Using Vagrant for Developing and Testing Puppet Modules
1. Using Vagrant for developing and
testing puppet modules
onsdag den 18. april 12
2. Thanks to
• Mitchell Hashimoto & John Bender
• The creators of Vagrant
• Kris Buytaert
• Parts of this presentation is based on his
excellent talk at Puppet Camp Edinburg
onsdag den 18. april 12
3. Vagrant
"A person without a settled home or regular home who
wanders from place to place and lives by begging."
onsdag den 18. april 12
4. Vagrant tool
• "Create and configure lightweight,
reproducible, and portable development
environments" - vagrantup.com
• A light tool that using virtual box makes it
very easy to start from an empty OS and
apply a puppet manifest to it
onsdag den 18. april 12
5. Install and setup
• Requires: Ruby, Virtualbox
$ gem install vagrant
$ vagrant box add base http://.../
$ vagrant init
$ vagrant up
onsdag den 18. april 12
6. Connect and destroy
$ vagrant ssh
vagrant@vagrant-ubuntu-oneiric:~$
$ vagrant destroy
[default] Destroying VM and
associated drives...
onsdag den 18. april 12
7. Using puppet
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "./"
puppet.manifest_file = "vagrant.pp"
puppet.module_path = "../"
end
onsdag den 18. april 12
8. Using puppet
node default {
package {
"ruby-json":
ensure => 'installed',
}
}
onsdag den 18. april 12
9. Testing our manifest
$ vagrant up
[default] VM booted and ready for use!
[default] Mounting shared folders...
[default] -- v-root: /vagrant
[default] -- manifests: /tmp/vagrant-puppet/manifests
[default] -- v-pp-m0: /tmp/vagrant-puppet/modules-0
[default] Running provisioner: Vagrant::Provisioners::Puppet...
[default] Running Puppet with /tmp/vagrant-puppet/manifests/vagrant.pp...
stdin: is not a tty
notice: /Stage[main]//Node[default]/Package[ruby-json]/ensure: ensure changed
'purged' to 'present'
notice: Finished catalog run in 6.44 seconds
onsdag den 18. april 12
10. Testing our manifest
• Manifest and module paths mounted from
host to VM, any local change is immediately
on the VM
• Run puppet again, without restarting the VM
$ vagrant provision
onsdag den 18. april 12
11. Benefits
• Use same puppet files to generate developer
environments
• Create a production-like vm in minutes
• Can be shipped both internally and
externally.
onsdag den 18. april 12
12. Questions?
• Twitter: @oellegaard
• GitHub: KristianOellegaard
• Email: kristian@oellegaard.com
onsdag den 18. april 12