Site: US UK AU |
Nexcess Blog

Puppet – Use It For More Than Just Servers

May 29, 2012 0 Comments RSS Feed

Puppet - Use It For More Than Just Servers

I use virtual machines at work and home to test and experiment with various things. After setting up a new virtual machine, I install some of the programs I use on a daily basis like emacs, gawk, ack, etc. But there are other programs I use less frequently that I always forget to install. It is quite annoying when you try to run mtr, nc, or nmap to debug a problem, only to discover they don’t exist since they were never installed. It’s easy to install the missing packages, but annoying to have to do it every time I set up a new virtual machine for the latest Fedora release.

With the last virtual server I did at home, Fedora 16, I stopped installing missing packages by hand and started writing a puppet manifest to install the packages I needed. If you’re not familiar with the puppet language, it is easy to get started with simple stuff like installing packages, it looks like this:

package { 'foobar':<br />
	ensure =&gt; 'installed'<br />

That’s it, puppet will figure out what distro and package provider (eg yum, aptitude) your distro has, then will install the packages using it. To apply your manifest, it is just `puppet apply foo.pp` where foo.pp is your filename.

Here’s a smaller version of the manifest I run after installing the latest fedora, I’ve included a service in there too.

package {['emacs-nox', 'mg', 'gawk', 'ncftp', 'wget', 'lynx', 'gcc-c++',  'aspell-en', 'enchant-aspell', 'ack', 'nmap', 'mtr', 'nc', 'ntp']:<br />
  ensure =&gt; 'present',<br />
<p>service {'ntpd':<br />
  ensure =&gt; 'running',<br />
  enable =&gt; true,<br />
  require =&gt; Package['ntp'],<br />

Now when Fedora 17 is released, I can just apply my manifest on my virtual machine and not worry about missing packages anymore!

Posted in: General