Skip to content

Instantly share code, notes, and snippets.

@basz
Created September 29, 2015 19:42
Show Gist options
  • Select an option

  • Save basz/b2f4249e5df42c60f63e to your computer and use it in GitHub Desktop.

Select an option

Save basz/b2f4249e5df42c60f63e to your computer and use it in GitHub Desktop.
192.168.33.10 web.localhost # VAGRANT: ebc283c1f8ffc9e5cbe2478efab4e0ce (web) / b442f183-a01f-47d3-b3fc-eed832482bfb
192.168.33.11 db.localhost # VAGRANT: 6326d8261d43a18c63fb327a9d37abb4 (db) / 50816a6b-921e-4079-bedb-11f04a14987d
192.168.33.12 worker.localhost # VAGRANT: f0a3c4cc0918527022d4b00405ad86ac (worker) / ea8fbb1c-459d-455b-ae35-3f2c55c83201
require_relative './vagrant/key_authorization'
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
authorize_key_for_root config, '~/.ssh/id_dsa.pub', '~/.ssh/id_rsa.pub'
pool = {
'web' => '192.168.33.10',
'db' => '192.168.33.11',
'worker' => '192.168.33.12',
}
pool.each do |short_name, ip|
config.vm.define short_name do |host_config|
host_config.vm.network 'private_network', ip: "#{ip}"
host_config.vm.hostname = "#{short_name}.localhost"
host_config.vm.synced_folder "./vm-mounts/#{short_name}-localhost", "/vagrant", owner: "root", group: "root", create: true
config.vm.provision "ansible" do |ansible|
ansible.playbook = "ansible/playbook-common.yml"
ansible.sudo = true
ansible.limit = "#{short_name}"
# note: an ansible inventory file is create by vagrant, only use this to run the 'common' playbook
# ansible.inventory_path = "ansible/inventory-local.yml"
# ansible.verbose = "vvvv"
end
end
end
# Remove line in host's known_host file through Vagrant
#
# requires : vagrant-triggers
# vagrant plugin install vagrant-triggers
#
config.trigger.after :destroy do
puts "Removing known host entries"
`sed -i '' '/192\.168\.33\.[0-9]{1,3}/d' ~/.ssh/known_hosts`
end
end
# For vagrant virtual machines
#
# SECURITY NOTICE: Absolutely do not do this for your production servers. This
# is only safe on a private vagrant network with your own VMs.
Host 192.168.33.* *.localhost
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
User root
LogLevel ERROR
rattletrap:provisi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment