Open drnic opened 12 years ago
From http://vagrantup.com/v1/docs/provisioners/shell.html
To configure and run this provisioner, the following would be added to the Vagrantfile:
Vagrant::Config.run do |config|
config.vm.provision :shell, :path => "test.sh"
end
Working on an example script at the moment.
Something like:
#!/usr/bin/env bash
set -e # exit immediately if a simple command exits with a non-zero status
set -u # report the usage of uninitialized variables
set +x
if [[ ! -f /var/vcap/install_dependencies_complete ]]
then
echo Installing dependencies for bosh-solo
sudo apt-get install curl git-core -y
if [[ ! -x /opt/sm/bin/sm ]]
then
if [[ ! -f /tmp/smf.sh ]]
then
curl -s -L https://get.smf.sh -o /tmp/smf.sh
fi
sudo chmod +x /tmp/smf.sh
sudo sh /tmp/smf.sh
fi
sudo /opt/sm/bin/sm ext install bosh-solo git://github.com/drnic/bosh-solo.git
sudo /opt/sm/bin/sm bosh-solo install_dependencies
sudo /usr/local/rvm/bin/rvm 1.9.3 --default
sudo mkdir -p /var/vcap
sudo touch /var/vcap/install_dependencies_complete
fi
# TODO run: sm bosh-solo update examples/dev-solo.yml or rel.yml
And Vagrantfile changed to:
Vagrant::Config.run do |config|
config.vm.box = "lucid64"
config.vm.box_url = "http://files.vagrantup.com/lucid64.box"
if local_bosh_src = ENV['BOSH_SRC']
config.vm.share_folder "bosh-src", "/bosh", local_bosh_src
end
config.vm.provision :shell, :path => "setup.sh"
if ENV['MULTIVM']
multivm_total = ENV['MULTIVM'].to_i
multivm_total = 4 if multivm_total < 4
# create VMs with internal IPs:
# - 192.168.11
# - 192.168.12
# - 192.168.13
# - 192.168.14
1.upto(4) do |n|
config.vm.define "rel#{n}".to_sym do |riak_config|
riak_config.vm.network :hostonly, "192.168.10.1#{n}"
end
end
end
end
This script should work nicely with pre-baked boxes that already have this all installed (see #5)
The
Vagrant.init.sh
is run via a shell provisioner in the Vagrantfile, to install SM, install bosh-solo, install_dependencies, set ruby 1.9.3 as default