<?xml version="1.0"?>

<rss version="2.0">
  <channel>
    <title>Dean Wilson@UnixDaemon: In search of (a) life</title>
    <link>http://blog.unixdaemon.net/cgi-bin/blosxom.pl/tools/puppet/</link>
    <description>Tech rantings, reviews and other stuff that may not begin with r.</description>
    <language>en</language>
    <copyright>Copyright (c) 2010 Dean Wilson - Unixdaemon.net</copyright>

    <lastBuildDate>Thu, 11 Feb 2010 22:11:00 GMT</lastBuildDate>

    <item>
      <title>Simplifying File Permissions in Puppet Manifests</title>
      <link>http://blog.unixdaemon.net/cgi-bin/blosxom.pl/tools/puppet/simplifying_file_permissions_in_puppet_manifests.html</link>
      <description><![CDATA[
I've been a user of <a href="">Puppet</a> for about three years now and
while on a recent dig in to some of my older classes it was a little
embarrassing to see lots of file types used like this:</p>

<pre><code>
  file { "/srv/whi/maps":
    ensure => present,
    source => "puppet://$servername/whi/maps.conf"
    owner  => whi,
    group  => whi,
    mode   => 644
  }
  file { "/srv/whi/elocs":
    ensure => present,
    source => "puppet://$servername/whi/eloc.conf"
    owner  => whi,
    group  => whi,
    mode   => 644
  }
</code></pre>

<p>Luckily as we get more experienced with a tool we can often go back and
improve on the first steps. By using an explicit <code>File { settings
}</code> inside a class you can assign a sensible set of defaults to all
the instances of the same type that lack overriding settings. So we can
shorten the previous example to -

<pre><code>
File {
  owner => whi,
  group => whi,
  mode  => 644
}

file { "/srv/whi/maps":
  ensure => present,
  source => "puppet://$servername/whi/maps.conf"
}

file { "/srv/whi/elocs":
  ensure => present,
  source => "puppet://$servername/whi/eloc.conf"
}
</code></pre>

<p>While this isn't a huge win in raw characters typed (although in longer
manifests they start to mount up) it does move all the common settings in
to a single location (keeping us clear of <acronym title="Don't Repeat
Yourself">DRY</acronym> violations) and it leaves only the differences
between file type definitions.</p>

<p>You can also apply those kind of settings (such as <code>Exec { path =>
"path:list" }</code> at the server level by including them in a top level
file and then overriding them as needed in each module. If you do this then
you need to be aware that any declared type that doesn't override it gets
the global setting, which can lead to the odd action from afar head
scratching.</p><p class="posted">Like this post? - <a href="http://www.digg.com/submit?url=http://blog.unixdaemon.net/cgi-bin/blosxom.pl/tools/puppet/simplifying_file_permissions_in_puppet_manifests.rss20&amp;title=Simplifying%20File%20Permissions%20in%20Puppet%20Manifests&amp;phase=3">Digg Me!</a> | <a href="http://del.icio.us/post?url=http://blog.unixdaemon.net/cgi-bin/blosxom.pl/tools/puppet/simplifying_file_permissions_in_puppet_manifests.rss20&amp;title=Simplifying%20File%20Permissions%20in%20Puppet%20Manifests">Add to del.icio.us!</a> | <a href="http://reddit.com/submit?url=http://blog.unixdaemon.net/cgi-bin/blosxom.pl/tools/puppet/simplifying_file_permissions_in_puppet_manifests.rss20&amp;title=Simplifying%20File%20Permissions%20in%20Puppet%20Manifests">reddit this!</a>]]></description>
      <author>Dean Wilson &lt;dean.wilson@gmail.com&gt;</author>
      <category>/tools/puppet</category>
      <pubDate>Wed, 23 Sep 2009 22:16:00 GMT</pubDate>
      <guid isPermaLink="false">simplifying_file_permissions_in_puppet_manifests</guid>
    </item>

    <item>
      <title>Stand Alone Puppet</title>
      <link>http://blog.unixdaemon.net/cgi-bin/blosxom.pl/tools/puppet/stand_alone_puppet.html</link>
      <description><![CDATA[
While <a href="">Puppet</a> can be used to manage large, complex
environments it's also a useful tool at the lower end of the spectrum.
Using just the <code>puppet</code> executable and a small inline class or
two you can write very useful manifests in only a handful of lines.</p>

<pre>
<code>
class build-host {
  package { "build-essential": ensure => installed }
  package { "subversion":      ensure => installed }

  file { "/home/dwilson/repos/":
    ensure => directory,
    owner  => dwilson,
    group  => dwilson,
  }
}

node default {
  include build-host
}
</code>
</pre>

<p>To invoke the class you just run <code>puppet -v build-host.pp</code>.
It's also worth pointing out the node name of default. This saves you
manually changing the manifest whenever you move to another machine.
While it wouldn't be hard to replace the above example with a shell
script, by using puppet you can easily access the built-in abstractions
(which package manager to use, how should you add users) and remove a lot
of scaffolding code. And then when you're done you can promote the class to
your managed infrastructure.</p>

<p>I've used this to bootstrap provisioning servers (why should the
provisioning host be the only machine that wasn't provisioned?), test
small but annoying new classes on scratch servers and I'm
currently working on integrating it with a small subversion backup testing
project in my spare time at work (so very slowly).</p><p class="posted">Like this post? - <a href="http://www.digg.com/submit?url=http://blog.unixdaemon.net/cgi-bin/blosxom.pl/tools/puppet/stand_alone_puppet.rss20&amp;title=Stand%20Alone%20Puppet&amp;phase=3">Digg Me!</a> | <a href="http://del.icio.us/post?url=http://blog.unixdaemon.net/cgi-bin/blosxom.pl/tools/puppet/stand_alone_puppet.rss20&amp;title=Stand%20Alone%20Puppet">Add to del.icio.us!</a> | <a href="http://reddit.com/submit?url=http://blog.unixdaemon.net/cgi-bin/blosxom.pl/tools/puppet/stand_alone_puppet.rss20&amp;title=Stand%20Alone%20Puppet">reddit this!</a>]]></description>
      <author>Dean Wilson &lt;dean.wilson@gmail.com&gt;</author>
      <category>/tools/puppet</category>
      <pubDate>Thu, 17 Sep 2009 21:33:00 GMT</pubDate>
      <guid isPermaLink="false">stand_alone_puppet</guid>
    </item>


  </channel>
</rss>
