mirror of
https://github.com/geerlingguy/ansible-for-devops.git
synced 2024-05-19 06:50:03 +00:00
Update all Vagrant VM host-only private network IP ranges.
This commit is contained in:
@ -4,15 +4,15 @@ This project builds a simple application architecture with a load balancer which
|
||||
|
||||
The infrastructure is fairly simple, with the following structure:
|
||||
|
||||
-----------------------
|
||||
| HAProxy (192.168.4.2) |
|
||||
-----------------------
|
||||
------------------------
|
||||
| HAProxy (192.168.56.2) |
|
||||
------------------------
|
||||
|
|
||||
_______________________________
|
||||
| |
|
||||
---------------------- ----------------------
|
||||
| Apache (192.168.4.3) | | Apache (192.168.4.4) |
|
||||
---------------------- ----------------------
|
||||
----------------------- -----------------------
|
||||
| Apache (192.168.56.3) | | Apache (192.168.56.4) |
|
||||
----------------------- -----------------------
|
||||
|
||||
## Building the VMs
|
||||
|
||||
@ -22,7 +22,7 @@ The infrastructure is fairly simple, with the following structure:
|
||||
4. Run `ansible-galaxy install -r requirements.yml` in this directory to get the required Ansible roles.
|
||||
5. Run `vagrant up` to build the VMs and configure the infrastructure.
|
||||
|
||||
When Vagrant is finished provisioning the VMs with Ansible, you should be able to visit `http://192.168.4.2/`, and you'll see the default Ubuntu Apache 2 'installation complete' page (loaded from one of the two backend web servers through HAProxy).
|
||||
When Vagrant is finished provisioning the VMs with Ansible, you should be able to visit `http://192.168.56.2/`, and you'll see the default Ubuntu Apache 2 'installation complete' page (loaded from one of the two backend web servers through HAProxy).
|
||||
|
||||
## Performing a zero-downtime deployment
|
||||
|
||||
|
6
deployments-balancer/Vagrantfile
vendored
6
deployments-balancer/Vagrantfile
vendored
@ -15,9 +15,9 @@ Vagrant.configure("2") do |config|
|
||||
|
||||
# Define three VMs with static private IP addresses.
|
||||
boxes = [
|
||||
{ :name => "bal1", :ip => "192.168.4.2" },
|
||||
{ :name => "app1", :ip => "192.168.4.3" },
|
||||
{ :name => "app2", :ip => "192.168.4.4" }
|
||||
{ :name => "bal1", :ip => "192.168.56.2" },
|
||||
{ :name => "app1", :ip => "192.168.56.3" },
|
||||
{ :name => "app2", :ip => "192.168.56.4" }
|
||||
]
|
||||
|
||||
# Provision each of the VMs.
|
||||
|
@ -1,9 +1,9 @@
|
||||
[balancer]
|
||||
192.168.4.2
|
||||
192.168.56.2
|
||||
|
||||
[app]
|
||||
192.168.4.3
|
||||
192.168.4.4
|
||||
192.168.56.3
|
||||
192.168.56.4
|
||||
|
||||
[deployments:children]
|
||||
balancer
|
||||
|
@ -21,10 +21,10 @@
|
||||
|
||||
vars:
|
||||
haproxy_backend_servers:
|
||||
- name: 192.168.4.3
|
||||
address: 192.168.4.3:80
|
||||
- name: 192.168.4.4
|
||||
address: 192.168.4.4:80
|
||||
- name: 192.168.56.3
|
||||
address: 192.168.56.3:80
|
||||
- name: 192.168.56.4
|
||||
address: 192.168.56.4:80
|
||||
|
||||
roles:
|
||||
- geerlingguy.haproxy
|
||||
|
@ -13,7 +13,7 @@ This project builds a [Node.js](https://nodejs.org/)-based API app inside a VM.
|
||||
Once the VM is built, you can test the API by running the following command (copy and paste verbatim, without the leading `$`), which requests the `/hello/:name` endpoint on each server:
|
||||
|
||||
$ for i in {2..5}; \
|
||||
do curl -w "\n" "http://192.168.3.$i:8080/hello/john"; \
|
||||
do curl -w "\n" "http://192.168.56.$i:8080/hello/john"; \
|
||||
done
|
||||
|
||||
If the above command outputs `"hello john"` on four lines, everything worked correctly!
|
||||
|
8
deployments-rolling/Vagrantfile
vendored
8
deployments-rolling/Vagrantfile
vendored
@ -15,10 +15,10 @@ Vagrant.configure("2") do |config|
|
||||
|
||||
# Define four VMs with static private IP addresses.
|
||||
boxes = [
|
||||
{ :name => "nodejs1", :ip => "192.168.3.2" },
|
||||
{ :name => "nodejs2", :ip => "192.168.3.3" },
|
||||
{ :name => "nodejs3", :ip => "192.168.3.4" },
|
||||
{ :name => "nodejs4", :ip => "192.168.3.5" }
|
||||
{ :name => "nodejs1", :ip => "192.168.56.2" },
|
||||
{ :name => "nodejs2", :ip => "192.168.56.3" },
|
||||
{ :name => "nodejs3", :ip => "192.168.56.4" },
|
||||
{ :name => "nodejs4", :ip => "192.168.56.5" }
|
||||
]
|
||||
|
||||
# Provision each of the VMs.
|
||||
|
@ -1,8 +1,8 @@
|
||||
[nodejs-api]
|
||||
192.168.3.2
|
||||
192.168.3.3
|
||||
192.168.3.4
|
||||
192.168.3.5
|
||||
192.168.56.2
|
||||
192.168.56.3
|
||||
192.168.56.4
|
||||
192.168.56.5
|
||||
|
||||
[nodejs-api:vars]
|
||||
ansible_user=vagrant
|
||||
|
@ -10,7 +10,7 @@ This project builds a [Ruby on Rails](http://rubyonrails.org/)-based app inside
|
||||
4. Run `ansible-galaxy install -r requirements.yml` in this directory to get the required Ansible roles.
|
||||
5. Run `vagrant up` to build the VM and deploy the version of the app specified in `playbooks/vars.yml`.
|
||||
|
||||
Once the VM is built, you can visit `http://192.168.33.7/` (or whatever domain name you point to that IP address in your local hosts file) to view the demo app.
|
||||
Once the VM is built, you can visit `http://192.168.56.7/` (or whatever domain name you point to that IP address in your local hosts file) to view the demo app.
|
||||
|
||||
## Deploying application updates
|
||||
|
||||
|
2
deployments/Vagrantfile
vendored
2
deployments/Vagrantfile
vendored
@ -13,7 +13,7 @@ Vagrant.configure(2) do |config|
|
||||
end
|
||||
|
||||
config.vm.hostname = "rails-demo"
|
||||
config.vm.network :private_network, ip: "192.168.33.7"
|
||||
config.vm.network :private_network, ip: "192.168.56.7"
|
||||
|
||||
config.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "playbooks/main.yml"
|
||||
|
@ -1,5 +1,5 @@
|
||||
[rails]
|
||||
192.168.33.7
|
||||
192.168.56.7
|
||||
|
||||
[rails:vars]
|
||||
ansible_user=vagrant
|
||||
|
@ -32,7 +32,7 @@ Once the new VM is up and running (after `vagrant up` is complete and you're bac
|
||||
|
||||
You need to modify your host machine's hosts file (Mac/Linux: `/etc/hosts`; Windows: `%systemroot%\system32\drivers\etc\hosts`), adding the line below:
|
||||
|
||||
192.168.33.39 docker-flask.test
|
||||
192.168.56.39 docker-flask.test
|
||||
|
||||
After that is configured, you could visit http://docker-flask.test/ in a browser, and you'll see the test page, confirming the Flask container can communicate with the MySQL container.
|
||||
|
||||
|
2
docker-flask/Vagrantfile
vendored
2
docker-flask/Vagrantfile
vendored
@ -5,7 +5,7 @@ VAGRANTFILE_API_VERSION = "2"
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.box = "geerlingguy/ubuntu2004"
|
||||
config.vm.network :private_network, ip: "192.168.33.39"
|
||||
config.vm.network :private_network, ip: "192.168.56.39"
|
||||
config.ssh.insert_key = false
|
||||
|
||||
config.vm.hostname = "docker-flask.test"
|
||||
|
@ -32,7 +32,7 @@ Note: *If there are any errors during the course of running `vagrant up`, and it
|
||||
|
||||
### 3 - Configure your host machine to access the VM.
|
||||
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.88.8 drupal.test` so you can connect to the VM.
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.56.8 drupal.test` so you can connect to the VM.
|
||||
2. Open your browser and access [http://drupal.test/](http://drupal.test/).
|
||||
|
||||
## Notes
|
||||
|
2
drupal/Vagrantfile
vendored
2
drupal/Vagrantfile
vendored
@ -5,7 +5,7 @@ VAGRANTFILE_API_VERSION = "2"
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.box = "geerlingguy/ubuntu2004"
|
||||
config.vm.network :private_network, ip: "192.168.88.8"
|
||||
config.vm.network :private_network, ip: "192.168.56.8"
|
||||
config.vm.hostname = "drupal.test"
|
||||
config.ssh.insert_key = false
|
||||
|
||||
|
@ -6,7 +6,7 @@ Each of the scripts has comments for all the different parts of the code which g
|
||||
|
||||
## Testing these scripts
|
||||
|
||||
A Vagrantfile is provided, so you can build a couple local VMs to test with the inventory scripts. Make sure you have Vagrant and VirtualBox installed, and run `vagrant up` inside this folder to build the two VMs, with the IP addresses `192.168.28.71` and `192.168.28.72`.
|
||||
A Vagrantfile is provided, so you can build a couple local VMs to test with the inventory scripts. Make sure you have Vagrant and VirtualBox installed, and run `vagrant up` inside this folder to build the two VMs, with the IP addresses `192.168.56.71` and `192.168.56.72`.
|
||||
|
||||
Then run the following command to test the inventory file with Ansible:
|
||||
|
||||
|
4
dynamic-inventory/custom/Vagrantfile
vendored
4
dynamic-inventory/custom/Vagrantfile
vendored
@ -11,13 +11,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.define "inventory1" do |inventory|
|
||||
inventory.vm.hostname = "inventory1.test"
|
||||
inventory.vm.box = "geerlingguy/ubuntu2004"
|
||||
inventory.vm.network :private_network, ip: "192.168.28.71"
|
||||
inventory.vm.network :private_network, ip: "192.168.56.71"
|
||||
end
|
||||
|
||||
# Application server 2.
|
||||
config.vm.define "inventory2" do |inventory|
|
||||
inventory.vm.hostname = "inventory2.test"
|
||||
inventory.vm.box = "geerlingguy/ubuntu2004"
|
||||
inventory.vm.network :private_network, ip: "192.168.28.72"
|
||||
inventory.vm.network :private_network, ip: "192.168.56.72"
|
||||
end
|
||||
end
|
||||
|
@ -15,7 +15,7 @@
|
||||
function example_inventory() {
|
||||
return [
|
||||
'group' => [
|
||||
'hosts' => ['192.168.28.71', '192.168.28.72'],
|
||||
'hosts' => ['192.168.56.71', '192.168.56.72'],
|
||||
'vars' => [
|
||||
'ansible_user' => 'vagrant',
|
||||
'ansible_ssh_private_key_file' => '~/.vagrant.d/insecure_private_key',
|
||||
@ -25,10 +25,10 @@ function example_inventory() {
|
||||
],
|
||||
'_meta' => [
|
||||
'hostvars' => [
|
||||
'192.168.28.71' => [
|
||||
'192.168.56.71' => [
|
||||
'host_specific_var' => 'foo',
|
||||
],
|
||||
'192.168.28.72' => [
|
||||
'192.168.56.72' => [
|
||||
'host_specific_var' => 'bar',
|
||||
],
|
||||
],
|
||||
|
@ -32,7 +32,7 @@ class ExampleInventory(object):
|
||||
def example_inventory(self):
|
||||
return {
|
||||
'group': {
|
||||
'hosts': ['192.168.28.71', '192.168.28.72'],
|
||||
'hosts': ['192.168.56.71', '192.168.56.72'],
|
||||
'vars': {
|
||||
'ansible_user': 'vagrant',
|
||||
'ansible_ssh_private_key_file':
|
||||
@ -44,10 +44,10 @@ class ExampleInventory(object):
|
||||
},
|
||||
'_meta': {
|
||||
'hostvars': {
|
||||
'192.168.28.71': {
|
||||
'192.168.56.71': {
|
||||
'host_specific_var': 'foo'
|
||||
},
|
||||
'192.168.28.72': {
|
||||
'192.168.56.72': {
|
||||
'host_specific_var': 'bar'
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ Once the VMs are up and running (after `vagrant up` is complete and you're back
|
||||
|
||||
You need to modify your host machine's hosts file (Mac/Linux: `/etc/hosts`; Windows: `%systemroot%\system32\drivers\etc\hosts`), adding the lines below:
|
||||
|
||||
192.168.9.90 logs.test
|
||||
192.168.9.91 web.test
|
||||
192.168.56.90 logs.test
|
||||
192.168.56.91 web.test
|
||||
|
||||
(Where `logs.test`/`web.test` is the hostname you have configured in the `Vagrantfile`).
|
||||
|
||||
|
4
elk/Vagrantfile
vendored
4
elk/Vagrantfile
vendored
@ -18,7 +18,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
# ELK server.
|
||||
config.vm.define "logs" do |logs|
|
||||
logs.vm.hostname = "logs.test"
|
||||
logs.vm.network :private_network, ip: "192.168.9.90"
|
||||
logs.vm.network :private_network, ip: "192.168.56.90"
|
||||
|
||||
logs.vm.provision :ansible do |ansible|
|
||||
ansible.playbook = "provisioning/elk/main.yml"
|
||||
@ -30,7 +30,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
# Web server.
|
||||
config.vm.define "web" do |web|
|
||||
web.vm.hostname = "web.test"
|
||||
web.vm.network :private_network, ip: "192.168.9.91"
|
||||
web.vm.network :private_network, ip: "192.168.56.91"
|
||||
|
||||
web.vm.provider :virtualbox do |v|
|
||||
v.memory = 512
|
||||
|
@ -1,2 +1,2 @@
|
||||
[logs]
|
||||
logs.test ansible_ssh_host=192.168.9.90 ansible_ssh_port=22
|
||||
logs.test ansible_ssh_host=192.168.56.90 ansible_ssh_port=22
|
||||
|
@ -1,2 +1,2 @@
|
||||
[web]
|
||||
web.test ansible_ssh_host=192.168.9.91 ansible_ssh_port=22
|
||||
web.test ansible_ssh_host=192.168.56.91 ansible_ssh_port=22
|
||||
|
@ -27,5 +27,5 @@
|
||||
lineinfile:
|
||||
dest: /etc/hosts
|
||||
regexp: '.*logs\.test$'
|
||||
line: "192.168.9.90 logs.test"
|
||||
line: "192.168.56.90 logs.test"
|
||||
state: present
|
||||
|
@ -6,7 +6,7 @@ This folder contains two quick demo playbooks which build a LAMP and Apache Solr
|
||||
|
||||
After running `vagrant up`, you can access the installed LAMP site or Solr Admin dashboard following these instructions:
|
||||
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.18.8 galaxy-role-servers.test` so you can connect to the VM.
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.56.8 galaxy-role-servers.test` so you can connect to the VM.
|
||||
2. Open your browser and access the following:
|
||||
a. LAMP server: [http://galaxy-role-servers.test/](http://galaxy-role-servers.test/).
|
||||
b. Solr Admin dashboard: [http://galaxy-role-servers.test:8983/](http://galaxy-role-servers.test:8983/).
|
||||
|
2
galaxy-role-servers/Vagrantfile
vendored
2
galaxy-role-servers/Vagrantfile
vendored
@ -5,7 +5,7 @@ VAGRANTFILE_API_VERSION = "2"
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.box = "geerlingguy/ubuntu2004"
|
||||
config.vm.network :private_network, ip: "192.168.18.8"
|
||||
config.vm.network :private_network, ip: "192.168.56.8"
|
||||
config.vm.hostname = "galaxy-role-servers.test"
|
||||
config.ssh.insert_key = false
|
||||
|
||||
|
4
gluster/Vagrantfile
vendored
4
gluster/Vagrantfile
vendored
@ -14,8 +14,8 @@ Vagrant.configure("2") do |config|
|
||||
|
||||
# Define two VMs with static private IP addresses.
|
||||
boxes = [
|
||||
{ :name => "gluster1", :ip => "192.168.29.2" },
|
||||
{ :name => "gluster2", :ip => "192.168.29.3" }
|
||||
{ :name => "gluster1", :ip => "192.168.56.2" },
|
||||
{ :name => "gluster2", :ip => "192.168.56.3" }
|
||||
]
|
||||
|
||||
# Provision each of the VMs.
|
||||
|
@ -1,6 +1,6 @@
|
||||
[gluster]
|
||||
192.168.29.2
|
||||
192.168.29.3
|
||||
192.168.56.2
|
||||
192.168.56.3
|
||||
|
||||
[gluster:vars]
|
||||
ansible_ssh_user=vagrant
|
||||
|
@ -24,7 +24,7 @@ Note: *If there are any errors during the course of running `vagrant up`, and it
|
||||
|
||||
### 3 - Configure your host machine to access the VM.
|
||||
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.46.84 https-proxy.test` so you can connect to the VM.
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.56.84 https-proxy.test` so you can connect to the VM.
|
||||
2. Open your browser and access [http://https.test](http://https.test), and you should be redirected to the `https://` version of the URL.
|
||||
|
||||
## Notes
|
||||
|
2
https-nginx-proxy/Vagrantfile
vendored
2
https-nginx-proxy/Vagrantfile
vendored
@ -6,7 +6,7 @@ VAGRANTFILE_API_VERSION = "2"
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.box = "geerlingguy/debian10"
|
||||
config.vm.hostname = "https-proxy.test"
|
||||
config.vm.network :private_network, ip: "192.168.46.84"
|
||||
config.vm.network :private_network, ip: "192.168.56.84"
|
||||
config.ssh.insert_key = false
|
||||
|
||||
config.vm.provider :virtualbox do |v|
|
||||
|
@ -24,7 +24,7 @@ Note: *If there are any errors during the course of running `vagrant up`, and it
|
||||
|
||||
### 3 - Configure your host machine to access the VM.
|
||||
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.76.84 https.test` so you can connect to the VM.
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.56.84 https.test` so you can connect to the VM.
|
||||
2. Open your browser and access [https://https.test](https://https.test).
|
||||
|
||||
## Notes
|
||||
|
2
https-self-signed/Vagrantfile
vendored
2
https-self-signed/Vagrantfile
vendored
@ -6,7 +6,7 @@ VAGRANTFILE_API_VERSION = "2"
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.box = "geerlingguy/ubuntu2004"
|
||||
config.vm.hostname = "https.test"
|
||||
config.vm.network :private_network, ip: "192.168.76.84"
|
||||
config.vm.network :private_network, ip: "192.168.56.84"
|
||||
config.ssh.insert_key = false
|
||||
|
||||
config.vm.provider :virtualbox do |v|
|
||||
|
@ -4,7 +4,7 @@ This example playbook takes the `drupal` playbook example (included in the same
|
||||
|
||||
After running `vagrant up`, you can access the installed Drupal site following these instructions:
|
||||
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.88.89 drupal.test` so you can connect to the VM.
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.56.89 drupal.test` so you can connect to the VM.
|
||||
2. Open your browser and access [http://drupal.test/](http://drupal.test/).
|
||||
|
||||
## About the Author
|
||||
|
2
includes/Vagrantfile
vendored
2
includes/Vagrantfile
vendored
@ -5,7 +5,7 @@ VAGRANTFILE_API_VERSION = "2"
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.box = "geerlingguy/ubuntu2004"
|
||||
config.vm.network :private_network, ip: "192.168.88.89"
|
||||
config.vm.network :private_network, ip: "192.168.56.89"
|
||||
config.vm.hostname = "drupal.test"
|
||||
config.ssh.insert_key = false
|
||||
|
||||
|
@ -23,7 +23,7 @@ Note: *If there are any errors during the course of running `vagrant up`, and it
|
||||
|
||||
### 3 - Configure your host machine to access the VM.
|
||||
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.76.76 jenkinsci.test` so you can connect to the VM.
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.56.76 jenkinsci.test` so you can connect to the VM.
|
||||
2. Open your browser and access [http://jenkinsci.test:8080](http://jenkinsci.test:8080).
|
||||
|
||||
## Notes
|
||||
|
2
jenkins/Vagrantfile
vendored
2
jenkins/Vagrantfile
vendored
@ -6,7 +6,7 @@ VAGRANTFILE_API_VERSION = "2"
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.box = "geerlingguy/ubuntu2004"
|
||||
config.vm.hostname = "jenkinsci.test"
|
||||
config.vm.network :private_network, ip: "192.168.76.76"
|
||||
config.vm.network :private_network, ip: "192.168.56.76"
|
||||
config.ssh.insert_key = false
|
||||
|
||||
config.vm.provider :virtualbox do |v|
|
||||
|
@ -23,7 +23,7 @@ Note: *If there are any errors during the course of running `vagrant up`, and it
|
||||
|
||||
### 3 - Configure your host machine to access the VM.
|
||||
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.84.3 cluster.k8s.test` so you can connect to the VM.
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.56.3 cluster.k8s.test` so you can connect to the VM.
|
||||
|
||||
### 4 - Deploy applications to the Kubernetes cluster
|
||||
|
||||
|
6
kubernetes/Vagrantfile
vendored
6
kubernetes/Vagrantfile
vendored
@ -16,9 +16,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
|
||||
# Define three VMs with static private IP addresses.
|
||||
boxes = [
|
||||
{ :name => "master", :ip => "192.168.84.2" },
|
||||
{ :name => "node1", :ip => "192.168.84.3" },
|
||||
{ :name => "node2", :ip => "192.168.84.4" },
|
||||
{ :name => "master", :ip => "192.168.56.2" },
|
||||
{ :name => "node1", :ip => "192.168.56.3" },
|
||||
{ :name => "node2", :ip => "192.168.56.4" },
|
||||
]
|
||||
|
||||
# Provision each of the VMs.
|
||||
|
@ -1,9 +1,9 @@
|
||||
[k8s-master]
|
||||
master ansible_host=192.168.84.2 kubernetes_role=master
|
||||
master ansible_host=192.168.56.2 kubernetes_role=master
|
||||
|
||||
[k8s-nodes]
|
||||
node1 ansible_host=192.168.84.3 kubernetes_role=node
|
||||
node2 ansible_host=192.168.84.4 kubernetes_role=node
|
||||
node1 ansible_host=192.168.56.3 kubernetes_role=node
|
||||
node2 ansible_host=192.168.56.4 kubernetes_role=node
|
||||
|
||||
[k8s:children]
|
||||
k8s-master
|
||||
|
@ -18,6 +18,6 @@ kubernetes_packages:
|
||||
- name: kubernetes-cni
|
||||
state: present
|
||||
|
||||
kubernetes_apiserver_advertise_address: "192.168.84.2"
|
||||
kubernetes_apiserver_advertise_address: "192.168.56.2"
|
||||
kubernetes_flannel_manifest_file: "~/kube-flannel-vagrant.yml"
|
||||
kubernetes_kubelet_extra_args: '--node-ip={{ ansible_host }}'
|
||||
|
@ -6,22 +6,22 @@ The architecture for the example web application will be:
|
||||
|
||||
--------------------------
|
||||
| varnish.test (Varnish) |
|
||||
| 192.168.2.2 |
|
||||
| 192.168.56.2 |
|
||||
--------------------------
|
||||
/ \
|
||||
---------------------- ----------------------
|
||||
| www1.test (Apache) | | www2.test (Apache) |
|
||||
| 192.168.2.3 | | 192.168.2.4 |
|
||||
| 192.168.56.3 | | 192.168.56.4 |
|
||||
---------------------- ----------------------
|
||||
\ /
|
||||
------------------------------
|
||||
| memcached.test (Memcached) |
|
||||
| 192.168.2.7 |
|
||||
| 192.168.56.7 |
|
||||
------------------------------
|
||||
/ \
|
||||
----------------------------- ----------------------------
|
||||
| db1.test (MySQL - Master) | | db2.test (MySQL - Slave) |
|
||||
| 192.168.2.5 | | 192.168.2.6 |
|
||||
| 192.168.56.5 | | 192.168.56.6 |
|
||||
----------------------------- ----------------------------
|
||||
|
||||
*IP addresses and hostnames in this diagram are modeled after local VirtualBox/Vagrant-based VMs.*
|
||||
@ -47,7 +47,7 @@ To build the VMs and configure them using Ansible, follow these steps (both from
|
||||
|
||||
This guide assumes you already have Vagrant, VirtualBox, and Ansible installed locally.
|
||||
|
||||
After everything is booted and configured, visit http://varnish.test/ (if you configured the domain in your hosts file with the line `192.168.2.2 varnish.test`) in a browser, and refresh a few times to see that Varnish, Apache, PHP, Memcached, and MySQL are all working properly!
|
||||
After everything is booted and configured, visit http://varnish.test/ (if you configured the domain in your hosts file with the line `192.168.56.2 varnish.test`) in a browser, and refresh a few times to see that Varnish, Apache, PHP, Memcached, and MySQL are all working properly!
|
||||
|
||||
## Build and configure the servers (DigitalOcean)
|
||||
|
||||
|
12
lamp-infrastructure/Vagrantfile
vendored
12
lamp-infrastructure/Vagrantfile
vendored
@ -19,13 +19,13 @@ Vagrant.configure("2") do |config|
|
||||
# Varnish.
|
||||
config.vm.define "varnish" do |varnish|
|
||||
varnish.vm.hostname = "varnish.test"
|
||||
varnish.vm.network :private_network, ip: "192.168.2.2"
|
||||
varnish.vm.network :private_network, ip: "192.168.56.2"
|
||||
end
|
||||
|
||||
# Apache.
|
||||
config.vm.define "www1" do |www1|
|
||||
www1.vm.hostname = "www1.test"
|
||||
www1.vm.network :private_network, ip: "192.168.2.3"
|
||||
www1.vm.network :private_network, ip: "192.168.56.3"
|
||||
|
||||
www1.vm.provision "shell",
|
||||
inline: "sudo yum update -y"
|
||||
@ -38,7 +38,7 @@ Vagrant.configure("2") do |config|
|
||||
# Apache.
|
||||
config.vm.define "www2" do |www2|
|
||||
www2.vm.hostname = "www2.test"
|
||||
www2.vm.network :private_network, ip: "192.168.2.4"
|
||||
www2.vm.network :private_network, ip: "192.168.56.4"
|
||||
|
||||
www2.vm.provision "shell",
|
||||
inline: "sudo yum update -y"
|
||||
@ -51,19 +51,19 @@ Vagrant.configure("2") do |config|
|
||||
# MySQL.
|
||||
config.vm.define "db1" do |db1|
|
||||
db1.vm.hostname = "db1.test"
|
||||
db1.vm.network :private_network, ip: "192.168.2.5"
|
||||
db1.vm.network :private_network, ip: "192.168.56.5"
|
||||
end
|
||||
|
||||
# MySQL.
|
||||
config.vm.define "db2" do |db2|
|
||||
db2.vm.hostname = "db2.test"
|
||||
db2.vm.network :private_network, ip: "192.168.2.6"
|
||||
db2.vm.network :private_network, ip: "192.168.56.6"
|
||||
end
|
||||
|
||||
# Memcached.
|
||||
config.vm.define "memcached" do |memcached|
|
||||
memcached.vm.hostname = "memcached.test"
|
||||
memcached.vm.network :private_network, ip: "192.168.2.7"
|
||||
memcached.vm.network :private_network, ip: "192.168.56.7"
|
||||
|
||||
# Run Ansible provisioner once for all VMs at the end.
|
||||
memcached.vm.provision "ansible" do |ansible|
|
||||
|
@ -1,16 +1,16 @@
|
||||
[lamp_varnish]
|
||||
192.168.2.2
|
||||
192.168.56.2
|
||||
|
||||
[lamp_www]
|
||||
192.168.2.3
|
||||
192.168.2.4
|
||||
192.168.56.3
|
||||
192.168.56.4
|
||||
|
||||
[a4d.lamp.db.1]
|
||||
192.168.2.5
|
||||
192.168.56.5
|
||||
|
||||
[lamp_db]
|
||||
192.168.2.5 mysql_replication_role=master
|
||||
192.168.2.6 mysql_replication_role=slave
|
||||
192.168.56.5 mysql_replication_role=master
|
||||
192.168.56.6 mysql_replication_role=slave
|
||||
|
||||
[lamp_memcached]
|
||||
192.168.2.7
|
||||
192.168.56.7
|
||||
|
@ -6,7 +6,7 @@ The primary difference in this example (as explained in [Ansible for DevOps](htt
|
||||
|
||||
After running `vagrant up`, perform the following steps to access the app via a hostname:
|
||||
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.55.56 nodejs-role.test` so you can connect to the VM.
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.56.56 nodejs-role.test` so you can connect to the VM.
|
||||
2. Open your browser and access [http://nodejs-role.test/](http://nodejs-role.test/).
|
||||
|
||||
## About the Author
|
||||
|
2
nodejs-role/Vagrantfile
vendored
2
nodejs-role/Vagrantfile
vendored
@ -5,7 +5,7 @@ VAGRANTFILE_API_VERSION = "2"
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.box = "geerlingguy/rockylinux8"
|
||||
config.vm.network :private_network, ip: "192.168.55.56"
|
||||
config.vm.network :private_network, ip: "192.168.56.56"
|
||||
config.ssh.insert_key = false
|
||||
config.vm.synced_folder ".", "/vagrant", disabled: true
|
||||
|
||||
|
@ -30,7 +30,7 @@ Note: *If there are any errors during the course of running `vagrant up`, and it
|
||||
|
||||
### 3 - Configure your host machine to access the VM.
|
||||
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.55.55 nodejs.test` so you can connect to the VM.
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.56.55 nodejs.test` so you can connect to the VM.
|
||||
2. Open your browser and access [http://nodejs.test/](http://nodejs.test/).
|
||||
|
||||
## Notes
|
||||
|
2
nodejs/Vagrantfile
vendored
2
nodejs/Vagrantfile
vendored
@ -6,7 +6,7 @@ VAGRANTFILE_API_VERSION = "2"
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.box = "geerlingguy/rockylinux8"
|
||||
config.vm.hostname = "nodejs.test"
|
||||
config.vm.network :private_network, ip: "192.168.55.55"
|
||||
config.vm.network :private_network, ip: "192.168.56.55"
|
||||
config.ssh.insert_key = false
|
||||
config.vm.synced_folder ".", "/vagrant", disabled: true
|
||||
|
||||
|
6
orchestration/Vagrantfile
vendored
6
orchestration/Vagrantfile
vendored
@ -16,18 +16,18 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
# Application server 1.
|
||||
config.vm.define "app1" do |app|
|
||||
app.vm.hostname = "orc-app1.test"
|
||||
app.vm.network :private_network, ip: "192.168.60.4"
|
||||
app.vm.network :private_network, ip: "192.168.56.4"
|
||||
end
|
||||
|
||||
# Application server 2.
|
||||
config.vm.define "app2" do |app|
|
||||
app.vm.hostname = "orc-app2.test"
|
||||
app.vm.network :private_network, ip: "192.168.60.5"
|
||||
app.vm.network :private_network, ip: "192.168.56.5"
|
||||
end
|
||||
|
||||
# Database server.
|
||||
config.vm.define "db" do |db|
|
||||
db.vm.hostname = "orc-db.test"
|
||||
db.vm.network :private_network, ip: "192.168.60.6"
|
||||
db.vm.network :private_network, ip: "192.168.56.6"
|
||||
end
|
||||
end
|
||||
|
@ -1,11 +1,11 @@
|
||||
# Application servers
|
||||
[app]
|
||||
192.168.60.4
|
||||
192.168.60.5
|
||||
192.168.56.4
|
||||
192.168.56.5
|
||||
|
||||
# Database server
|
||||
[db]
|
||||
192.168.60.6
|
||||
192.168.56.6
|
||||
|
||||
# Group 'multi' with all servers
|
||||
[multi:children]
|
||||
|
@ -11,7 +11,7 @@ ansible db -b -m service -a "name=mariadb state=started enabled=yes"
|
||||
ansible db -b -m dnf -a "name=firewalld state=present"
|
||||
ansible db -b -m service -a "name=firewalld state=started enabled=yes"
|
||||
ansible db -b -m firewalld -a "zone=database state=present permanent=yes"
|
||||
ansible db -b -m firewalld -a "source=192.168.60.0/24 zone=database state=enabled permanent=yes"
|
||||
ansible db -b -m firewalld -a "source=192.168.56.0/24 zone=database state=enabled permanent=yes"
|
||||
ansible db -b -m firewalld -a "port=3306/tcp zone=database state=enabled permanent=yes"
|
||||
|
||||
# Configure DB user for Django.
|
||||
|
@ -29,7 +29,7 @@ Note: *If there are any errors during the course of running `vagrant up`, and it
|
||||
|
||||
### 3 - Configure your host machine to access the VM.
|
||||
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.66.66 solr.test` so you can connect to the VM.
|
||||
1. [Edit your hosts file](http://docs.rackspace.com/support/how-to/modify-your-hosts-file/), adding the line `192.168.56.66 solr.test` so you can connect to the VM.
|
||||
2. Open your browser and access [http://solr.test:8983/solr/](http://solr.test:8983/solr).
|
||||
|
||||
## Notes
|
||||
|
2
solr/Vagrantfile
vendored
2
solr/Vagrantfile
vendored
@ -5,7 +5,7 @@ VAGRANTFILE_API_VERSION = "2"
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.box = "geerlingguy/ubuntu2004"
|
||||
config.vm.network :private_network, ip: "192.168.66.66"
|
||||
config.vm.network :private_network, ip: "192.168.56.66"
|
||||
config.vm.hostname = "solr.test"
|
||||
config.ssh.insert_key = false
|
||||
|
||||
|
Reference in New Issue
Block a user