Last Updated: September 09, 2019
·
2.258K
· spanneberg

Automatically update Puppet in your Vagrant precise64 box

I'm a big fan of Vagrant (and Puppet) and often use it to craft together test environments and test Puppet manifests and modules that are used elsewhere later. Often, I use the precise64 box as a starting point, but this has still Puppet 2.7 packaged in it. So I came with this little script (bootstrap-puppet.sh) to update Puppet on 'vagrant up' if applicable:

#!/bin/bash

if [ ! -e /tmp/puppet-updated ]; then
  wget -O /tmp/puppetlabs-release-precise.deb http://apt.puppetlabs.com/puppetlabs-release-precise.deb
  dpkg -i /tmp/puppetlabs-release-precise.deb
  apt-get update
  apt-get --assume-yes install puppet
  touch /tmp/puppet-updated
fi

Now this can simply be included in your Vagrantfile with a shell provisioner before (!) your Puppet provisioner, and if Puppet is not up-to-date yet, it'll be updated:

config.vm.provision :shell, :path => "scripts/bootstrap_puppet.sh"

If you're using different boxes, look at http://docs.puppetlabs.com/guides/puppetlabs_package_repositories.html for adjusting the script to fit your box' OS.

1 Response
Add your response

That temp file (/tmp/puppet-updated) gets destroyed anything the machine is restarted. Best to put that marker file elsewhere.

over 1 year ago ·