Skip to content

Instantly share code, notes, and snippets.

@garthk
Last active December 12, 2015 01:08
Show Gist options
  • Save garthk/4688847 to your computer and use it in GitHub Desktop.
Save garthk/4688847 to your computer and use it in GitHub Desktop.
Vagrant trick: upgrade Puppet, update apt-get, and install Puppet modules before the Puppet provisioner runs.
# Manifest to install Puppet modules for Vagrant.
$vpup = '/opt/vagrant_ruby/bin/puppet'
$vmods = '/tmp/vagrant-puppet/modules'
define vpupmod() {
$modulename = inline_template('<%= name.split("/")[1] %>')
exec { "install module ${name}":
command => "${vpup} module install ${name} --modulepath ${vmods}",
creates => "${vmods}/${modulename}",
}
}
vpupmod { ['cprice404/inifile', 'puppetlabs/stdlib']: }
MANIFESTS = [
'vagrant-prereq.pp', # prerequisites, e.g. other Puppet modules
'vagrant.pp' # the Logstash configuration we're testing
]
# Run the Puppet provisioner for each manifest
for manifest in MANIFESTS
ls.vm.provision :puppet do |puppet|
puppet.manifests_path = "tests"
puppet.manifest_file = manifest
puppet.options = ["--modulepath", "/tmp/vagrant-puppet/modules"]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment