robrich
robrich

Reputation: 13205

Vagrant provision after all machines up

Is there a way to flag a provision step as "after all nodes are up"?

I have a multi-machine vagrant file like so:

Vagrant.configure("2") do |config|
  config.vm.box = "generic/ubuntu1904"

  # share current folder so scripts are available
  config.vm.synced_folder ".", "/vagrant", disabled: false

  config.vm.define "main", primary: true do |main|
    main.vm.network :private_network, ip: "10.10.10.11"
    main.vm.hostname = "main"
    main.vm.provision "shell", path: "provision.sh"
  end

  config.vm.define "replica" do |replica|
    replica.vm.network :private_network, ip: "10.10.10.12"
    replica.vm.hostname = "replica"
  end
  
end

I need to provision on the main node, but I need to provision after both nodes are running.

What I see is that main machine boots and provision.sh runs then replica boots.

Is there a way to flag a provision step as "after all nodes are up"?

Upvotes: 1

Views: 440

Answers (1)

robrich
robrich

Reputation: 13205

This is hardly a good answer, but I found that reordering the machines such that the main machine was last in the list ensured it was provisioned last, and therefore "after all nodes were up" accidentally happened as soon as it was ready.

Upvotes: 3

Related Questions