Skip to content

Instantly share code, notes, and snippets.

@DracoBlue
Last active December 23, 2015 17:19
Show Gist options
  • Save DracoBlue/6668451 to your computer and use it in GitHub Desktop.
Save DracoBlue/6668451 to your computer and use it in GitHub Desktop.
A way to require specific versions for puppet modules in Vagrantfile.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
PUPPET_MODULE_INSTALL_STRING = "if [ ! -d \"/etc/puppet/modules/%{module_name}-%{version}\" ];
then
rm -rf /etc/puppet/modules/%{module_name} &&
puppet module install %{forge_user}/%{module_name} --version %{version} &&
mv /etc/puppet/modules/%{module_name} /etc/puppet/modules/%{module_name}-%{version}
fi;
if [ ! -L \"/etc/puppet/modules/%{module_name}\" ];
then
ln -s /etc/puppet/modules/%{module_name}-%{version} /etc/puppet/modules/%{module_name}
fi;"
PUPPET_GIT_MODULE_INSTALL_STRING = "if [ ! -d \"/etc/puppet/modules/%{module_name}\" ];
then
git clone %{url} /etc/puppet/modules/%{module_name}
fi;
cd /etc/puppet/modules/%{module_name} && git pull origin master
"
config.vm.provision :shell do |shell|
shell.inline = "test `find /var/cache/apt/pkgcache.bin -cmin +60` && apt-get update --fix-missing;" +
"if [ ! -d \"/etc/puppet/modules\" ]; then mkdir -p /etc/puppet/modules; fi;" +
"if [ ! -f \"/usr/bin/git\" ]; then apt-get install git -y; fi;" +
PUPPET_MODULE_INSTALL_STRING % { :forge_user => 'puppetlabs', :module_name => 'stdlib', :version => '4.1.0' } +
PUPPET_MODULE_INSTALL_STRING % { :forge_user => 'puppetlabs', :module_name => 'apt', :version => '1.2.0' } +
PUPPET_MODULE_INSTALL_STRING % { :forge_user => 'jfryman', :module_name => 'nginx', :version => '0.0.5' } +
PUPPET_GIT_MODULE_INSTALL_STRING % { :url => 'https://github.com/jfryman/puppet-nginx.git', :module_name => 'nginx' }
end
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "manifests"
puppet.manifest_file = "init.pp"
puppet.options = "--verbose --debug"
puppet.module_path = "modules"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment