Skip to content

Instantly share code, notes, and snippets.

@tuomastielinen
Last active August 29, 2015 14:07
Show Gist options
  • Save tuomastielinen/220a0699e6bc33388a41 to your computer and use it in GitHub Desktop.
Save tuomastielinen/220a0699e6bc33388a41 to your computer and use it in GitHub Desktop.
Vagrantfile for Ansible testing with three machines
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2
config.vm.provider "virtualbox" do |vb|
vb.gui = false
end
config.vm.define "ansible" do |ansible|
ansible.vm.box = "ubuntu/trusty64"
ansible.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
ansible.ssh.username = "vagrant"
ansible.vm.hostname = "ansible"
ansible.vm.network "private_network", ip: "192.168.56.101"
ansible.ssh.port = 2222
end
config.vm.define "web1" do |web1|
web1.vm.box = "ubuntu/trusty64"
web1.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
web1.ssh.username = "vagrant"
web1.vm.hostname = "web1"
web1.vm.network "private_network", ip: "192.168.56.102"
web1.ssh.port = 2200
end
config.vm.define "db1" do |db1|
db1.vm.box = "ubuntu/trusty64"
db1.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
db1.ssh.username = "vagrant"
db1.vm.hostname = "db1"
db1.vm.network "private_network", ip: "192.168.56.103"
db1.ssh.port = 2201
end
config.vm.provision "ansible" do |ansible|
ansible.extra_vars = { ansible_ssh_user: 'vagrant' }
ansible.playbook = "playbook.yml"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment