0

In our current scenario we have a Vagrantfile that creates two machines - app1 and app2. I then have a puppet provisioning set up that installs a number of modules (all of our application components). The way that our applications work requires that both machines are up prior to any provisioning occurring.

The way we see our configuration behaving now is that app1 is brought up and then provisioned, then app2 is brought up and then provisioned. This causes our application to be unable to connect because it can't make connections with the appropriate services on the other server that has not yet been brought up.

Is there anyway to get our desired configuration where app1 and app2 are brought up and then provisioned? Below is our current Vagrantfile for reference

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
  config.ssh.insert_key = false

  config.vm.define "app1" do |app1|
        app1.vm.box = "centos_base"
        app1.vm.hostname = "app1.vagrant.test"
        app1.vm.network "private_network", ip: "192.168.10.10"
        app1.vm.network "forwarded_port", guest: 8080, host: 8000
  end

  config.vm.define "app2" do |app2|
        app2.vm.box = "centos_base"
        app2.vm.hostname = "app2.vagrant.test"
        app2.vm.network "private_network", ip: "192.168.10.11"
        app2.vm.network "forwarded_port", guest:8080, host: 8001
  end

  config.vm.provision "puppet" do |puppet|
        puppet.module_path = "modules"
        puppet.manifests_path = "manifests"
        puppet.manifest_file = "default.pp"
  end
end
Ze_Gitan
  • 194
  • 7

1 Answers1

0

I dont think you can do that directly from vagrant (I checked and tested with vagrant plugin but even triggers are executed after each instance command so it cannot work for you)

one thing you can do is to add a 3rd machine that will run the provisioning on the other. so you will run the provisioning on the 3rd machine only and the script will actually be to connect and execute the installation steps on the 2 machines. If you dont want the 3rd machine you can make all the provisioning on the 2nd machine and for the 1st machine it connects to the 1st one and run the puppet commands.

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139