moved ansible inventory generation out of Vagrant
This commit is contained in:
@ -13,20 +13,9 @@ Vagrant.configure("2") do |config|
|
||||
num_webserver = #{numWebserver}
|
||||
num_loadbalancer = #{numLoadbalancers}
|
||||
|
||||
ansible_groups = {
|
||||
"loadbalancer" => [],
|
||||
"webserver" => []
|
||||
}
|
||||
ansible_vars = {}
|
||||
|
||||
(1..num_webserver).each do |nth|
|
||||
machine_id = "#{customerName}-bloated-debian-web%d" % [nth]
|
||||
ansible_groups["webserver"] << machine_id
|
||||
|
||||
machine_id = "#{customerName}-bloated-debian-web%d" % [nth]
|
||||
machine_ip = increment_ip()
|
||||
ansible_vars[machine_id] = {
|
||||
"ipv4_address" => machine_ip
|
||||
}
|
||||
|
||||
config.vm.define machine_id do |web|
|
||||
web.vm.box = "ubuntu/focal64"
|
||||
@ -40,25 +29,12 @@ Vagrant.configure("2") do |config|
|
||||
vb.gui = false
|
||||
vb.name = machine_id
|
||||
end
|
||||
|
||||
if nth == num_webserver
|
||||
config.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "./playbooks/install_nginx.yml"
|
||||
ansible.groups = ansible_groups
|
||||
ansible.host_vars = ansible_vars
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
(1..num_loadbalancer).each do |nth|
|
||||
machine_id = "#{customerName}-bloated-debian-lb%d" % [nth]
|
||||
ansible_groups["loadbalancer"] << machine_id
|
||||
|
||||
machine_id = "#{customerName}-bloated-debian-lb%d" % [nth]
|
||||
machine_ip = increment_ip()
|
||||
ansible_vars[machine_id] = {
|
||||
"ipv4_address" => machine_ip
|
||||
}
|
||||
|
||||
config.vm.define machine_id do |web|
|
||||
web.vm.box = "ubuntu/focal64"
|
||||
@ -72,14 +48,6 @@ Vagrant.configure("2") do |config|
|
||||
vb.gui = false
|
||||
vb.name = machine_id
|
||||
end
|
||||
|
||||
if nth == num_loadbalancer
|
||||
config.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "./playbooks/install_loadbalancer.yml"
|
||||
ansible.groups = ansible_groups
|
||||
ansible.host_vars = ansible_vars
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user