Hello,
Vagrantfile is read top to bottom.
So if you need the worker after the server put them in different order.
server
node
If you want one script to run in all the nodes, put a
config.vm.provision "shell" after the 2nd box, and that will run at
the end.
here the rule of "inside" > "outside" will apply.
Vagrant.configure("2") do |config|
# server to configure
config.vm.define "server" do |server|
server.vm.box = "hashicorp/precise64"
server.vm.hostname = "server01"
server.vm.network "private_network", ip: "192.168.50.5"
server.vm.provision "shell", path: "setup-server.sh"
end
# workstation node
config.vm.define "work" do |work|
work.vm.box = "hashicorp/precise64"
work.vm.hostname = "workstation01"
work.vm.network "private_network", ip: "192.168.50.4"
work.vm.provision "shell", path: "setup-work.sh"
end
#at this point all the vms have been configured and the local
scripts have been run
config.vm.provision "shell", path: "post.sh"
end
If you require a script, to run in the server after all the workers
have been setup, I will say the easiest way will be make the script to
check host name. Same goes to run something in all the workers but not
on the server
If you need a 2nd pass after the first post run :D just add a second
script. etc.
in the script you can use something like
if [[ "${HOSTNAME}" =~ "workstation" ]];then
echo "doing something here for workstation"
if [[ "${HOSTNAME}" =~ "server" ]];then
echo "doing something here for server"
else
echo "don't know what to do for this box"
exit 1
fi
Hope this helps
Alvaro.
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
>
https://www.hashicorp.com/community-guidelines.html. Behavior in violation
> of those guidelines may result in your removal from this mailing list.
>
> GitHub Issues:
https://github.com/mitchellh/vagrant/issues
> IRC: #vagrant on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
vagrant-up+...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/vagrant-up/ac0900cc-c430-4796-827c-c71a5104c38b%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.