Skip to content

Instantly share code, notes, and snippets.

@rubendob
Created March 12, 2015 11:47
Show Gist options
  • Save rubendob/ed0d756bd1b3dc00dd2b to your computer and use it in GitHub Desktop.
Save rubendob/ed0d756bd1b3dc00dd2b to your computer and use it in GitHub Desktop.
PXC-Ansible
-*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
cluster = {
"node1" => { :ip => "192.168.33.50", :cpus => 1, :mem => 1024 },
"node2" => { :ip => "192.168.33.51", :cpus => 1, :mem => 1024 },
"node3" => { :ip => "192.168.33.52", :cpus => 1, :mem => 1024 },
}
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/precise64"
cluster.each_with_index do |(hostname, info), index|
config.vm.define hostname do |cfg|
cfg.vm.provider :virtualbox do |vb, override|
config.vm.box = "ubuntu/precise64"
override.vm.network :private_network, ip: "#{info[:ip]}"
override.vm.hostname = hostname
vb.name = 'pxc-' + hostname
vb.customize ["modifyvm", :id, "--memory", info[:mem], "--cpus", info[:cpus], "--hwvirtex", "on" ]
end # end provider
# provision nodes with ansible
if index == cluster.size - 1
cfg.vm.provision :ansible do |ansible|
#ansible.verbose = "vvvv"
ansible.extra_vars = { ansible_ssh_user: 'vagrant' }
ansible.inventory_path = "./inventory"
ansible.playbook = "playbook.yml"
ansible.limit = "local"
end # end provision
end #end if
end # end config
end # end cluster
end # end vagrant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment