vagrant: script to upgrade chef in advance
This commit is contained in:
parent
02290fec39
commit
290d65c049
12
Vagrantfile
vendored
12
Vagrantfile
vendored
@ -42,7 +42,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
boxes.each do |box|
|
||||
config.vm.define box[:name] do |node|
|
||||
node.vm.provider :virtualbox do |vb|
|
||||
vb.gui = true
|
||||
# access via tty => user: vagrant, password: vagrant
|
||||
#vb.gui = true
|
||||
|
||||
# 1. adapter: NAT to allow vagrant setup the machine
|
||||
# 2. adapter: for internal network between nodes
|
||||
vb.customize ["modifyvm", :id,
|
||||
@ -56,6 +58,14 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
|
||||
node.vm.hostname = box[:name]
|
||||
|
||||
# Update Chef in VM to specific version before running chef provisioner
|
||||
config.vm.provision :shell do |shell|
|
||||
shell.path = "script/upgrade_chef.sh"
|
||||
# target version
|
||||
shell.args = "11.8.2"
|
||||
end
|
||||
config.vm.provision(:shell){ |shell| shell.path = "script/fix_stdin_error.sh" }
|
||||
|
||||
config.vm.provision :chef_solo do |chef|
|
||||
chef_default.call(chef)
|
||||
chef.add_role box[:role].to_s
|
||||
|
10
script/fix_stdin_error.sh
Normal file
10
script/fix_stdin_error.sh
Normal file
@ -0,0 +1,10 @@
|
||||
# If last line is `mesg n`, replace with conditional.
|
||||
if [ "`tail -1 /root/.profile`" = "mesg n" ]; then
|
||||
echo 'Patching basebox to prevent future `stdin: is not a tty` errors...'
|
||||
sed -i '$d' /root/.profile
|
||||
cat << 'EOH' >> /root/.profile
|
||||
if `tty -s`; then
|
||||
mesg n
|
||||
fi
|
||||
EOH
|
||||
fi
|
8
script/upgrade_chef.sh
Normal file
8
script/upgrade_chef.sh
Normal file
@ -0,0 +1,8 @@
|
||||
gem=/opt/chef/embedded/bin/gem
|
||||
chef=/opt/chef/bin/chef-client
|
||||
|
||||
if [ "`$chef -v | awk '{print $NF}'`" != "$1" ]; then
|
||||
echo "Upgrading Chef to $1...";
|
||||
$gem uninstall chef --all --ignore-dependencies --executables
|
||||
$gem install chef -v $1 --no-rdoc --no-ri
|
||||
fi
|
Loading…
Reference in New Issue
Block a user