I\'m using puppet to provision a vagrant (ubuntu based) virtual machine. In my script I need to:
sudo apt-get build-dep python-lxml
I know
Inspired by wtanaka.com's answer, I implemented a solution like below which I think is much more readable.
1) create a new ruby file called 'puppet_deps.rb' under the same folder as Vagrantfile with code like below:
def install_dep(name, version, install_dir = nil)
install_dir ||= '/etc/puppet/modules'
"mkdir -p #{install_dir} && (puppet module list | grep #{name}) || puppet module install -v #{version} #{name}"
end
2) In your Vagrantfile, you can load this ruby file and use it to specify the puppet dependency:
# on top of your Vagrantfile
require './puppet_deps'
...
...
# in your vm definition, use a shell provisioning this:
config.vm.provision :shell, :inline => install_dep('puppetlabs-firewall', '1.1.3')
config.vm.provision :shell, :inline => install_dep('puppetlabs-stdlib', '4.3.2')