spuder
spuder

Reputation: 18397

Vagrant start 2 vm's with provisioners

How would you configure two Vagrant VM's, each with their own provisioner file?

For example, I want to start the sensu-server vm with the sensu-server.pp puppet manifest, but the sensu-client vm with the sensu-client.pp puppet manifest

#Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.synced_folder ".", "/vagrant"


  config.vm.define "sensu-server", autostart: true do |server|
    server.vm.box = "ubuntu-12_04-x64-virtualbox_4_2_10-plain"
    server.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210.box"
    server.vm.hostname = 'sensu-server'
    config.vm.provision "puppet" do |puppet|
      puppet.manifests_path = ["vm","/vagrant/tests"]
      puppet.manifests_file = "sensu-server.pp"
    end
  end

  config.vm.define "sensu-client", autostart: true do |client|
    client.vm.box = "ubuntu-12_04-x64-virtualbox_4_2_10-plain"
    client.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210.box"
    client.vm.hostname = 'sensu-client'
    config.vm.provision "puppet" do |puppet|
      puppet.manifests_path = ["vm","/vagrant/tests"]
      puppet.manifests_file = "sensu-client.pp"
    end
  end

end

Upvotes: 1

Views: 227

Answers (1)

spuder
spuder

Reputation: 18397

This is the syntax that I was able to use to provision the vms.

The sensu-server vm is first provisioned with a shell provisioner, then 3 puppet manifest provisioners. The sensu-client has a shell and then a puppet provisioner.

  config.vm.define "sensu-server", primary: true, autostart: true do |server|
    server.vm.box = "ubuntu-12_04-x64-virtualbox_4_2_10-plain"
    server.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210.box"
    server.vm.hostname = 'sensu-server'
    server.vm.provision :shell, :path => "tests/provision_server.sh"
    server.vm.provision :puppet, :manifests_path => ["vm","/vagrant/tests"], :manifest_file => "rabbitmq.pp"
    server.vm.provision :puppet, :manifests_path => ["vm","/vagrant/tests"], :manifest_file => "sensu-server.pp"
    server.vm.provision :puppet, :manifests_path => ["vm","/vagrant/tests"], :manifest_file => "uchiwa.pp"
  end

  config.vm.define "sensu-client", autostart: true do |client|
    client.vm.box = "ubuntu-12_04-x64-virtualbox_4_2_10-plain"
    client.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210.box"
    client.vm.hostname = 'sensu-client'
    client.vm.provision :shell, :path => "tests/provision_client.sh"
    client.vm.provision :puppet, :manifests_path => ["vm","/vagrant/tests"], :manifest_file => "sensu-client.pp"
  end

Upvotes: 2

Related Questions