Vagrant与配置者一起开始2 vm

时间:2014-11-25 17:14:29

标签: vagrant vagrantfile

您如何配置两个Vagrant VM,每个VM都有自己的配置文件?

例如,我想使用sensu-server木偶清单启动sensu-server.pp vm,但sensu-client vm带有sensu-client.pp木偶清单

#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

1 个答案:

答案 0 :(得分:1)

这是我能够用来配置vms的语法。

首先为sensu-server vm配置了一个shell配置器,然后是3个puppet manifest配置器。 sensu-client有一个shell,然后是一个木偶供应者。

  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
相关问题