Closed alexandru-calinoiu closed 9 years ago
I would like to add to this:
Is there a way to run the provision trigger only if the provisioning succeeded on all vms in a multivm environment?
This should work starting from version 0.5.0, using the new provisioner-like syntax:
config.vm.provision "trigger", :option => "value" do |trigger|
trigger.fire do
run "script"
end
end
Hi Emyl,
Thanks for implementing this. Would you be able to clarify how I could automatically execute some script after provisioning was successful for all VMs in a multi-VM environment?
An extract from my Vagrantconfig is below:
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
...
# setup loadbalancer node(s)
0.upto($lb_ip_offset) do |num|
config.vm.define "lb#{num}" do |lb|
lb.vm.network :private_network ...
lb.vm.hostname = "lb#{num}.#{$domain_name}"
lb.vm.box = $os_string
lb.vm.provision "shell", path: "scripts/install_lb_node.sh", args: "#{num} \"#{$os_repo_install_cmd}\""
end
end
# setup the database nodes
1.upto($db_node_count) do |num|
config.vm.define "node#{num}" do |node|
node.vm.network :private_network ...
node.vm.hostname = "node#{num}.#{$domain_name}"
node.vm.box = $os_string
node.vm.provision "shell", path: "scripts/install_db_node.sh", args: "#{num} #{cookie} \"#{$os_repo_install_cmd}\""
end
end
...
# how to run a script after all vms have been successfully provisioned?
end
Is there a way to run the provision trigger only if the provisioning succeded?