ruby - Vagrant: different provisioner for different machines -
i'm trying have vagrant configuration run different shell script each machine in multi-machine environment.
i have definition smartos 1 centos, want run different shell provider configuration each, before running same chef-solo provider configuration on both.
#!/usr/bin/env ruby # vagrantfile api/syntax version. don't touch unless know you're doing! vagrantfile_api_version = "2" $smartos_script = <<-shell echo "http://10.40.95.5" > /opt/local/etc/pkgin/repositories.conf rm -rf /var/db/pkgin && pkgin -y update shell $centos_script = <<-shell touch /opt/my_file shell vagrant.configure(vagrantfile_api_version) |config| config.berkshelf.enabled = true config.ssh.forward_agent = true config.vm.define :smartos |smartos| smartos.vm.box = "smartos" smartos.vm.box_url = 'http://dlc-int.openindiana.org/aszeszo/vagrant/smartos-base1310-64-virtualbox-20130806.box' smartos.vm.guest = :solaris config.vm.provision :shell |shell| shell.inline = $smartos_script end end config.vm.define :centos |centos| centos.vm.box = "centos" centos.vm.box_url = 'http://dlc-int.openindiana.org/aszeszo/vagrant/smartos-base1310-64-virtualbox-20130806.box' config.vm.provision :shell |shell| shell.inline = $centos_script end end config.vm.provision :chef_solo |chef| chef.add_recipe 'test' end end
i have tried using smartos.vm.provision
instead of config, have seen no difference.
does have idea how can this?
you on right track
i have tried using smartos.vm.provision instead of config
try simple vagrantfile out
$smartos_script = <<-shell touch /opt/foo shell $centos_script = <<-shell touch /opt/bar shell # vagrantfile api/syntax version. don't touch unless know you're doing! vagrantfile_api_version = "2" vagrant.configure(vagrantfile_api_version) |config| config.vm.define :smartos |smartos| smartos.vm.box = "smartos" smartos.vm.box_url = 'http://dlc-int.openindiana.org/aszeszo/vagrant/smartos-base1310-64-virtualbox-20130806.box' smartos.vm.provision :shell |shell| shell.inline = $smartos_script end end config.vm.define :centos |centos| centos.vm.box = "centos" centos.vm.box_url = 'http://dlc-int.openindiana.org/aszeszo/vagrant/smartos-base1310-64-virtualbox-20130806.box' centos.vm.provision :shell |shell| shell.inline = $centos_script end end end
when run "vagrant up" , ssh machine, e.g. vagrant ssh smartos , cd /opt see file "foo" has been created. , when ssh cents machine see file "bar" created.
Comments
Post a Comment