diff --git a/lamp-infrastructure/Vagrantfile b/lamp-infrastructure/Vagrantfile index 762f8d3..e18b9ec 100644 --- a/lamp-infrastructure/Vagrantfile +++ b/lamp-infrastructure/Vagrantfile @@ -7,7 +7,9 @@ Vagrant.configure("2") do |config| # General VirtualBox VM configuration. config.vm.provider :virtualbox do |v| + v.customize ["modifyvm", :id, "--memory", 512] v.customize ["modifyvm", :id, "--cpus", 1] + v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] v.customize ["modifyvm", :id, "--ioapic", "on"] end @@ -15,12 +17,6 @@ Vagrant.configure("2") do |config| config.vm.define "varnish" do |varnish| varnish.vm.hostname = "varnish.dev" varnish.vm.network :private_network, ip: "192.168.2.2" - - varnish.vm.provider :virtualbox do |v| - v.customize ["modifyvm", :id, "--name", "varnish.dev"] - v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] - v.customize ["modifyvm", :id, "--memory", 512] - end end # Apache. @@ -32,8 +28,6 @@ Vagrant.configure("2") do |config| inline: "sudo yum update -y" www1.vm.provider :virtualbox do |v| - v.customize ["modifyvm", :id, "--name", "www1.dev"] - v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] v.customize ["modifyvm", :id, "--memory", 256] end end @@ -47,8 +41,6 @@ Vagrant.configure("2") do |config| inline: "sudo yum update -y" www2.vm.provider :virtualbox do |v| - v.customize ["modifyvm", :id, "--name", "www2.dev"] - v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] v.customize ["modifyvm", :id, "--memory", 256] end end @@ -57,24 +49,12 @@ Vagrant.configure("2") do |config| config.vm.define "db1" do |db1| db1.vm.hostname = "db1.dev" db1.vm.network :private_network, ip: "192.168.2.5" - - db1.vm.provider :virtualbox do |v| - v.customize ["modifyvm", :id, "--name", "db1.dev"] - v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] - v.customize ["modifyvm", :id, "--memory", 512] - end end # MySQL. config.vm.define "db2" do |db2| db2.vm.hostname = "db2.dev" db2.vm.network :private_network, ip: "192.168.2.6" - - db2.vm.provider :virtualbox do |v| - v.customize ["modifyvm", :id, "--name", "db2.dev"] - v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] - v.customize ["modifyvm", :id, "--memory", 512] - end end # Memcached. @@ -82,12 +62,6 @@ Vagrant.configure("2") do |config| memcached.vm.hostname = "memcached.dev" memcached.vm.network :private_network, ip: "192.168.2.7" - memcached.vm.provider :virtualbox do |v| - v.customize ["modifyvm", :id, "--name", "memcached.dev"] - v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] - v.customize ["modifyvm", :id, "--memory", 512] - end - # Run Ansible provisioner once for all VMs at the end. memcached.vm.provision "ansible" do |ansible| ansible.playbook = "configure.yml" diff --git a/lamp-infrastructure/playbooks/db/main.yml b/lamp-infrastructure/playbooks/db/main.yml index 5365155..a9d0b34 100644 --- a/lamp-infrastructure/playbooks/db/main.yml +++ b/lamp-infrastructure/playbooks/db/main.yml @@ -9,8 +9,18 @@ - name: Create dynamic MySQL variables. set_fact: mysql_users: - - { name: mycompany_user, host: "{{ groups['lamp-www'][0] }}", password: secret, priv: "*.*:SELECT" } - - { name: mycompany_user, host: "{{ groups['lamp-www'][1] }}", password: secret, priv: "*.*:SELECT" } + - { + name: mycompany_user, + host: "{{ groups['lamp-www'][0] }}", + password: secret, + priv: "*.*:SELECT" + } + - { + name: mycompany_user, + host: "{{ groups['lamp-www'][1] }}", + password: secret, + priv: "*.*:SELECT" + } mysql_replication_master: "{{ groups['a4d.lamp.db.1'][0] }}" - debug: var=mysql_replication_master diff --git a/lamp-infrastructure/provisioners/digitalocean.yml b/lamp-infrastructure/provisioners/digitalocean.yml index 9a5586a..56d1537 100644 --- a/lamp-infrastructure/provisioners/digitalocean.yml +++ b/lamp-infrastructure/provisioners/digitalocean.yml @@ -4,7 +4,6 @@ gather_facts: false vars: - droplet_default_state: present droplets: - { name: a4d.lamp.varnish, ssh_key: "138954", group: "lamp-varnish" } - { name: a4d.lamp.www.1, ssh_key: "138954", group: "lamp-www" } @@ -16,7 +15,7 @@ tasks: - name: Provision DigitalOcean droplets. digital_ocean: - state: "{{ item.state | default(droplet_default_state) }}" + state: "{{ item.state | default('present') }}" command: droplet name: "{{ item.name }}" private_networking: yes