<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>www.devco.net</title>
	<atom:link href="http://www.devco.net/feed" rel="self" type="application/rss+xml" />
	<link>http://www.devco.net</link>
	<description>by r.i.pienaar</description>
	<lastBuildDate>Fri, 12 Mar 2010 11:59:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Puppet Concat 20100312</title>
		<link>http://www.devco.net/archives/2010/03/12/puppet_concat_20100312.php</link>
		<comments>http://www.devco.net/archives/2010/03/12/puppet_concat_20100312.php#comments</comments>
		<pubDate>Fri, 12 Mar 2010 11:59:34 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[puppet]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1335</guid>
		<description><![CDATA[I am pleased to announce the next version of my Puppet Concat script, we now have 0.24.8 and newer support and a few smaller bits mentioned below.
For background of what this is about please see my earlier post: Building files from fragments with Puppet
New in this release
Paul Elliot sent in most of the patches that [...]]]></description>
			<content:encoded><![CDATA[<p>I am pleased to announce the next version of my Puppet Concat script, we now have 0.24.8 and newer support and a few smaller bits mentioned below.</p>
<p>For background of what this is about please see my earlier post: <a href="http://www.devco.net/archives/2010/02/19/building_files_from_fragments_with_puppet.php">Building files from fragments with Puppet</a></p>
<h2>New in this release</h2>
<p>Paul Elliot sent in most of the patches that enabled this release, lots of thanks Paul!</p>
<ul>
<li>0.24.8 and newer is supported</li>
<li>You can now prepend warnings to generated files as a shell style comment using the <em>warn</em> property</li>
<li>You can enable the ability to create empty concat files using the <em>force</em> property
<li>You can configure the location of your sort binary in <em>setup.pp</em>
</ul>
<p>The code should auto configure for 0.24.8 use, if it does not work please see <em>setup.pp</em>.</p>
<p>You can grab the code <a href="http://www.devco.net/code/concat-20100312.tgz">here</a>.</p>
<h2>Known issues</h2>
<p>As with my earlier attempts at making a concat tool for 0.24.x this version when used on 0.24 will raise some false notifies.  Basically the method we use to clear the concat store of unmanaged files has a side effect and on the next run you will get an unneeded notify.  Puppets behavior has improved in 0.25 so it works as expected there, for 0.24 though there is no known work around.</p>
<p>You cannot change the owner of a file, I know how to work around this issue and will have something in the next release.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/03/12/puppet_concat_20100312.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Puppet localconfig parser &#8211; 20100303</title>
		<link>http://www.devco.net/archives/2010/03/03/puppet_localconfig_parser_-_20100303.php</link>
		<comments>http://www.devco.net/archives/2010/03/03/puppet_localconfig_parser_-_20100303.php#comments</comments>
		<pubDate>Wed, 03 Mar 2010 18:36:02 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1332</guid>
		<description><![CDATA[I've had some good feedback on my previous post about the puppet localconfig parser, have implemented the requested features so here's a new version.
First the ability to limit what resources are being printed:


# parselocalconfig.rb --limit package
Classes included on this node:
        fqdn
        [...]]]></description>
			<content:encoded><![CDATA[<p>I've had some good feedback on my <a href="http://www.devco.net/archives/2010/02/26/what_does_puppet_manage_on_a_node-2.php">previous post</a> about the puppet localconfig parser, have implemented the requested features so here's a new version.</p>
<p>First the ability to limit what resources are being printed:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># parselocalconfig.rb --limit package
Classes included on this node:
        fqdn
        common::linux
&nbsp;
Resources managed by puppet on this node:
        package{redhat-lsb: }
                defined in common/modules/puppet/manifests/init.pp:15</pre></div></div>

</blockquote>
<p>You should only see package resources.  You can also disable the classes list using <em>--no-classes</em> and on 0.25.x disable the tags list with <em>--no-tags</em>.  </p>
<p>I've improved the detection of where to find the yaml file for 0.25 nodes and added an option <em>--config</em> if your config file is not in the usual place.</p>
<p>You can get the latest version <a href="http://www.devco.net/code/parselocalconfig.rb">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/03/03/puppet_localconfig_parser_-_20100303.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What does Puppet manage on a node?</title>
		<link>http://www.devco.net/archives/2010/02/26/what_does_puppet_manage_on_a_node-2.php</link>
		<comments>http://www.devco.net/archives/2010/02/26/what_does_puppet_manage_on_a_node-2.php#comments</comments>
		<pubDate>Fri, 26 Feb 2010 21:25:42 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1324</guid>
		<description><![CDATA[Last year I wrote a tool to parse the localconfig.yaml from Puppet 0.24 and display a list of resources and classes.  This script failed when 0.25 came out, I've updated it for 0.25 support.
The yaml cache has some added features in 0.25 so now I can also show the list of tags on a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.devco.net/archives/2009/07/30/what_does_puppet_manage_on_a_node.php">Last year I wrote</a> a tool to parse the <em>localconfig.yaml</em> from Puppet 0.24 and display a list of resources and classes.  This script failed when 0.25 came out, I've updated it for 0.25 support.</p>
<p>The yaml cache has some added features in 0.25 so now I can also show the list of tags on a node, output would be:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># parselocalconfig.rb /var/lib/puppet/client_yaml/catalog/fqdn.yaml
Classes included on this node:
        fqdn
        common::linux
        &lt;snip&gt;
&nbsp;
Tags for this node:
        fqdn
        common::linux
        &lt;snip&gt;
&nbsp;
Resources managed by puppet on this node:
        yumrepo{centos-base: }
                defined in common/modules/yum/manifests/init.pp:24
&nbsp;
        file{/root/.ssh: }
                defined in common/modules/users/manifests/root.pp:20
&nbsp;
        &lt;snip&gt;</pre></div></div>

</blockquote>
<p>You can get the script that supports both 0.24 and 0.25 <a href="http://www.devco.net/code/parselocalconfig.rb">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/02/26/what_does_puppet_manage_on_a_node-2.php/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>London Devops Night Venue Sponsor</title>
		<link>http://www.devco.net/archives/2010/02/23/london_devops_night_venue_sponsor.php</link>
		<comments>http://www.devco.net/archives/2010/02/23/london_devops_night_venue_sponsor.php#comments</comments>
		<pubDate>Tue, 23 Feb 2010 18:16:50 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[ldndevops]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1318</guid>
		<description><![CDATA[Tomorrow is our first public London DevOps meetup, it's looking like there will be a lot of people given the activity on Twitter, hopefully it will be a great night.
In the mean time The Guardian has offered us a regular venue at their big auditorium where the London Scale Camp was held.  This is [...]]]></description>
			<content:encoded><![CDATA[<p>Tomorrow is our first public London DevOps meetup, it's looking like there will be a lot of people given the activity on Twitter, hopefully it will be a great night.</p>
<p>In the mean time <a href="http://www.guardian.co.uk/">The Guardian</a> has offered us a regular venue at their big auditorium where the London Scale Camp was held.  This is an excellent venue setup with projectors and everything.  We could get it every month but I figured we'll keep the talks bi-monthly and do drinks night or just something social on the other nights.  There are several pubs around the Guardian so we'll do drinks after the 1 or 2 talks a night.</p>
<p>The upcoming dates - excluding the pure pub nights are then:</p>
<p>02/03/2010 7pm – Agile Systems Administration at London Geek Nights – thanks to Thoughtworks<br />
28/04/2010 7pm – Topic TBA – thanks to The Guardian for the venue<br />
30/06/2010 7pm – Topic TBA – thanks to The Guardian for the venue<br />
27/10/2010 6pm – Topic TBA – thanks to The Guardian for the venue<br />
29/12/2010 6pm – Topic TBA – thanks to The Guardian for the venue</p>
<p>Put them in your calendars and again massive thanks to The Guardian for sponsoring us.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/02/23/london_devops_night_venue_sponsor.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building files from fragments with Puppet</title>
		<link>http://www.devco.net/archives/2010/02/19/building_files_from_fragments_with_puppet.php</link>
		<comments>http://www.devco.net/archives/2010/02/19/building_files_from_fragments_with_puppet.php#comments</comments>
		<pubDate>Fri, 19 Feb 2010 18:14:20 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[puppet]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1309</guid>
		<description><![CDATA[While building up complex configs with Puppet you often need to build up one file from many fragments.  This is useful for files like older sysctl.conf files and maybe named.conf files.  
The basic pattern is you want to manage a file, but want the contents to be very different from node to node. [...]]]></description>
			<content:encoded><![CDATA[<p>While building up complex configs with Puppet you often need to build up one file from many fragments.  This is useful for files like older <em>sysctl.conf</em> files and maybe <em>named.conf</em> files.  </p>
<p>The basic pattern is you want to manage a file, but want the contents to be very different from node to node.  A fragment based system lets you register different contents into a file on different nodes.  It's exactly like the <em>conf.d</em> directory you'd find in Apache but for daemons that does not support this construct on their own.</p>
<p>I've had an older version of this floating around but had to clean it up for a client today so thought I might as well do a proper job, release it and get some more eye balls on it.  This version is specific to Puppet 0.25.x, I will soon make a >= 0.24.8 version too since that is what my client is on.</p>
<p>An example says more than words, so lets create something to manage <em>sysctl.conf</em>:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="puppet" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Initial setup</span>
<span style="color:#0000FF; font-weight:bold;">class</span> sysctl <span style="color:#006600; font-weight:bold;">&#123;</span>
   <span style="color:#9966CC; font-weight:bold;">include</span> concat<span style="color:#0066ff; font-weight:bold;">::</span>setup
&nbsp;
   <span style="color:#CC00FF; font-weight:bold;">exec</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">&quot;reload-sysctl&quot;</span><span style="color:#006600; font-weight:bold;">:</span>
      <span style="color:#CC0066; font-weight:bold;">refreshonly</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>,
      <span style="color:#CC0066; font-weight:bold;">command</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/sbin/sysctl -p&quot;</span>
   <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
   concat<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">&quot;/etc/sysctl.conf&quot;</span><span style="color:#006600; font-weight:bold;">:</span>
      <span style="color:#CC0066; font-weight:bold;">notify</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#CC00FF; font-weight:bold;">Exec</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;reload-sysctl&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
   <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># use this to set values</span>
<span style="color:#0000FF; font-weight:bold;">define</span> sysctl<span style="color:#0066ff; font-weight:bold;">::</span>setting<span style="color:#006600; font-weight:bold;">&#40;</span>$value<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
   concat<span style="color:#0066ff; font-weight:bold;">::</span>fragment<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">&quot;sysctl_${name}&quot;</span><span style="color:#006600; font-weight:bold;">:</span> 
      <span style="color:#CC0066; font-weight:bold;">target</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/etc/sysctl.conf&quot;</span>,
      <span style="color:#CC0066; font-weight:bold;">content</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;${name} = ${value}<span style="color:#000099;">\n</span>&quot;</span>,
   <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

</blockquote>
<p>The above sets up a class that will create an empty <em>sysctl.conf</em> and provides an utility for setting individual values.  Whenever the <em>sysctl.conf</em> file gets changed the changes will be made live using the <em>refreshonly exec</em>.</p>
<p>Lets see how we might use it:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="puppet" style="font-family:monospace;"><span style="color:#0000FF; font-weight:bold;">node</span> <span style="color:#996600;">&quot;your.example.com&quot;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
   <span style="color:#9966CC; font-weight:bold;">include</span> sysctl
&nbsp;
   sysctl<span style="color:#0066ff; font-weight:bold;">::</span>setting<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">&quot;net.ipv4.ip_forward&quot;</span><span style="color:#006600; font-weight:bold;">:</span>
      <span style="color:#CC0066; font-weight:bold;">value</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">1</span>
   <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

</blockquote>
<p>You can see this looks and feels a lot like a native type but without a lot of the hassle it would take to write one, you can really get a lot of mileage out of this pattern.  The concat is clever enough to unregister the setting should you remove lines 4 to 6 in the above node block.</p>
<p>A cleaner approach would be to just make classes like <em>sysctl::ipv4_forward</em> that you can include on the nodes that need it.</p>
<p>You can grab the current code <a href="http://www.devco.net/code/concat-20100219.tgz">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/02/19/building_files_from_fragments_with_puppet.php/feed</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Custom deployer using MCollective</title>
		<link>http://www.devco.net/archives/2010/02/18/custom_deployer_using_mcollective.php</link>
		<comments>http://www.devco.net/archives/2010/02/18/custom_deployer_using_mcollective.php#comments</comments>
		<pubDate>Thu, 18 Feb 2010 17:39:35 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[mcollective]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1296</guid>
		<description><![CDATA[One of the goals of building the SimpleRPC framework and the overall speed of MCollective is to create interactive tools to manage your infrastructure in a way that it all just seems like a single point of entry with one machine.   I've blogged a bit about this before with how I manage Exim [...]]]></description>
			<content:encoded><![CDATA[<p>One of the goals of building the <a href="http://code.google.com/p/mcollective/wiki/SimpleRPCIntroduction">SimpleRPC framework</a> and the overall speed of <a href="http://code.google.com/p/mcollective/">MCollective</a> is to create interactive tools to manage your infrastructure in a way that it all just seems like a single point of entry with one machine.   I've blogged a bit about this before with <a href="http://www.devco.net/archives/2009/12/14/exim_mcollective_and_speed.php">how I manage Exim clusters</a>.</p>
<p>I've recently built a deployer for a client that does some very specific things with their FastCGI, packages and monitoring in a way that is safe for developers to use.  I've made a sanitized demo of it that you can see below.  It's sanitized in that the hostnames are replaced with hashes and some monitoring details removed but you'll get the idea.</p>
<p>As usual it's best to just <a href="http://www.youtube.com/watch?v=Fqt2SgnQn3k&#038;feature=player_embedded#">look at the video on youtube</a> in it's HD mode.</p>
<p><center><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/Fqt2SgnQn3k&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Fqt2SgnQn3k&#038;hl=en_US&#038;fs=1&#038;ap=%2526fmt%3D18" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object> </center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/02/18/custom_deployer_using_mcollective.php/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Few Rubyisms</title>
		<link>http://www.devco.net/archives/2010/02/17/few_rubyisms.php</link>
		<comments>http://www.devco.net/archives/2010/02/17/few_rubyisms.php#comments</comments>
		<pubDate>Wed, 17 Feb 2010 21:53:19 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1285</guid>
		<description><![CDATA[While looking at some bits of other peoples Ruby code I came across a few shortcuts and interesting structures worth mentioning.
Exception handling shortcut
First up a shortcut to catch exceptions thrown by a method:


def say_foo
   puts &#34;foo&#34; if doit
rescue Exception
   puts &#34;#fail&#34;
end


So since we didn't define doit this will raise an exception, [...]]]></description>
			<content:encoded><![CDATA[<p>While looking at some bits of other peoples Ruby code I came across a few shortcuts and interesting structures worth mentioning.</p>
<h1>Exception handling shortcut</h1>
<p>First up a shortcut to catch exceptions thrown by a method:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> say_foo
   <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;foo&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> doit
<span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">Exception</span>
   <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#fail&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

</blockquote>
<p>So since we didn't define <em>doit</em> this will raise an exception, which will be handled.  Nice shortcut to avoid an extra inner <em>begin / rescue</em> block.</p>
<h1>sprintf equivelant</h1>
<p>Ruby supports sprintf style string building in a handy little shortcut:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;%2.6f<span style="color:#000099;">\n</span>%d&quot;</span> <span style="color:#006600; font-weight:bold;">%</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span>, <span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span></pre></div></div>

</blockquote>
<p>This produces:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ ruby test.rb
<span style="color: #000000;">1.000000</span>
<span style="color: #000000;">1</span></pre></div></div>

</blockquote>
<h1>Get a value from a hash with default for non existing</h1>
<p>This is really nice, I've written way too many constructs like this:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">foo.<span style="color:#9966CC; font-weight:bold;">include</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:bar</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? bar = foo<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:bar</span><span style="color:#006600; font-weight:bold;">&#93;</span> : bar = <span style="color:#996600;">&quot;unknown&quot;</span></pre></div></div>

</blockquote>
<p>One option that I was told about was this:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">bar = foo<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:bar</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#996600;">&quot;unknown&quot;</span></pre></div></div>

</blockquote>
<p>But that does not work if you had <em>false</em> in the hash, or maybe even nil.</p>
<p>Turns out there's an awesome shortcut for this:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">bar = foo.<span style="color:#9900CC;">fetch</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:bar</span>, <span style="color:#996600;">&quot;unknown&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

</blockquote>
<h1>Reloading a class</h1>
<p>Sometimes you want to reload a class you previously loaded with <em>require</em>.  I have the need in my plugin manager for mcollective.  There's a simple fix by simply using Kernel#load to load the .rb file, each time you load it the file will be reloaded from disk.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">irb<span style="color:#006600; font-weight:bold;">&#40;</span>main<span style="color:#006600; font-weight:bold;">&#41;</span>:001:<span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#CC0066; font-weight:bold;">load</span> <span style="color:#996600;">&quot;test.rb&quot;</span>
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>
irb<span style="color:#006600; font-weight:bold;">&#40;</span>main<span style="color:#006600; font-weight:bold;">&#41;</span>:002:<span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&gt;</span> Foo.<span style="color:#9900CC;">doit</span>
foo
irb<span style="color:#006600; font-weight:bold;">&#40;</span>main<span style="color:#006600; font-weight:bold;">&#41;</span>:003:<span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">*</span> <span style="color:#CC0066; font-weight:bold;">load</span> <span style="color:#996600;">&quot;test.rb&quot;</span>
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>
irb<span style="color:#006600; font-weight:bold;">&#40;</span>main<span style="color:#006600; font-weight:bold;">&#41;</span>:004:<span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&gt;</span> Foo.<span style="color:#9900CC;">doit</span>
foo foo</pre></div></div>

</blockquote>
<p>In between lines 2 and 3 I edited the file <em>test.rb</em> and just reloaded it, the changes on disk reflected in the current session.  The main difference is that you need to supply the full file name and not just <em>test</em> like you would with <em>require</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/02/17/few_rubyisms.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>London DevOps</title>
		<link>http://www.devco.net/archives/2010/02/11/london_devops.php</link>
		<comments>http://www.devco.net/archives/2010/02/11/london_devops.php#comments</comments>
		<pubDate>Thu, 11 Feb 2010 22:24:37 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[ldndevops]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1277</guid>
		<description><![CDATA[Since DevOps Days last year a number of us have been meeting monthly, it was all a bit under the radar and not announced to the wider public.
The thinking was that we wanted to be sure we will do the meetings roughly monthly rather than start something with a lot of noise and then fizzle [...]]]></description>
			<content:encoded><![CDATA[<p>Since <a href="http://devopsdays.org/">DevOps Days</a> last year a number of us have been meeting monthly, it was all a bit under the radar and not announced to the wider public.</p>
<p>The thinking was that we wanted to be sure we will do the meetings roughly monthly rather than start something with a lot of noise and then fizzle out.</p>
<p>We've met 4 months in a row and we figured it's about time to throw open the doors.  We are therefore meeting on the 24th of February 2010 at <a href="http://www.priorybar.com/">The Priory Bar</a>, we'll aim to be there from 6 or 7pm on wards.</p>
<p>We're trying to create a community of like minded people in London - Sysadmins, Ops People, Developers, Puppet Users, Chef Users we do not discriminate.  As long as your interested in Agile Infrastructures or in bridging the gap between the Dev and Ops Silos or just want to hang out with a bunch of Systems guys who aren't stuck in the 1980s you're welcome to join us.  The basic format we're aiming for is to meet in a pub/restaurant for Lunch or Dinner one month and every second month to try and arrange some meeting with talks.</p>
<p>Our first actual meeting with talks will be in March at a venue provided by Thought Works so the meeting on the 24th is to discuss what we'll be up to there.  We'll also be very glad to hear from any companies who would like to offer us some space on a bi-monthly basis for our talks.</p>
<p>While on the subject I should mention an event that is coming up.  In March London hosts <a href="http://qconlondon.com/london-2010/tracks/show_track.jsp?trackOID=331">Q-Con</a> with a track specifically for DevOps and I will be there doing a talk as well as some of our other regular members.</p>
<p>Please help spread the word by tweeting with the <em>#ldndevops</em> hashtag.  We've created a site at <a href="http://londondevops.org/">http://londondevops.org/</a> that aggregates some of the blogs of people who we already know about in London who are operating in this space.  Please contact me here in comments or on Twitter <a href="http://twitter.com/ripienaar">@ripienaar</a> to get yourself added.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/02/11/london_devops.php/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding methods to a ruby class</title>
		<link>http://www.devco.net/archives/2010/02/05/adding_methods_to_a_ruby_class.php</link>
		<comments>http://www.devco.net/archives/2010/02/05/adding_methods_to_a_ruby_class.php#comments</comments>
		<pubDate>Fri, 05 Feb 2010 13:11:27 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1273</guid>
		<description><![CDATA[I'm just blogging this because it took me ages to figure out, it seems so simple now but I guess that's how it usually goes.
The problem I have is I want a plugin to be able to either make a method using the normal Ruby def foo or via some DSL'ish helpers.


class Foo&#60;Base
   [...]]]></description>
			<content:encoded><![CDATA[<p>I'm just blogging this because it took me ages to figure out, it seems so simple now but I guess that's how it usually goes.</p>
<p>The problem I have is I want a plugin to be able to either make a method using the normal Ruby <em>def foo</em> or via some DSL'ish helpers.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Foo<span style="color:#006600; font-weight:bold;">&lt;</span>Base
   register_action<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;do_something&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:description</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;foo&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
   <span style="color:#9966CC; font-weight:bold;">def</span> do_something_action
   <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
   register_action<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;do_something_else&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:description</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;foo&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      <span style="color:#008000; font-style:italic;"># body of the action here</span>
   <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

</blockquote>
<p>The above code should make me two methods - <em>do_something_action</em> and <em>do_something_else_action</em> - they should be identical to viewers from the outside.  Here's the base class that makes this happen correctly:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Base
   <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">register_input</span><span style="color:#006600; font-weight:bold;">&#40;</span>input, <span style="color:#006600; font-weight:bold;">&amp;</span>block<span style="color:#006600; font-weight:bold;">&#41;</span>
      name = input<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:name</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
      <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">module_eval</span> <span style="color:#006600; font-weight:bold;">&#123;</span> define_method<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{name}_action&quot;</span>, <span style="color:#006600; font-weight:bold;">&amp;</span>block<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#9966CC; font-weight:bold;">if</span> block_given?
   <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

</blockquote>
<p>It's pretty simple, we're just using define_method in the scope of the module and that does the rest.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/02/05/adding_methods_to_a_ruby_class.php/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MCollective Agent Introspection</title>
		<link>http://www.devco.net/archives/2010/02/03/mcollective_agent_introspection.php</link>
		<comments>http://www.devco.net/archives/2010/02/03/mcollective_agent_introspection.php#comments</comments>
		<pubDate>Wed, 03 Feb 2010 20:44:44 +0000</pubDate>
		<dc:creator>R.I. Pienaar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[mcollective]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.devco.net/?p=1269</guid>
		<description><![CDATA[With the new SimpleRPC system in MCollective we have a simple interface to creating agents.  The way to call an agent would be:


$ mc-rpc service status service=httpd


This is all fine and well and easy enough, however it requires you to know a lot.  You need to know there's a status action and you [...]]]></description>
			<content:encoded><![CDATA[<p>With the new <a href="http://srt.ly/simplerpc">SimpleRPC system in MCollective</a> we have a simple interface to creating agents.  The way to call an agent would be:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ mc-rpc service status <span style="color: #007800;">service</span>=httpd</pre></div></div>

</blockquote>
<p>This is all fine and well and easy enough, however it requires you to know a lot.  You need to know there's a <em>status</em> action and you need to know it expects a <em>service</em> argument, not great.</p>
<p>I'm busy adding the ability for an agent to register its metadata and interface so that 3rd party tools can dynamically generate useful interfaces.</p>
<p>A sample registration for service agent is:</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">register_meta<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span>        <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;SimpleRPC Service Agent&quot;</span>,
              <span style="color:#ff3333; font-weight:bold;">:description</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Agent to manage services using the Puppet service provider&quot;</span>,
              <span style="color:#ff3333; font-weight:bold;">:author</span>      <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;R.I.Pienaar&quot;</span>,
              <span style="color:#ff3333; font-weight:bold;">:license</span>     <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;GPLv2&quot;</span>,
              <span style="color:#ff3333; font-weight:bold;">:version</span>     <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">1.1</span>,
              <span style="color:#ff3333; font-weight:bold;">:url</span>         <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;http://mcollective-plugins.googlecode.com/&quot;</span>,
              <span style="color:#ff3333; font-weight:bold;">:timeout</span>     <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">60</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;start&quot;</span>, <span style="color:#996600;">&quot;stop&quot;</span>, <span style="color:#996600;">&quot;restart&quot;</span>, <span style="color:#996600;">&quot;status&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>action<span style="color:#006600; font-weight:bold;">|</span>
    register_input<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:action</span>      <span style="color:#006600; font-weight:bold;">=&gt;</span> action,
                   <span style="color:#ff3333; font-weight:bold;">:name</span>        <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;service&quot;</span>,
                   <span style="color:#ff3333; font-weight:bold;">:prompt</span>      <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Service Name&quot;</span>,
                   <span style="color:#ff3333; font-weight:bold;">:description</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;The service to #{action}&quot;</span>,
                   <span style="color:#ff3333; font-weight:bold;">:type</span>        <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:string</span>,
                   <span style="color:#ff3333; font-weight:bold;">:validation</span>  <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'^[a-zA-Z<span style="color:#000099;">\-</span>_<span style="color:#000099;">\d</span>]+$'</span>,
                   <span style="color:#ff3333; font-weight:bold;">:maxlength</span>   <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">30</span><span style="color:#006600; font-weight:bold;">&#41;</span>:</pre></div></div>

</blockquote>
<p>This includes all the meta data, versions, timeouts, validation of inputs, prompts and help text for every input argument.</p>
<p>Using this we can now generate dynamic UI's, and do something like JavaDoc generated documentation.  I've recorded <a href="http://srt.ly/4">a little video demonstrating a proof of concept Text UI</a> that uses this data to generate a UI dynamically.   This is ripe for integration into tools like <a href="http://srt.ly/foreman">Foreman</a> and <a href="http://srt.ly/puppetdash">Puppet Dashboard</a>.</p>
<p>Please watch the video <a href="http://srt.ly/4">here, best viewed full screen</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devco.net/archives/2010/02/03/mcollective_agent_introspection.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
