<?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>cd ~ &#187; Puppet</title>
	<atom:link href="http://www.rottenbytes.info/?cat=15&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.rottenbytes.info</link>
	<description>/home/nico</description>
	<lastBuildDate>Wed, 18 Aug 2010 09:35:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>In the network space no one can hear your puppet scream</title>
		<link>http://www.rottenbytes.info/?p=271</link>
		<comments>http://www.rottenbytes.info/?p=271#comments</comments>
		<pubDate>Tue, 02 Mar 2010 15:15:59 +0000</pubDate>
		<dc:creator>Nico</dc:creator>
				<category><![CDATA[BOFH Life]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.rottenbytes.info/?p=271</guid>
		<description><![CDATA[I&#8217;ve been lazy at maintaining my servers recently and decided to start playing with puppet reports. First I started with something simple that helps me to find on which machines my manifests have some failure.
So here&#8217;s a quick and dirty code that goes through Puppet&#8217;s reportdir and points out neglected machines.

#!/usr/bin/env ruby
&#160;
require 'puppet'
require 'find'
require 'yaml'
require [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-54" title="kermit" src="http://www.rottenbytes.info/wp-content/uploads/2009/01/kermit.jpg" alt="kermit" width="108" height="127" />I&#8217;ve been lazy at maintaining my servers recently and decided to start playing with puppet reports. First I started with something simple that helps me to find on which machines my manifests have some failure.</p>
<p>So here&#8217;s a quick and dirty code that goes through Puppet&#8217;s reportdir and points out neglected machines.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'puppet'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'find'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'yaml'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'optparse'</span>
&nbsp;
Puppet<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:config</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;/etc/puppet/puppet.conf&quot;</span>
Puppet.<span style="color:#9900CC;">parse_config</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> most_recent_file<span style="color:#006600; font-weight:bold;">&#40;</span>path<span style="color:#006600; font-weight:bold;">&#41;</span>
	reports = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
	<span style="color:#CC00FF; font-weight:bold;">Find</span>.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>path<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |file|
		<span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">file</span>? file
			reports <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">basename</span><span style="color:#006600; font-weight:bold;">&#40;</span>file,<span style="color:#996600;">&quot;.yaml&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#9966CC; font-weight:bold;">end</span>
	<span style="color:#006600; font-weight:bold;">&#125;</span>
	reports.<span style="color:#9900CC;">sort</span>!.<span style="color:#9900CC;">reverse</span>!
	<span style="color:#0000FF; font-weight:bold;">return</span> path<span style="color:#006600; font-weight:bold;">+</span><span style="color:#996600;">&quot;/&quot;</span><span style="color:#006600; font-weight:bold;">+</span>reports<span style="color:#006600; font-weight:bold;">&#91;</span>0<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_s</span><span style="color:#006600; font-weight:bold;">+</span><span style="color:#996600;">&quot;.yaml&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> scan_dir<span style="color:#006600; font-weight:bold;">&#40;</span>path, debug=<span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span>
	<span style="color:#CC00FF; font-weight:bold;">Find</span>.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>path<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |entry|
		<span style="color:#9966CC; font-weight:bold;">if</span> entry != path <span style="color:#008000; font-style:italic;"># don't scan the basedir</span>
			<span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">directory</span>? entry
				report = most_recent_file<span style="color:#006600; font-weight:bold;">&#40;</span>entry<span style="color:#006600; font-weight:bold;">&#41;</span>
				scan_file<span style="color:#006600; font-weight:bold;">&#40;</span>report, debug<span style="color:#006600; font-weight:bold;">&#41;</span>
			<span style="color:#9966CC; font-weight:bold;">end</span>
		<span style="color:#9966CC; font-weight:bold;">end</span>
	<span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> scan_file<span style="color:#006600; font-weight:bold;">&#40;</span>filename, debug=<span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span>
	notify_on_field = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:failed</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
	<span style="color:#008000; font-style:italic;"># debug</span>
	<span style="color:#9966CC; font-weight:bold;">if</span> debug <span style="color:#9966CC; font-weight:bold;">then</span>  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;scanning &quot;</span> <span style="color:#006600; font-weight:bold;">+</span> filename <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	fp=<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>filename,<span style="color:#996600;">&quot;r&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
	<span style="color:#CC00FF; font-weight:bold;">YAML</span>::load_documents<span style="color:#006600; font-weight:bold;">&#40;</span>fp<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |report|
		report.<span style="color:#9900CC;">metrics</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;resources&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">values</span>.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |value|
			<span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>notify_on_field.<span style="color:#9966CC; font-weight:bold;">include</span>? value<span style="color:#006600; font-weight:bold;">&#91;</span>0<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">and</span> <span style="color:#006600; font-weight:bold;">&#40;</span>value<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&gt;</span> 0<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">then</span>
				<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{report.host} has #{value[2]} #{value[0]} resource(s)&quot;</span>
				<span style="color:#9966CC; font-weight:bold;">if</span> debug <span style="color:#9966CC; font-weight:bold;">then</span>
					<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;log message(s) :&quot;</span>
					report.<span style="color:#9900CC;">logs</span>.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |log|
						<span style="color:#CC0066; font-weight:bold;">puts</span> log.<span style="color:#9900CC;">message</span>
					<span style="color:#006600; font-weight:bold;">&#125;</span>
				<span style="color:#9966CC; font-weight:bold;">end</span>
			<span style="color:#9966CC; font-weight:bold;">end</span>
		<span style="color:#006600; font-weight:bold;">&#125;</span>
	<span style="color:#006600; font-weight:bold;">&#125;</span>	
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
options = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
myargs = <span style="color:#CC0066; font-weight:bold;">Array</span>
&nbsp;
optparse = OptionParser.<span style="color:#9900CC;">new</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |opts|
	opts.<span style="color:#9900CC;">banner</span> = <span style="color:#996600;">&quot;Usage : report_check.rb&quot;</span>
&nbsp;
	options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:show</span><span style="color:#006600; font-weight:bold;">&#93;</span>=<span style="color:#0000FF; font-weight:bold;">false</span>
	opts.<span style="color:#9900CC;">on</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;-d&quot;</span>, <span style="color:#996600;">&quot;--debug&quot;</span>, <span style="color:#996600;">&quot;runs in debug mode&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> |debug|
		options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:debug</span><span style="color:#006600; font-weight:bold;">&#93;</span>=<span style="color:#0000FF; font-weight:bold;">true</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	opts.<span style="color:#9900CC;">on</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;-h&quot;</span>, <span style="color:#996600;">&quot;--help&quot;</span>, <span style="color:#996600;">&quot;Displays this help&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
		<span style="color:#CC0066; font-weight:bold;">puts</span> opts
		<span style="color:#CC0066; font-weight:bold;">exit</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
optparse.<span style="color:#9900CC;">parse</span>!
&nbsp;
scan_dir<span style="color:#006600; font-weight:bold;">&#40;</span>Puppet<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:reportdir</span><span style="color:#006600; font-weight:bold;">&#93;</span>, options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:debug</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.rottenbytes.info/?feed=rss2&amp;p=271</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A pkgin provider for puppet</title>
		<link>http://www.rottenbytes.info/?p=263</link>
		<comments>http://www.rottenbytes.info/?p=263#comments</comments>
		<pubDate>Fri, 26 Feb 2010 17:08:22 +0000</pubDate>
		<dc:creator>Nico</dc:creator>
				<category><![CDATA[BOFH Life]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[OpenSolaris]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[pkgin]]></category>

		<guid isPermaLink="false">http://www.rottenbytes.info/?p=263</guid>
		<description><![CDATA[On my Solaris machines at $WORK I use iMil&#8217;s pkgin to install additional software. But until today, I add to do it by hand, on every machine&#8230; Not really what I like to do after a little more than a year using puppet. So I wrote a provider to manage packages with pkgin. It was [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-54" title="kermit" src="http://www.rottenbytes.info/wp-content/uploads/2009/01/kermit.jpg" alt="kermit" width="108" height="127" />On my Solaris machines at $WORK I use <a href="http://imil.net">iMil</a>&#8217;s <a href="http://imil.net/pkgin">pkgin</a> to install additional software. But until today, I add to do it by hand, on every machine&#8230; Not really what I like to do after a little more than a year using puppet. So I wrote a provider to manage packages with pkgin. It was very informative on puppet internals and I learned more about my favorite config management system.</p>
<p>Enough talking, here is the file : <a href="http://www.rottenbytes.info/wp-content/uploads/2010/02/pkgin.rb">pkgin.rb</a></p>
<p>Example of use in a manifest :</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> foo <span style="color:#006600; font-weight:bold;">&#123;</span>
    package <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;bla&quot;</span>:
        <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> installed,
        provider <span style="color:#006600; font-weight:bold;">=&gt;</span> pkgin
    <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.rottenbytes.info/?feed=rss2&amp;p=263</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>When puppet meets nginx</title>
		<link>http://www.rottenbytes.info/?p=250</link>
		<comments>http://www.rottenbytes.info/?p=250#comments</comments>
		<pubDate>Mon, 22 Feb 2010 14:55:04 +0000</pubDate>
		<dc:creator>Nico</dc:creator>
				<category><![CDATA[BOFH Life]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[munin]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://www.rottenbytes.info/?p=250</guid>
		<description><![CDATA[At $WORK I started using Nginx a while ago, first as a front end to my mongrel instances for puppet. Recently I began to use it for one of its most know features : reverse proxy (and caching too). Of course this work had to be puppetized !
This is a summary of what I&#8217;ve done [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-252 alignleft" title="Absolut_nginx" src="http://www.rottenbytes.info/wp-content/uploads/2010/02/Absolut_nginx.jpg" alt="Absolut_nginx" width="90" height="250" />At $WORK I started using Nginx a while ago, first as a front end to my mongrel instances for puppet. Recently I began to use it for one of its most know features : reverse proxy (and caching too). Of course this work had to be puppetized !</p>
<p>This is a summary of what I&#8217;ve done :</p>
<ul>
<li>Basic setup</li>
<li>Automatic setup of the status page, exploited by a munin plugin</li>
<li>An &#8220;include&#8221; directory, can be specific to a host through the usual $fqdn source selection system (as well as the nginx.conf file).</li>
<li>A &#8220;reverse proxy&#8221; specific class that uses a template embedding some ruby (see the previous post). My cache dir is under tmpfs, to speed up the whole thing.</li>
</ul>
<p>This setup is mostly inspired by this <a href="http://www.cmdln.org/2009/07/12/transparent_dynamic-reverse-proxy-with-nginx/">post</a>. I use a local dnsmasq setup to resolve both internal &amp; external requests. This way I can manage vhosts being accessible from inside ou outside our network. It&#8217;s incredibly flexible and allows you to get the most from your infrastructure.</p>
<p>The puppet class :</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># @name : nginx</span>
<span style="color:#008000; font-style:italic;"># @desc : classe de base pour nginx</span>
<span style="color:#008000; font-style:italic;"># @info : nil</span>
<span style="color:#9966CC; font-weight:bold;">class</span> nginx
<span style="color:#006600; font-weight:bold;">&#123;</span>
 package <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;nginx&quot;</span>:
 <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> installed
 <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
 service <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;nginx&quot;</span>:
 <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> running
 <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
 file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;nginx.conf&quot;</span>:
 name <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/etc/nginx/nginx.conf&quot;</span>,
 owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
 group <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
 source <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#996600;">&quot;puppet://$fileserver/files/apps/nginx/$fqdn/nginx-rp-secure.conf&quot;</span>, <span style="color:#996600;">&quot;puppet://$fileserver/files/apps/nginx/nginx-rp-secure.conf&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
 <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> present,
 notify <span style="color:#006600; font-weight:bold;">=&gt;</span> Service<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;nginx&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
 <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
 <span style="color:#008000; font-style:italic;"># status is installed on all nginx boxens</span>
 file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;nginx-status&quot;</span>:
 name <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/etc/nginx/sites-enabled/nginx-status&quot;</span>,
 owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
 group <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
 source <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#996600;">&quot;puppet://$fileserver/files/apps/nginx/nginx-status&quot;</span>, <span style="color:#996600;">&quot;puppet://$fileserver/files/apps/nginx/$fqdn/nginx-status&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
 <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> present,
 notify <span style="color:#006600; font-weight:bold;">=&gt;</span> Service<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;nginx&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
 <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
 <span style="color:#008000; font-style:italic;"># include dir, get the freshness here</span>
 file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;include_dir&quot;</span>:
 name <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/etc/nginx/includes&quot;</span>,
 owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
 group <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
 source <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#996600;">&quot;puppet://$fileserver/files/apps/nginx/includes.$fqdn&quot;</span>, <span style="color:#996600;">&quot;puppet://$fileserver/files/apps/nginx/includes&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
 <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> directory,
 recurse <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>,
 notify <span style="color:#006600; font-weight:bold;">=&gt;</span> Service<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;nginx&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
 ignore <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;.svn*&quot;</span>
 <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
 <span style="color:#008000; font-style:italic;"># files managed by hand, no matter if it breaks</span>
 file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;sites-managed&quot;</span>:
 name <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/etc/nginx/sites-managed&quot;</span>,
 owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
 group <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
 <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> directory
 <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;"># @name : nginx::reverseproxy</span>
<span style="color:#008000; font-style:italic;"># @desc : config nginx pour reverse proxy</span>
<span style="color:#008000; font-style:italic;"># @info : utilisée en conjonction avec dnsmasq local</span>
<span style="color:#9966CC; font-weight:bold;">class</span> nginx::reverseproxy
<span style="color:#006600; font-weight:bold;">&#123;</span>
 <span style="color:#9966CC; font-weight:bold;">include</span> nginx
 <span style="color:#9966CC; font-weight:bold;">include</span> dnsmasq::reverseproxy
&nbsp;
 <span style="color:#008000; font-style:italic;"># Vars used by the template below</span>
 <span style="color:#ff6633; font-weight:bold;">$mysqldatabase</span>=extlookup<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;mysqldatabase&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
 <span style="color:#ff6633; font-weight:bold;">$mysqllogin</span>=extlookup<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;mysqllogin&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
 <span style="color:#ff6633; font-weight:bold;">$mysqlpassword</span>=extlookup<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;mysqlpassword&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
 <span style="color:#ff6633; font-weight:bold;">$mysqlserver</span>=extlookup<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;mysqlserver&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
 file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;nginx-cachedir&quot;</span>:
 name <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/dev/shm/nginx-cache&quot;</span>,
 owner <span style="color:#006600; font-weight:bold;">=&gt;</span> www<span style="color:#006600; font-weight:bold;">-</span>data,
 group <span style="color:#006600; font-weight:bold;">=&gt;</span> www<span style="color:#006600; font-weight:bold;">-</span>data,
 <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> directory
 <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
 file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;site_reverse-proxy&quot;</span>:
 name <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/etc/nginx/sites-enabled/reverse-proxy&quot;</span>,
 owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
 group <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
 content <span style="color:#006600; font-weight:bold;">=&gt;</span> template<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;nginx/$fqdn/reverse-proxy.erb&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>,
 <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> present,
 notify <span style="color:#006600; font-weight:bold;">=&gt;</span> Service<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;nginx&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
 <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#CC00FF; font-weight:bold;">File</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;nginx-cachedir&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
 <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>This is the munin plugins that are automatically distributed with the box.</p>
<ul>
<li><a href="http://www.rottenbytes.info/wp-content/uploads/2010/02/nginx-status">Nginx status</a></li>
<li><a href="http://www.rottenbytes.info/wp-content/uploads/2010/02/nginx-requests">Nginx requests</a></li>
</ul>
<p>One of the generated graphs :</p>
<p><img class="aligncenter size-full wp-image-258" title="nginx_requests-day" src="http://www.rottenbytes.info/wp-content/uploads/2010/02/nginx_requests-day.png" alt="nginx_requests-day" width="495" height="271" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rottenbytes.info/?feed=rss2&amp;p=250</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Put your ruby in my ERB</title>
		<link>http://www.rottenbytes.info/?p=243</link>
		<comments>http://www.rottenbytes.info/?p=243#comments</comments>
		<pubDate>Wed, 27 Jan 2010 20:17:31 +0000</pubDate>
		<dc:creator>Nico</dc:creator>
				<category><![CDATA[BOFH Life]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Général]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[erb]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[templates]]></category>

		<guid isPermaLink="false">http://www.rottenbytes.info/?p=243</guid>
		<description><![CDATA[ Today I started installing a reverse proxy at $WORK. I choose to follow this way, and all my DNS data is stored in my CMDB. Once again, the solution came from #puppet ! You can embed some &#8220;pure&#8221; ruby code in ERB templates. And, yes, you can query your database !

&#60;%
dbh = DBI.connect&#40;&#34;DBI:Mysql:yourbase:mysql.mycorp.com&#34;, &#34;you&#34;, [...]]]></description>
			<content:encoded><![CDATA[<p><img title="kermit" src="../wp-content/uploads/2009/01/kermit.jpg" alt="" width="108" height="127" /> Today I started installing a reverse proxy at $WORK. I choose to follow <a href="http://www.cmdln.org/2009/07/12/transparent_dynamic-reverse-proxy-with-nginx/">this way</a>, and all my DNS data is stored in my CMDB. Once again, the solution came from #puppet ! You can embed some &#8220;pure&#8221; ruby code in ERB templates. And, yes, you can query your database !</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>
dbh = DBI.<span style="color:#9900CC;">connect</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;DBI:Mysql:yourbase:mysql.mycorp.com&quot;</span>, <span style="color:#996600;">&quot;you&quot;</span>, <span style="color:#996600;">&quot;XXXX&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
query = dbh.<span style="color:#9900CC;">prepare</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;your fancy query&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
query.<span style="color:#9900CC;">execute</span>
<span style="color:#9966CC; font-weight:bold;">while</span> row = query.<span style="color:#9900CC;">fetch</span> <span style="color:#9966CC; font-weight:bold;">do</span>
todisplay=some_funny_things<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#006600; font-weight:bold;">%&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;%</span>= todisplay <span style="color:#006600; font-weight:bold;">%&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>I use this technique to generate the dnsmasq data file. Just use the subscribe function and all is done !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rottenbytes.info/?feed=rss2&amp;p=243</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fun with stored configs</title>
		<link>http://www.rottenbytes.info/?p=223</link>
		<comments>http://www.rottenbytes.info/?p=223#comments</comments>
		<pubDate>Mon, 07 Sep 2009 12:44:35 +0000</pubDate>
		<dc:creator>Nico</dc:creator>
				<category><![CDATA[Puppet]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.rottenbytes.info/?p=223</guid>
		<description><![CDATA[After reading masterzen&#8217;s excellent blog post about puppet storedconfigs, it gave me the idea to create a system of subscription to services.
For example, if you want some client to subscribe to a &#8220;backup&#8221; service you can use the following little things :

# Subscription system through exported resources
# A stupid idea of Nico &#60;nico@gcu.info&#62;
# $subscribedir is [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-thumbnail wp-image-54" title="kermit" src="http://www.rottenbytes.info/wp-content/uploads/2009/01/kermit.jpg" alt="" width="108" height="127" />After reading masterzen&#8217;s excellent <a href="http://www.masterzen.fr/2009/08/08/storeconfigs-use-cases/">blog post about puppet storedconfigs</a>, it gave me the idea to create a system of subscription to services.</p>
<p>For example, if you want some client to subscribe to a &#8220;backup&#8221; service you can use the following little things :</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Subscription system through exported resources</span>
<span style="color:#008000; font-style:italic;"># A stupid idea of Nico &lt;nico@gcu.info&gt;</span>
<span style="color:#008000; font-style:italic;"># $subscribedir is defined somewhere else</span>
define set_subscription_to<span style="color:#006600; font-weight:bold;">&#40;</span>$title<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#006600; font-weight:bold;">&#123;</span>
   @@file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;$subscribedir/nodes/$title/$fqdn&quot;</span>:
   content <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;<span style="color:#000099;">\n</span>&quot;</span>,
   tag <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;$title&quot;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
define get_subscription_to<span style="color:#006600; font-weight:bold;">&#40;</span>$title<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#006600; font-weight:bold;">&#123;</span>
   file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;$subscribedir&quot;</span>:
      <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> directory,
      owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root
   <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
   file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;$subscribedir/nodes&quot;</span>:
      <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> directory,
      owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
      <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#CC00FF; font-weight:bold;">File</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;$subscribedir&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
   <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
   file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;$subscribedir/nodes/$title&quot;</span>:
      <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> directory,
      owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
      <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#CC00FF; font-weight:bold;">File</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;$subscribedir/nodes&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
   <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
   <span style="color:#CC00FF; font-weight:bold;">File</span> &lt;&lt;| tag == <span style="color:#ff6633; font-weight:bold;">$title</span> |&gt;&gt;
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>and in your manifests :</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> client <span style="color:#006600; font-weight:bold;">&#123;</span>
   set_subscription_to <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;backup&quot;</span> : <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> server <span style="color:#006600; font-weight:bold;">&#123;</span>
   get_subscription_to <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;backup&quot;</span>: <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>Then the server will be able to know which machines subscribed to something and then treat them by walking the associated folder ( $subscribedir/nodes/$title )</p>
<p>This can be really enhanced of course <img src='http://www.rottenbytes.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Have fun</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rottenbytes.info/?feed=rss2&amp;p=223</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Puppet &amp; munin : little things added</title>
		<link>http://www.rottenbytes.info/?p=200</link>
		<comments>http://www.rottenbytes.info/?p=200#comments</comments>
		<pubDate>Wed, 05 Aug 2009 07:58:35 +0000</pubDate>
		<dc:creator>Nico</dc:creator>
				<category><![CDATA[BOFH Life]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[munin]]></category>

		<guid isPermaLink="false">http://www.rottenbytes.info/?p=200</guid>
		<description><![CDATA[ Disclaimer : this work is mostly based upon DavidS work, available on his git repo. In the scope of my work I needed to have munin support for freeBSD &#38; Solaris. I also wrote a class for snmp_plugins &#38; custom plugins. Some things are quite dependant from my infrastructure, like munin.conf generation script but [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-thumbnail wp-image-54" title="kermit" src="http://www.rottenbytes.info/wp-content/uploads/2009/01/kermit.jpg" alt="" width="108" height="127" /> Disclaimer : this work is mostly based upon DavidS work, available on <a href="http://git.black.co.at">his git repo</a>. In the scope of my work I needed to have munin support for freeBSD &amp; Solaris. I also wrote a class for snmp_plugins &amp; custom plugins. Some things are quite dependant from my infrastructure, like munin.conf generation script but it can easily be adapted to yours, by extracting data from your CMDB.</p>
<p>It requires the munin_interfaces fact published here (and merged into DavidS repo, thanks to him), and <a href="http://nephilim.ml.org/~rip/puppet/extlookup.rb">Volcane&#8217;s extlookup function</a> to store some parameters. Enough talking, this is the code :</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Munin config class</span>
<span style="color:#008000; font-style:italic;"># Many parts taken from David Schmitt's http://git.black.co.at/</span>
<span style="color:#008000; font-style:italic;"># FreeBSD &amp; Solaris + SNMP &amp; custom plugins support by Nicolas Szalay &lt;nico@gcu.info&gt;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> munin::node <span style="color:#006600; font-weight:bold;">&#123;</span>
	<span style="color:#9966CC; font-weight:bold;">case</span> <span style="color:#ff6633; font-weight:bold;">$operatingsystem</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
		openbsd: <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
		debian: <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#9966CC; font-weight:bold;">include</span> munin::node::debian<span style="color:#006600; font-weight:bold;">&#125;</span>
		freebsd: <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#9966CC; font-weight:bold;">include</span> munin::node::freebsd<span style="color:#006600; font-weight:bold;">&#125;</span>
		solaris: <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#9966CC; font-weight:bold;">include</span> munin::node::solaris<span style="color:#006600; font-weight:bold;">&#125;</span>
		default: <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
	<span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> munin::node::debian <span style="color:#006600; font-weight:bold;">&#123;</span>
&nbsp;
	package <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;munin-node&quot;</span>: <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> installed <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	file <span style="color:#006600; font-weight:bold;">&#123;</span> 
	<span style="color:#996600;">&quot;/etc/munin&quot;</span>:
		<span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> directory,
		mode <span style="color:#006600; font-weight:bold;">=&gt;</span> 0755,
		owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
		group <span style="color:#006600; font-weight:bold;">=&gt;</span> root;
&nbsp;
	<span style="color:#996600;">&quot;/etc/munin/munin-node.conf&quot;</span>:
		source <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;puppet://$fileserver/files/apps/munin/munin-node-debian.conf&quot;</span>,
		owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
		group <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
		mode <span style="color:#006600; font-weight:bold;">=&gt;</span> 0644,
		before <span style="color:#006600; font-weight:bold;">=&gt;</span> Package<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;munin-node&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
		notify <span style="color:#006600; font-weight:bold;">=&gt;</span> Service<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;munin-node&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	service <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;munin-node&quot;</span>: <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> running <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">include</span> munin::plugins::linux 
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> munin::node::freebsd <span style="color:#006600; font-weight:bold;">&#123;</span>
	package <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;munin-node&quot;</span>: <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> installed, provider <span style="color:#006600; font-weight:bold;">=&gt;</span> freebsd <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
        file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;/usr/local/etc/munin/munin-node.conf&quot;</span>:
                source <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;puppet://$fileserver/files/apps/munin/munin-node-freebsd.conf&quot;</span>,
                owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
                group <span style="color:#006600; font-weight:bold;">=&gt;</span> wheel,
                mode <span style="color:#006600; font-weight:bold;">=&gt;</span> 0644,
                before <span style="color:#006600; font-weight:bold;">=&gt;</span> Package<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;munin-node&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
                notify <span style="color:#006600; font-weight:bold;">=&gt;</span> Service<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;munin-node&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
        <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	service <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;munin-node&quot;</span>: <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> running <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">include</span> munin::plugins::freebsd
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> munin::node::solaris <span style="color:#006600; font-weight:bold;">&#123;</span>
	<span style="color:#008000; font-style:italic;"># &quot;hand made&quot; install, no package.</span>
	file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;/etc/munin/munin-node.conf&quot;</span>:
		source <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;puppet://$fileserver/files/apps/munin/munin-node-solaris.conf&quot;</span>,
                owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
                group <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
                mode <span style="color:#006600; font-weight:bold;">=&gt;</span> 0644
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">include</span> munin::plugins::solaris
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> munin::gatherer <span style="color:#006600; font-weight:bold;">&#123;</span>
	package <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;munin&quot;</span>:
		<span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> installed
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#008000; font-style:italic;"># custom version of munin-graph : forks &amp; generates many graphs in parallel</span>
	file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;/usr/share/munin/munin-graph&quot;</span>:
		owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
		group <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
		mode <span style="color:#006600; font-weight:bold;">=&gt;</span> 0755,
		source <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;puppet://$fileserver/files/apps/munin/gatherer/munin-graph&quot;</span>,
		<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> Package<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;munin&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#008000; font-style:italic;"># custon version of debian cron file. Month &amp; Year cron are generated once daily</span>
	file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;/etc/cron.d/munin&quot;</span>:
		owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
		group <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
		mode <span style="color:#006600; font-weight:bold;">=&gt;</span> 0644,
		source <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;puppet://$fileserver/files/apps/munin/gatherer/munin.cron&quot;</span>,
		<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> Package<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;munin&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#008000; font-style:italic;"># Ensure cron is running, to fetch every 5 minutes</span>
	service <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;cron&quot;</span>:
		<span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> running
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#008000; font-style:italic;"># Ruby DBI for mysql</span>
	package <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;libdbd-mysql-ruby&quot;</span>:
		<span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> installed
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#008000; font-style:italic;"># config generator</span>
	file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;/opt/scripts/muningen.rb&quot;</span>:
		owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
		group <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
		mode <span style="color:#006600; font-weight:bold;">=&gt;</span> 0755,
		source <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;puppet://$fileserver/files/apps/munin/gatherer/muningen.rb&quot;</span>,
		<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> Package<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;munin&quot;</span>, <span style="color:#996600;">&quot;libdbd-mysql-ruby&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
	<span style="color:#006600; font-weight:bold;">&#125;</span>	
&nbsp;
	<span style="color:#008000; font-style:italic;"># regenerate munin's gatherer config every hour</span>
	cron <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;munin_config&quot;</span>:
		command <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/opt/scripts/muningen.rb &gt; /etc/munin/munin.conf&quot;</span>,
		user <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;root&quot;</span>,
		minute <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;0&quot;</span>,
		<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#CC00FF; font-weight:bold;">File</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;/opt/scripts/muningen.rb&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">include</span> munin::plugins::snmp
	<span style="color:#9966CC; font-weight:bold;">include</span> munin::plugins::linux
	<span style="color:#9966CC; font-weight:bold;">include</span> munin::plugins::custom::gatherer
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
&nbsp;
<span style="color:#008000; font-style:italic;"># define to create a munin plugin inside the right directory</span>
define munin::plugin <span style="color:#006600; font-weight:bold;">&#40;</span>$ensure = <span style="color:#996600;">&quot;present&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">case</span> <span style="color:#ff6633; font-weight:bold;">$operatingsystem</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
		freebsd: <span style="color:#006600; font-weight:bold;">&#123;</span> 
			<span style="color:#ff6633; font-weight:bold;">$script_path</span> = <span style="color:#996600;">&quot;/usr/local/share/munin/plugins&quot;</span>
			<span style="color:#ff6633; font-weight:bold;">$plugins_dir</span> = <span style="color:#996600;">&quot;/usr/local/etc/munin/plugins&quot;</span>
		<span style="color:#006600; font-weight:bold;">&#125;</span>
		debian: <span style="color:#006600; font-weight:bold;">&#123;</span> 
			<span style="color:#ff6633; font-weight:bold;">$script_path</span> = <span style="color:#996600;">&quot;/usr/share/munin/plugins&quot;</span>
			<span style="color:#ff6633; font-weight:bold;">$plugins_dir</span> = <span style="color:#996600;">&quot;/etc/munin/plugins&quot;</span>
		<span style="color:#006600; font-weight:bold;">&#125;</span>
		solaris: <span style="color:#006600; font-weight:bold;">&#123;</span> 
			<span style="color:#ff6633; font-weight:bold;">$script_path</span> = <span style="color:#996600;">&quot;/usr/local/munin/lib/plugins&quot;</span>
			<span style="color:#ff6633; font-weight:bold;">$plugins_dir</span> = <span style="color:#996600;">&quot;/etc/munin/plugins&quot;</span>
		<span style="color:#006600; font-weight:bold;">&#125;</span>
		default: <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#ff6633; font-weight:bold;">$plugin</span> = <span style="color:#996600;">&quot;$plugins_dir/$name&quot;</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">case</span> <span style="color:#ff6633; font-weight:bold;">$ensure</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
		<span style="color:#996600;">&quot;absent&quot;</span>: <span style="color:#006600; font-weight:bold;">&#123;</span>
			debug <span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#996600;">&quot;munin_plugin: suppressing $plugin&quot;</span> <span style="color:#006600; font-weight:bold;">&#41;</span>
			file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff6633; font-weight:bold;">$plugin</span>: <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> absent, <span style="color:#006600; font-weight:bold;">&#125;</span> 
		<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
		default: <span style="color:#006600; font-weight:bold;">&#123;</span>
			<span style="color:#ff6633; font-weight:bold;">$plugin_src</span> = <span style="color:#ff6633; font-weight:bold;">$ensure</span> ? <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;present&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff6633; font-weight:bold;">$name</span>, default <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff6633; font-weight:bold;">$ensure</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
			file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff6633; font-weight:bold;">$plugin</span>:
				<span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;$script_path/${plugin_src}&quot;</span>,
				<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> Package<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;munin-node&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
				notify <span style="color:#006600; font-weight:bold;">=&gt;</span> Service<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;munin-node&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>
	<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;"># snmp plugin define, almost same as above</span>
define munin::snmp_plugin <span style="color:#006600; font-weight:bold;">&#40;</span>$ensure = <span style="color:#996600;">&quot;present&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
	<span style="color:#ff6633; font-weight:bold;">$pluginname</span> = get_plugin_name<span style="color:#006600; font-weight:bold;">&#40;</span>$name<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">case</span> <span style="color:#ff6633; font-weight:bold;">$operatingsystem</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
		freebsd: <span style="color:#006600; font-weight:bold;">&#123;</span> 
			<span style="color:#ff6633; font-weight:bold;">$script_path</span> = <span style="color:#996600;">&quot;/usr/local/share/munin/plugins&quot;</span>
			<span style="color:#ff6633; font-weight:bold;">$plugins_dir</span> = <span style="color:#996600;">&quot;/usr/local/etc/munin/plugins&quot;</span>
		<span style="color:#006600; font-weight:bold;">&#125;</span>
		debian: <span style="color:#006600; font-weight:bold;">&#123;</span> 
			<span style="color:#ff6633; font-weight:bold;">$script_path</span> = <span style="color:#996600;">&quot;/usr/share/munin/plugins&quot;</span>
			<span style="color:#ff6633; font-weight:bold;">$plugins_dir</span> = <span style="color:#996600;">&quot;/etc/munin/plugins&quot;</span>
		<span style="color:#006600; font-weight:bold;">&#125;</span>
		solaris: <span style="color:#006600; font-weight:bold;">&#123;</span> 
			<span style="color:#ff6633; font-weight:bold;">$script_path</span> = <span style="color:#996600;">&quot;/usr/local/munin/lib/plugins&quot;</span>
			<span style="color:#ff6633; font-weight:bold;">$plugins_dir</span> = <span style="color:#996600;">&quot;/etc/munin/plugins&quot;</span>
		<span style="color:#006600; font-weight:bold;">&#125;</span>
		default: <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#ff6633; font-weight:bold;">$plugin</span> = <span style="color:#996600;">&quot;$plugins_dir/$name&quot;</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">case</span> <span style="color:#ff6633; font-weight:bold;">$ensure</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
		<span style="color:#996600;">&quot;absent&quot;</span>: <span style="color:#006600; font-weight:bold;">&#123;</span>
			debug <span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#996600;">&quot;munin_plugin: suppressing $plugin&quot;</span> <span style="color:#006600; font-weight:bold;">&#41;</span>
			file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff6633; font-weight:bold;">$plugin</span>: <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> absent, <span style="color:#006600; font-weight:bold;">&#125;</span> 
		<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
		<span style="color:#996600;">&quot;present&quot;</span>: <span style="color:#006600; font-weight:bold;">&#123;</span>
			file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff6633; font-weight:bold;">$plugin</span>:
				<span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;$script_path/${pluginname}&quot;</span>,
				<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> Package<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;munin-node&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
				notify <span style="color:#006600; font-weight:bold;">=&gt;</span> Service<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;munin-node&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>
	<span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> munin::plugins::base
<span style="color:#006600; font-weight:bold;">&#123;</span>
	<span style="color:#9966CC; font-weight:bold;">case</span> <span style="color:#ff6633; font-weight:bold;">$operatingsystem</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
		debian: <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff6633; font-weight:bold;">$plugins_dir</span> = <span style="color:#996600;">&quot;/etc/munin/plugins&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
		freebsd: <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff6633; font-weight:bold;">$plugins_dir</span> = <span style="color:#996600;">&quot;/usr/local/etc/munin/plugins&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
		solaris: <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff6633; font-weight:bold;">$plugins_dir</span> = <span style="color:#996600;">&quot;/etc/munin/plugins&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
		default: <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff6633; font-weight:bold;">$plugins_dir</span>:
		source <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;puppet://$fileserver/files/empty&quot;</span>,
		<span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> directory,
		checksum <span style="color:#006600; font-weight:bold;">=&gt;</span> mtime,
		ignore <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;.svn*&quot;</span>,
		mode <span style="color:#006600; font-weight:bold;">=&gt;</span> 0755,
		recurse <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>,
		purge <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>,
		force <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>,
		owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root
	<span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> munin::plugins::interfaces
<span style="color:#006600; font-weight:bold;">&#123;</span>
	<span style="color:#ff6633; font-weight:bold;">$ifs</span> = <span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span>$munin_interfaces, <span style="color:#996600;">&quot; &quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#996600;">&quot;(.+)&quot;</span>, <span style="color:#996600;">&quot;if_<span style="color:#000099;">\\</span>1&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
	<span style="color:#ff6633; font-weight:bold;">$if_errs</span> = <span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span>$munin_interfaces, <span style="color:#996600;">&quot; &quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#996600;">&quot;(.+)&quot;</span>, <span style="color:#996600;">&quot;if_err_<span style="color:#000099;">\\</span>1&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
	plugin <span style="color:#006600; font-weight:bold;">&#123;</span>
		<span style="color:#ff6633; font-weight:bold;">$ifs</span>: <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;if_&quot;</span>;
		<span style="color:#ff6633; font-weight:bold;">$if_errs</span>: <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;if_err_&quot;</span>;
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">include</span> munin::plugins::base
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> munin::plugins::linux 
<span style="color:#006600; font-weight:bold;">&#123;</span>
	plugin <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">&#91;</span> cpu, <span style="color:#CC0066; font-weight:bold;">load</span>, memory, swap, irq_stats, df, processes, open_files, ntp_offset, vmstat <span style="color:#006600; font-weight:bold;">&#93;</span>: 
		<span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;present&quot;</span>
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">include</span> munin::plugins::base
	<span style="color:#9966CC; font-weight:bold;">include</span> munin::plugins::interfaces
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> munin::plugins::nfsclient
<span style="color:#006600; font-weight:bold;">&#123;</span>
	plugin <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;nfs_client&quot;</span>:
		<span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> present
	<span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> munin::plugins::snmp
<span style="color:#006600; font-weight:bold;">&#123;</span>
	<span style="color:#008000; font-style:italic;"># initialize plugins</span>
	<span style="color:#ff6633; font-weight:bold;">$snmp_plugins</span>=extlookup<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;munin_snmp_plugins&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
	snmp_plugin <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff6633; font-weight:bold;">$snmp_plugins</span>:
		<span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> present
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#008000; font-style:italic;"># SNMP communities used by plugins</span>
	file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">&quot;/etc/munin/plugin-conf.d/snmp_communities&quot;</span>:
		owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
		group <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
		mode <span style="color:#006600; font-weight:bold;">=&gt;</span> 0644,
		source <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;puppet://$fileserver/files/apps/munin/gatherer/snmp_communities&quot;</span>
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
define munin::custom_plugin<span style="color:#006600; font-weight:bold;">&#40;</span>$ensure = <span style="color:#996600;">&quot;present&quot;</span>, <span style="color:#ff6633; font-weight:bold;">$location</span> = <span style="color:#996600;">&quot;/etc/munin/plugins&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
	<span style="color:#ff6633; font-weight:bold;">$plugin</span> = <span style="color:#996600;">&quot;$location/$name&quot;</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">case</span> <span style="color:#ff6633; font-weight:bold;">$ensure</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
		<span style="color:#996600;">&quot;absent&quot;</span>: <span style="color:#006600; font-weight:bold;">&#123;</span>
			file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff6633; font-weight:bold;">$plugin</span>: <span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> absent, <span style="color:#006600; font-weight:bold;">&#125;</span> 
		<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
		<span style="color:#996600;">&quot;present&quot;</span>: <span style="color:#006600; font-weight:bold;">&#123;</span>
			file <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff6633; font-weight:bold;">$plugin</span>:
				owner <span style="color:#006600; font-weight:bold;">=&gt;</span> root,
				mode <span style="color:#006600; font-weight:bold;">=&gt;</span> 0755,
				source <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;puppet://$fileserver/files/apps/munin/custom_plugins/$name&quot;</span>,
				<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> Package<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;munin-node&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
				notify <span style="color:#006600; font-weight:bold;">=&gt;</span> Service<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;munin-node&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>
	<span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> munin::plugins::custom::gatherer
<span style="color:#006600; font-weight:bold;">&#123;</span>
	<span style="color:#ff6633; font-weight:bold;">$plugins</span>=extlookup<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;munin_custom_plugins&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
	custom_plugin <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff6633; font-weight:bold;">$plugins</span>:
		<span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> present
	<span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> munin::plugins::freebsd 
<span style="color:#006600; font-weight:bold;">&#123;</span>
	plugin <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">&#91;</span> cpu, <span style="color:#CC0066; font-weight:bold;">load</span>, memory, swap, irq_stats, df, processes, open_files, ntp_offset, vmstat <span style="color:#006600; font-weight:bold;">&#93;</span>: 
		<span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;present&quot;</span>,
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">include</span> munin::plugins::base
	<span style="color:#9966CC; font-weight:bold;">include</span> munin::plugins::interfaces
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> munin::plugins::solaris 
<span style="color:#006600; font-weight:bold;">&#123;</span>
	<span style="color:#008000; font-style:italic;"># Munin plugins on solaris are quite ... buggy. Will need rewrite / custom plugins.</span>
	plugin <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">&#91;</span> cpu, <span style="color:#CC0066; font-weight:bold;">load</span>, netstat <span style="color:#006600; font-weight:bold;">&#93;</span>: 
		<span style="color:#9966CC; font-weight:bold;">ensure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;present&quot;</span>,
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">include</span> munin::plugins::base
	<span style="color:#9966CC; font-weight:bold;">include</span> munin::plugins::interfaces
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.rottenbytes.info/?feed=rss2&amp;p=200</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Feed your puppet</title>
		<link>http://www.rottenbytes.info/?p=192</link>
		<comments>http://www.rottenbytes.info/?p=192#comments</comments>
		<pubDate>Thu, 30 Jul 2009 12:04:13 +0000</pubDate>
		<dc:creator>Nico</dc:creator>
				<category><![CDATA[BOFH Life]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[facter]]></category>

		<guid isPermaLink="false">http://www.rottenbytes.info/?p=192</guid>
		<description><![CDATA[-Post en anglais, pour une fois-
Everyone using puppet knows DavidS awesome git repository : git.black.co.at. Unfornately for me, his puppet infrastructure seems to be almost only linux based. I have different OS in mine, including FreeBSD &#38; OpenSolaris. Looking at his module-munin I decided to reuse it (and not recreate the wheel) but he used [...]]]></description>
			<content:encoded><![CDATA[<p>-Post en anglais, pour une fois-</p>
<p><img class="alignleft size-thumbnail wp-image-54" title="kermit" src="http://www.rottenbytes.info/wp-content/uploads/2009/01/kermit.jpg" alt="" width="108" height="127" />Everyone using puppet knows DavidS awesome git repository : <a title="DavidS Git Puppet" href="http://git.black.co.at">git.black.co.at</a>. Unfornately for me, his puppet infrastructure seems to be almost only linux based. I have different OS in mine, including FreeBSD &amp; OpenSolaris. Looking at his module-munin I decided to reuse it (and not recreate the wheel) but he used a custom fact that needed some little work. So this is a FreeBSD &amp; (Open)Solaris capable version, to know what network interfaces have link up</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># return the set of active interfaces as an array</span>
<span style="color:#008000; font-style:italic;"># taken from http://git.black.co.at</span>
<span style="color:#008000; font-style:italic;"># modified by nico &lt;nico@gcu.info&gt; to add FreeBSD &amp; Solaris support</span>
&nbsp;
Facter.<span style="color:#9900CC;">add</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;munin_interfaces&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp;
	setcode <span style="color:#9966CC; font-weight:bold;">do</span>
		<span style="color:#008000; font-style:italic;"># linux</span>
		<span style="color:#9966CC; font-weight:bold;">if</span> Facter.<span style="color:#9900CC;">value</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'kernel'</span><span style="color:#006600; font-weight:bold;">&#41;</span> == <span style="color:#996600;">&quot;Linux&quot;</span> <span style="color:#9966CC; font-weight:bold;">then</span>
			<span style="color:#996600;">`ip -o link show`</span>.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>\n<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">collect</span> <span style="color:#9966CC; font-weight:bold;">do</span> |line|
					value = <span style="color:#0000FF; font-weight:bold;">nil</span>
					matches = line.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>^\d<span style="color:#006600; font-weight:bold;">*</span>: <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>^:<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#41;</span>: <span style="color:#006600; font-weight:bold;">&lt;</span><span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#006600; font-weight:bold;">*</span>,<span style="color:#006600; font-weight:bold;">&#41;</span>?UP<span style="color:#006600; font-weight:bold;">&#40;</span>,.<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#41;</span>?<span style="color:#006600; font-weight:bold;">&gt;/</span><span style="color:#006600; font-weight:bold;">&#41;</span>
					<span style="color:#9966CC; font-weight:bold;">if</span> !matches.<span style="color:#0000FF; font-weight:bold;">nil</span>?
						value = matches<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>
						value.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>@.<span style="color:#006600; font-weight:bold;">*/</span>, <span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span>
					<span style="color:#9966CC; font-weight:bold;">end</span>
					value
			<span style="color:#9966CC; font-weight:bold;">end</span>.<span style="color:#9900CC;">compact</span>.<span style="color:#9900CC;">sort</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot; &quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#008000; font-style:italic;">#end</span>
&nbsp;
		<span style="color:#008000; font-style:italic;"># freebsd</span>
		<span style="color:#9966CC; font-weight:bold;">elsif</span> Facter.<span style="color:#9900CC;">value</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'kernel'</span><span style="color:#006600; font-weight:bold;">&#41;</span> == <span style="color:#996600;">&quot;FreeBSD&quot;</span> <span style="color:#9966CC; font-weight:bold;">then</span>
			Facter.<span style="color:#9900CC;">value</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'interfaces'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>,<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">collect</span> <span style="color:#9966CC; font-weight:bold;">do</span> |interface|
				status = <span style="color:#996600;">`ifconfig #{interface} | grep status`</span>
				<span style="color:#9966CC; font-weight:bold;">if</span> status != <span style="color:#996600;">&quot;&quot;</span> <span style="color:#9966CC; font-weight:bold;">then</span>
					status=status.<span style="color:#9900CC;">strip</span>!.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;:&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">strip</span>!
					<span style="color:#9966CC; font-weight:bold;">if</span> status == <span style="color:#996600;">&quot;active&quot;</span> <span style="color:#9966CC; font-weight:bold;">then</span> <span style="color:#008000; font-style:italic;"># I CAN HAZ LINK ?</span>
						interface.<span style="color:#9900CC;">to_a</span>
					<span style="color:#9966CC; font-weight:bold;">end</span>
				<span style="color:#9966CC; font-weight:bold;">end</span>
			<span style="color:#9966CC; font-weight:bold;">end</span>.<span style="color:#9900CC;">compact</span>.<span style="color:#9900CC;">sort</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot; &quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#008000; font-style:italic;">#end</span>
&nbsp;
		<span style="color:#008000; font-style:italic;"># solaris</span>
		<span style="color:#9966CC; font-weight:bold;">elsif</span> Facter.<span style="color:#9900CC;">value</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'kernel'</span><span style="color:#006600; font-weight:bold;">&#41;</span> == <span style="color:#996600;">&quot;SunOS&quot;</span> <span style="color:#9966CC; font-weight:bold;">then</span>
			Facter.<span style="color:#9900CC;">value</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'interfaces'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>,<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">collect</span> <span style="color:#9966CC; font-weight:bold;">do</span> |interface|
				<span style="color:#9966CC; font-weight:bold;">if</span> interface != <span style="color:#996600;">&quot;lo0&quot;</span> <span style="color:#9966CC; font-weight:bold;">then</span> <span style="color:#008000; font-style:italic;"># /dev/lo0 does not exists</span>
					status = <span style="color:#996600;">`ndd -get /dev/#{interface} link_status`</span>.<span style="color:#9900CC;">strip</span>!
					<span style="color:#9966CC; font-weight:bold;">if</span> status == <span style="color:#996600;">&quot;1&quot;</span> <span style="color:#008000; font-style:italic;"># ndd returns 1 for link up, 0 for down</span>
						interface.<span style="color:#9900CC;">to_a</span>
					<span style="color:#9966CC; font-weight:bold;">end</span>
				<span style="color:#9966CC; font-weight:bold;">end</span>
			<span style="color:#9966CC; font-weight:bold;">end</span>.<span style="color:#9900CC;">compact</span>.<span style="color:#9900CC;">sort</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot; &quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#9966CC; font-weight:bold;">end</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Thanks to Volcane from IRC for helping me.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rottenbytes.info/?feed=rss2&amp;p=192</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>La poupée agile</title>
		<link>http://www.rottenbytes.info/?p=176</link>
		<comments>http://www.rottenbytes.info/?p=176#comments</comments>
		<pubDate>Mon, 06 Jul 2009 12:52:24 +0000</pubDate>
		<dc:creator>Nico</dc:creator>
				<category><![CDATA[BOFH Life]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[NetAdmin]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[agile]]></category>

		<guid isPermaLink="false">http://www.rottenbytes.info/?p=176</guid>
		<description><![CDATA[ Il y a des trucs, ça relève du bon sens mais on y pense pas toujours. Dans le monde des sysadmins, il y en a qui militent pour ce qu&#8217;on appelle &#8220;l&#8217;agilité&#8221;. C&#8217;est en fait appliquer certaines techniques à la base mises en place pour le développement au monde de l&#8217;administration système. Personnellement, je [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-thumbnail wp-image-54" title="kermit" src="http://www.rottenbytes.info/wp-content/uploads/2009/01/kermit.jpg" alt="" width="108" height="127" /> Il y a des trucs, ça relève du bon sens mais on y pense pas toujours. Dans le monde des sysadmins, il y en a qui militent pour ce qu&#8217;on appelle &#8220;l&#8217;agilité&#8221;. C&#8217;est en fait appliquer certaines techniques à la base mises en place pour le développement au monde de l&#8217;administration système. Personnellement, je trouve que ce sont essentiellement des conseils de bon sens, l&#8217;expérience qui parle en somme.</p>
<p>Une de ces &#8220;bonnes pratiques&#8221; est que le code est la documentation, ce qui évite d&#8217;avoir à la réécrire &#8211; parce que c&#8217;est chiant avouons le &#8211; voire même d&#8217;oublier de l&#8217;écrire, ce qui arrive souvent.</p>
<p>Comme je suis en pleine frénésie puppet-ienne, j&#8217;écris des classes à tout va mais pas la doc qui va avec.. et ça PAS BIEN. Je me suis donc lancé dans un petit projet pour documenter mes classes puppet vite fait bien comme une loutre.</p>
<p>Il suffit d&#8217;ajouter au dessus de chaque classe (ou en dessous ou peu importe, le code est crade et ne fait pas la différence) des commentaires formattés comme suit :</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># @name : debian</span>
<span style="color:#008000; font-style:italic;"># @desc : classe de base pour debian</span>
<span style="color:#008000; font-style:italic;"># @info : ne pas affecter, sera incluse automatiquement</span></pre></div></div>

<p>Pour que le script sorte les données dans un tableau façon dokuwiki en 3 colonnes.</p>
<p>Le script va ensuite poster les infos dans le dokuwiki via XML-RPC dans la page indiquée par le script. Tout ce que contient la page sera écrasé, ce n&#8217;est pas de l&#8217;&#8221;append&#8221;.</p>
<p>Personnellement je conjugue ce script avec le plugin &#8220;include&#8221; de dokuwiki. J&#8217;ai donc la syntaxe suivante dans une des pages de mon wiki :</p>
<pre>{{page>:auto_puppetclasses}}</pre>
<p>Le XML-RPC est désactivé par défaut dans dokuwiki, pour l&#8217;activer ajoutez dans conf/local.php</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #000088;">$conf</span><span style="color: #009900;">&#91;</span><span style="">'xmlrpc'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span>;</pre></div></div>

<p>Et enfin, le script en ruby avec des bouts de XML-RPC dedans (dispo dans le package libruby sous debian). Warning, code sale.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
<span style="color:#008000; font-style:italic;">#</span>
<span style="color:#008000; font-style:italic;"># Automagicaly adds puppet classes in the dokuwiki corporate documentation</span>
<span style="color:#008000; font-style:italic;"># For use with the &quot;include&quot; plugin</span>
<span style="color:#008000; font-style:italic;"># By nico &lt;nico@gcu.info&gt;</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'xmlrpc/client'</span>
&nbsp;
xmlrpc_url = <span style="color:#996600;">&quot;http://XXXXX/wiki/lib/exe/xmlrpc.php&quot;</span>
basedirs = <span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#996600;">&quot;/home/nico/sysadmin/puppet/manifests/classes&quot;</span>, <span style="color:#996600;">&quot;/home/nico/sysadmin/puppet/manifests/os&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
destination_page = <span style="color:#996600;">&quot;auto_puppetclasses&quot;</span>
&nbsp;
server = <span style="color:#6666ff; font-weight:bold;">XMLRPC::Client</span>.<span style="color:#9900CC;">new2</span><span style="color:#006600; font-weight:bold;">&#40;</span>xmlrpc_url<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> doku_class<span style="color:#006600; font-weight:bold;">&#40;</span>classfile, final_page<span style="color:#006600; font-weight:bold;">&#41;</span>
	fp=<span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>classfile<span style="color:#006600; font-weight:bold;">&#41;</span>
	fp.<span style="color:#CC0066; font-weight:bold;">readlines</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |line|
&nbsp;
		line=line.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;n&quot;</span>,<span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
		<span style="color:#9966CC; font-weight:bold;">if</span> line =~ <span style="color:#006600; font-weight:bold;">/</span>@name<span style="color:#006600; font-weight:bold;">/</span>
			final_page <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#996600;">&quot;| &quot;</span> <span style="color:#006600; font-weight:bold;">+</span> line<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">10</span>,line.<span style="color:#9900CC;">length</span><span style="color:#006600; font-weight:bold;">&#93;</span>
		<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
		<span style="color:#9966CC; font-weight:bold;">if</span> line =~ <span style="color:#006600; font-weight:bold;">/</span>@desc<span style="color:#006600; font-weight:bold;">/</span>
			final_page <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#996600;">&quot; | &quot;</span> <span style="color:#006600; font-weight:bold;">+</span> line<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">10</span>,line.<span style="color:#9900CC;">length</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot; | &quot;</span>
		<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
		<span style="color:#9966CC; font-weight:bold;">if</span> line =~ <span style="color:#006600; font-weight:bold;">/</span>@info<span style="color:#006600; font-weight:bold;">/</span>
			final_page <span style="color:#006600; font-weight:bold;">+</span>= line<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">10</span>,line.<span style="color:#9900CC;">length</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot; |n&quot;</span>
		<span style="color:#9966CC; font-weight:bold;">end</span>
	<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	<span style="color:#0000FF; font-weight:bold;">return</span> final_page
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
final_page=<span style="color:#996600;">&quot;&quot;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># output some dokuwiki thing</span>
final_page <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#996600;">&quot;===== Classes disponibles =====n&quot;</span>
final_page <span style="color:#006600; font-weight:bold;">+</span>=  <span style="color:#996600;">&quot;n&quot;</span>
final_page <span style="color:#006600; font-weight:bold;">+</span>=  <span style="color:#996600;">&quot;^ Nom de la classe ^ Description rapide ^ Infos supplémentaires ^n&quot;</span>
&nbsp;
basedirs.<span style="color:#9900CC;">each</span><span style="color:#006600; font-weight:bold;">&#123;</span> |basedir|
	<span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>basedir<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">entries</span>.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |entry|
		<span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">file</span>? basedir<span style="color:#006600; font-weight:bold;">+</span><span style="color:#996600;">&quot;/&quot;</span><span style="color:#006600; font-weight:bold;">+</span>entry <span style="color:#9966CC; font-weight:bold;">then</span>
			final_page=doku_class<span style="color:#006600; font-weight:bold;">&#40;</span>basedir<span style="color:#006600; font-weight:bold;">+</span><span style="color:#996600;">&quot;/&quot;</span><span style="color:#006600; font-weight:bold;">+</span>entry,final_page<span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#9966CC; font-weight:bold;">end</span>
	<span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
server.<span style="color:#9900CC;">call2</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;wiki.putPage&quot;</span>, destination_page, final_page, <span style="color:#996600;">&quot;&quot;</span>, 0<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.rottenbytes.info/?feed=rss2&amp;p=176</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>cd /etc/puppet &amp;&amp; publish</title>
		<link>http://www.rottenbytes.info/?p=156</link>
		<comments>http://www.rottenbytes.info/?p=156#comments</comments>
		<pubDate>Mon, 22 Jun 2009 11:57:08 +0000</pubDate>
		<dc:creator>Nico</dc:creator>
				<category><![CDATA[BOFH Life]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[SysAdmin]]></category>

		<guid isPermaLink="false">http://www.rottenbytes.info/?p=156</guid>
		<description><![CDATA[ J&#8217;en avais parlé il y a quelques temps avec des lutins donc le voici, mon /etc/puppet. Ne vous attendez pas à quelque chose d&#8217;exceptionnel puisque ça ne suis pas les best practices, notamment le découpage en modules. Accessoirement certaines classes ont besoin d&#8217;être réécrites (souvent les premières que j&#8217;ai conçues).
Sont inclus mon script d&#8217;external [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-thumbnail wp-image-54" title="kermit" src="http://www.rottenbytes.info/wp-content/uploads/2009/01/kermit.jpg" alt="" width="108" height="127" /> J&#8217;en avais parlé il y a quelques temps avec des lutins donc le voici, mon /etc/puppet. Ne vous attendez pas à quelque chose d&#8217;exceptionnel puisque ça ne suis pas les best practices, notamment le découpage en modules. Accessoirement certaines classes ont besoin d&#8217;être réécrites (souvent les premières que j&#8217;ai conçues).</p>
<p>Sont inclus mon script d&#8217;external node et le script ext_lookup de Volcane (de #puppet, crédits à l&#8217;intérieur). La partie fichiers est vide car trop relou de chercher les trucs à ne pas divulguer, mais la structure est là.</p>
<p>Have fun.</p>
<p><a rel="attachment wp-att-157" href="http://www.rottenbytes.info/?attachment_id=157">Archive /etc/puppet</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rottenbytes.info/?feed=rss2&amp;p=156</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Puppet + Mongrel : follow up</title>
		<link>http://www.rottenbytes.info/?p=147</link>
		<comments>http://www.rottenbytes.info/?p=147#comments</comments>
		<pubDate>Fri, 22 May 2009 06:06:38 +0000</pubDate>
		<dc:creator>Nico</dc:creator>
				<category><![CDATA[Puppet]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[mongrel]]></category>

		<guid isPermaLink="false">http://www.rottenbytes.info/?p=147</guid>
		<description><![CDATA[ Petite suite à mon précédent billet sur l&#8217;utilisation d&#8217;un LB devant puppet. En 0.24.5, il existe un bug gênant si vous utilisez les external nodes : personnellement la conf des nodes est stockées dans une base mysql et c&#8217;est un script qui me sort le YAML correspond à la config.
Pour résoudre ce bug qui [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-thumbnail wp-image-54" title="kermit" src="http://www.rottenbytes.info/wp-content/uploads/2009/01/kermit.jpg" alt="" width="108" height="127" /> Petite suite à mon précédent billet sur l&#8217;utilisation d&#8217;un LB devant puppet. En 0.24.5, il existe un <a title="Bug #1095" href="http://projects.reductivelabs.com/issues/1095">bug gênant</a> si vous utilisez les external nodes : personnellement la conf des nodes est stockées dans une base mysql et c&#8217;est un script qui me sort le YAML correspond à la config.</p>
<p>Pour résoudre ce bug qui laisse les connexions en CLOSE_WAIT (cf le netstat) je vous conseille vivement de passer en version 0.24.8. Via du pinning apt cela ne pose aucun soucis.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rottenbytes.info/?feed=rss2&amp;p=147</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
