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.

On Sat, Oct 24, 2015 at 11:44 AM, Joaquin Menchaca <[email protected]> wrote:
> Is there any way to apply a provisioning script after all systems are fully
> up and running in a multi-machine setup.  I have scripts that would need to
> run, but have to fetch information from other systems that should be online
> before the provisioning script is run.  I would like to use the built-in
> provisioner.
>
> Thus in snippet below, wonder if there is a way to run the provisioning
> after all systems are up?
>
> Vagrant.configure("2") do |config|
>
>   # 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
>
>   # 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
>
> end
>
> --
> 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 [email protected].
> 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.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vagrant-up/CAHqq0ewSBi-48ztmos2sLb-tFMtoEHZ5LQ_azMCT3jm1w3__5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to