<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Some Softwaremanagement</title>
	<atom:link href="http://berndadamowicz.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://berndadamowicz.wordpress.com</link>
	<description>Hints and information about all aspects of software management.</description>
	<lastBuildDate>Fri, 24 Feb 2012 20:54:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='berndadamowicz.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Some Softwaremanagement</title>
		<link>http://berndadamowicz.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://berndadamowicz.wordpress.com/osd.xml" title="Some Softwaremanagement" />
	<atom:link rel='hub' href='http://berndadamowicz.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Automated Build of RCP Artifacts with Maven Tycho &#8211; A field report (Part 2)</title>
		<link>http://berndadamowicz.wordpress.com/2012/02/21/automated-build-of-rcp-artifacts-with-maven-tycho-a-field-report-part-2/</link>
		<comments>http://berndadamowicz.wordpress.com/2012/02/21/automated-build-of-rcp-artifacts-with-maven-tycho-a-field-report-part-2/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 19:54:02 +0000</pubDate>
		<dc:creator>Sandra Kosmalla</dc:creator>
				<category><![CDATA[Maven]]></category>
		<category><![CDATA[Tycho]]></category>
		<category><![CDATA[Maven Tycho]]></category>

		<guid isPermaLink="false">http://berndadamowicz.wordpress.com/?p=235</guid>
		<description><![CDATA[In my last post of this serie, I described how to solve the dependency problem. In this post, I will describe how to build Eclipse Plugin and Eclipse Feature with Maven Tycho and which problems I have. POM Definition The procedure for both Eclipse artifacts is similar. In both, you have to insert a pom.xml [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=235&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my last post of this serie, I described how to solve the dependency problem. In this post, I will describe how to build Eclipse Plugin and Eclipse Feature with Maven Tycho and which problems I have.</p>
<h3>POM Definition</h3>
<p>The procedure for both Eclipse artifacts is similar. In both, you have to insert a <em>pom.xml</em> and fill it with the Maven coordinate (group id, artifact id and version) and the packaging type. But there exists some rules about the content.</p>
<p>The packaging type is depended by what Eclipse artifact should be built:</p>
<table>
<tbody>
<tr>
<th>Eclipse Artifact</th>
<th>Packaging Type</th>
</tr>
<tr>
<td>Eclipse Plugin</td>
<td>eclipse-plugin</td>
</tr>
<tr>
<td>Eclipse Feature</td>
<td>eclipse-feature</td>
</tr>
</tbody>
</table>
<p>The version specification in the POM is depended by the version specification in the manifest (in case of Eclipse plugin) and by the version specification in the<em> feature.xml</em> (in case of Eclipse feature) respectively:</p>
<table>
<tbody>
<tr>
<th>MANIFEST.MF / feature.xml</th>
<th>pom.xml</th>
<th>Description</th>
</tr>
<tr>
<td>1.5.1.qualifier</td>
<td>1.5.1-SNAPSHOT</td>
<td>Development version</td>
</tr>
<tr>
<td>1.5.1</td>
<td>1.5.1</td>
<td>Release version</td>
</tr>
</tbody>
</table>
<p>The specification of the artifact id in the POM must be equal like  the bundle symbolic name in the manifest (in case of Eclipse plugin) and by the specification of the id in the <em>feature.xml</em> (in case of Eclipse feature) respectively. That&#8217;s all you need to define the <em>pom.xml</em>. Then call only <em>mvn clean install</em> and the Eclipse artifact is built by Maven Tycho.</p>
<h3>Troubleshooting</h3>
<p><em></em><em></em>I met two problems during the introduction of Maven Tycho for the building of Eclipse plugins. The first problem was that Maven Tycho sometimes throws a NullPointerException during the read-out of the manifest file. The reason is that a blank must be between the colon, that follows after the manifest header, and the command.</p>
<p><pre class="brush: plain;">
# Don't
Import-Package:com.library.*

# Do
Import-Package: com.library.*
</pre></p>
<p>The second problem was that Maven Tycho throws compiler error althought everything is alright in Eclipse. The analyse of the error message shows that the command for the <em>Import-Package</em> in the manifest is not completed.  A second analyse shows that package names of used Eclipse RCP artifacts are missing. After adding these missing package names in the manifest, Maven Tycho builds without error. But this also means that Eclipse does not generate the manifest osgi-compliantly.</p>
<br />Filed under: <a href='http://berndadamowicz.wordpress.com/category/maven/'>Maven</a>, <a href='http://berndadamowicz.wordpress.com/category/tycho/'>Tycho</a> Tagged: <a href='http://berndadamowicz.wordpress.com/tag/maven-tycho/'>Maven Tycho</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/berndadamowicz.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/berndadamowicz.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/berndadamowicz.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/berndadamowicz.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/berndadamowicz.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/berndadamowicz.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/berndadamowicz.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/berndadamowicz.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/berndadamowicz.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/berndadamowicz.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/berndadamowicz.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/berndadamowicz.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/berndadamowicz.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/berndadamowicz.wordpress.com/235/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=235&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://berndadamowicz.wordpress.com/2012/02/21/automated-build-of-rcp-artifacts-with-maven-tycho-a-field-report-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a71ceddb4103aea1f6c3087d88e9b462?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">skosmalla</media:title>
		</media:content>
	</item>
		<item>
		<title>Recognize Puppet Managed Files &#8211; Part 2</title>
		<link>http://berndadamowicz.wordpress.com/2012/01/16/recognize-puppet-managed-files-part-2/</link>
		<comments>http://berndadamowicz.wordpress.com/2012/01/16/recognize-puppet-managed-files-part-2/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 11:55:00 +0000</pubDate>
		<dc:creator>Bernd Adamowicz</dc:creator>
				<category><![CDATA[Puppet]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[ERB templates]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[VIM]]></category>

		<guid isPermaLink="false">http://berndadamowicz.wordpress.com/?p=242</guid>
		<description><![CDATA[Recognize Puppet Managed Files &#8211; Part 2 In the first part I&#8217;ve described the basic usage and the installation with Puppet of Chris Jones&#8217; TangledStrings plugin for vim. You may want to refer to this post before; it&#8217;s found here: Recognize Puppet Managed Files &#8211; Part 1. Now this article is about a different way [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=242&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Recognize Puppet Managed Files &#8211; Part 2</h1>
<p>In the first part I&#8217;ve described the basic usage and the installation with Puppet of <a href="https://launchpad.net/tangledstrings" title="TangledStrings Plugin" target="_blank">Chris Jones&#8217; TangledStrings plugin for vim</a>. You may want to refer to this post before; it&#8217;s found here: <a href="http://berndadamowicz.wordpress.com/2011/12/30/recognize-puppet-managed-files/" title="Recognize Puppet Managed Files – Part&nbsp;1">Recognize Puppet Managed Files &#8211; Part 1</a>.</p>
<p>Now this article is about a different way of installing the plugin with Puppet. The reason for this alternative is to make it possible also for non-root users to use the plugin. As per default this is not possible, since the <i>TangledStrings</i> plugin needs read access to the yaml file(s) below <i>/var/lib/puppet/client_yaml/catalog</i>. Here Puppet stores a yaml file which contains all managed resources. But this file will be only readable by user <i>Puppet</i> and <i> root</i>.</p>
<p>Additionally there are some hard-wired strings inside the plugin once it is installed. They contain user specific information. So we need to find a way to make those strings dynamic and fill them with the correct user information. I will describe both, accessing the yaml file as well as the dynamic generation of the user data here.</p>
<p><strong>Accessing the Yaml data</strong><br />
This part is quite easy to accomplish. Some analysing turned out that these files/directories were preventing a normal user from accessing the file:</p>
<ul>
<li>/var/lib/puppet/client_yaml</li>
<li>/var/lib/puppet/client_yaml/catalog</li>
<li>/var/lib/puppet/client_yaml/catalog/your.host.here.yaml</li>
</ul>
<p>I checked this by using the same command the plugin is using:<br />
<pre class="brush: bash;">
grep -h title /var/lib/puppet/client_yaml/catalog/*.yaml | awk '{ print $2 }' | grep '^/' 2&gt;/dev/null
</pre><br />
Issuing this command as the user you want the plugin to be executed will give you a <i>permission denied</i> error message as long as there are no sufficient access rights.</p>
<p>Finally I turned the manual <i>chmod</i> commands into an appropriate Puppet configuration:</p>
<p><pre class="brush: ruby;">
  file {'/var/lib/puppet/client_yaml':
    ensure =&gt; directory,
    mode =&gt; 0755,
  }
  
  file {'/var/lib/puppet/client_yaml/catalog':
    ensure =&gt; directory,
    mode =&gt; 0755,
  }
  
  file {&quot;/var/lib/puppet/client_yaml/catalog/${fqdn}.yaml&quot;:
    ensure =&gt; file,
    mode =&gt; 0644,
  }
</pre></p>
<p><strong>Using an ERB template for configuring the plugin</strong><br />
In the <a href="http://berndadamowicz.wordpress.com/2011/12/30/recognize-puppet-managed-files/" title="Recognize Puppet Managed Files – Part&nbsp;1">first part</a> of this post I simply copied the extracted plugin as a file resource to my Puppet agents. The structure of the installed plugin looks like this:</p>
<p><pre class="brush: bash;">
[root@somehost ~]# tree .vim
.vim
├── doc
│&amp;nbsp;&amp;nbsp; ├── tags
│&amp;nbsp;&amp;nbsp; └── tangledstrings.txt
├── plugin
│&amp;nbsp;&amp;nbsp; ├── tangledstrings.vba
│&amp;nbsp;&amp;nbsp; └── tangledstrings.vim
└── .VimballRecord

2 directories, 5 files
[root@somehost ~]#
</pre></p>
<p>If you look at the file <i>.VimballRecord</i> you will the see the user specific strings I mentioned:</p>
<p><pre class="brush: bash;">
tangledstrings.vba: call delete('/root/.vim/plugin/tangledstrings.vim')|call delete('/root/.vim/doc/tangledstrings.txt')
</pre></p>
<p>Obviously the user&#8217;s home directory is hard-coded there. In Puppet making a string dynamic is a straightforward issue. So I simply turned file <i>.VimballRecord</i> into an ERB template <i>VimballRecord.erb</i>. The content of this template looks like this:</p>
<p><pre class="brush: bash;">
tangledstrings.vba: call delete('&lt;%= user_home %&gt;/.vim/plugin/tangledstrings.vim')|call delete('&lt;%= user_home %&gt;/.vim/doc/tangledstrings.txt')
</pre></p>
<p>The <i>user_home</i> variable will be replaced by Puppet with the correct user&#8217;s home directory. Of course we need the appropriate configuration inside Puppet&#8217;s manifest file. I&#8217;m showing only the relevant parts here:</p>
<p><pre class="brush: ruby;">

  $youruser_home=&quot;/home/youruser&quot;
  
  configure_vim { &quot;youruser&quot;: 
    group =&gt; &quot;yourgroup&quot;,
    user_home =&gt; &quot;${youruser_home}&quot;,
  }
  
  configure_vim { &quot;root&quot;: 
    group =&gt; &quot;root&quot;,
    user_home =&gt; &quot;/root&quot;,
  }
  
  define configure_vim($user_home, $group) {
  
    file {&quot;$user_home/.vim&quot;:
      ensure =&gt; directory,
      source =&gt; 'puppet:///modules/unix-common/vim',
      recurse =&gt; true,
      purge =&gt; false,
      group =&gt; &quot;${group}&quot;,
      owner =&gt; &quot;${name}&quot;,
      mode =&gt; 0755,
    }
  
    file {&quot;$user_home/.vim/.VimballRecord&quot;:
      ensure =&gt; file,
      content =&gt; template('unix-common/VimballRecord.erb'),
      recurse =&gt; true,
      purge =&gt; false,
      group =&gt; &quot;${group}&quot;,
      owner =&gt; &quot;${name}&quot;,
      mode =&gt; 0755,
      force =&gt; true,
    }
  }
</pre></p>
<p>This way one will always have an individually configured user for the plugin. Beware that you need to install also the rest of the plugin&#8217;s files. I&#8217;ve described this in the <a href="http://berndadamowicz.wordpress.com/2011/12/30/recognize-puppet-managed-files/" title="Recognize Puppet Managed Files – Part 1">first part</a> of this post.</p>
<p><strong>Verifying</strong><br />
If everything went well and you open a Puppet managed file, you will see a warning message like this one:<br />
<div id="attachment_250" class="wp-caption alignleft" style="width: 414px"><a href="http://berndadamowicz.files.wordpress.com/2012/01/screen-tangledstrings1.jpg"><img src="http://berndadamowicz.files.wordpress.com/2012/01/screen-tangledstrings1.jpg?w=519" alt="Tangledstrings warning message." title="screen.tangledstrings"   class="size-full wp-image-250" /></a><p class="wp-caption-text">Warning message displayed when a Puppet managed file is opened.</p></div></p>
<br />Filed under: <a href='http://berndadamowicz.wordpress.com/category/puppet/'>Puppet</a>, <a href='http://berndadamowicz.wordpress.com/category/vim/'>vim</a> Tagged: <a href='http://berndadamowicz.wordpress.com/tag/erb-templates/'>ERB templates</a>, <a href='http://berndadamowicz.wordpress.com/tag/grep/'>grep</a>, <a href='http://berndadamowicz.wordpress.com/tag/puppet/'>Puppet</a>, <a href='http://berndadamowicz.wordpress.com/tag/vim-2/'>VIM</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/berndadamowicz.wordpress.com/242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/berndadamowicz.wordpress.com/242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/berndadamowicz.wordpress.com/242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/berndadamowicz.wordpress.com/242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/berndadamowicz.wordpress.com/242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/berndadamowicz.wordpress.com/242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/berndadamowicz.wordpress.com/242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/berndadamowicz.wordpress.com/242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/berndadamowicz.wordpress.com/242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/berndadamowicz.wordpress.com/242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/berndadamowicz.wordpress.com/242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/berndadamowicz.wordpress.com/242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/berndadamowicz.wordpress.com/242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/berndadamowicz.wordpress.com/242/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=242&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://berndadamowicz.wordpress.com/2012/01/16/recognize-puppet-managed-files-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7b162108ae0b9ce384456b5461da59ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">berndadamowicz</media:title>
		</media:content>

		<media:content url="http://berndadamowicz.files.wordpress.com/2012/01/screen-tangledstrings1.jpg" medium="image">
			<media:title type="html">screen.tangledstrings</media:title>
		</media:content>
	</item>
		<item>
		<title>Automated Build of RCP Artifacts with Maven Tycho &#8211; A field report (Part 1)</title>
		<link>http://berndadamowicz.wordpress.com/2012/01/14/automated-build-of-rcp-artifacts-with-maven-tycho-a-field-report-part-1/</link>
		<comments>http://berndadamowicz.wordpress.com/2012/01/14/automated-build-of-rcp-artifacts-with-maven-tycho-a-field-report-part-1/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 18:22:20 +0000</pubDate>
		<dc:creator>Sandra Kosmalla</dc:creator>
				<category><![CDATA[Maven]]></category>
		<category><![CDATA[Tycho]]></category>
		<category><![CDATA[Maven Tycho]]></category>

		<guid isPermaLink="false">http://berndadamowicz.wordpress.com/?p=105</guid>
		<description><![CDATA[This post serie should not be a tutorial for Maven Tycho. You can find many tutorials in the web (see for example [2] and [3]). This post serie should be a field report about the problems during the introduction of Maven Tycho. Why Maven Tycho? One requirement is that we can use Maven artifacts. So [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=105&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This post serie should not be a tutorial for Maven Tycho. You can find many tutorials in the web (see for example [2] and [3]). This post serie should be a field report about the problems during the introduction of Maven Tycho.</p>
<h3>Why Maven Tycho?</h3>
<p>One requirement is that we can use Maven artifacts. So it seems obvious to search after a solution based on Maven.  After a search in the web, two Maven plugins are noticed:</p>
<ul>
<li>PDE Maven Plugin ([7]): This plugin builds the RCP artifacts with the help of a generated Ant script by Eclipse. But this generated Ant script is error-prone.</li>
<li>Maven Tycho Plugin ([1]): Very young plugin to build RCP artifacts (current version 0.13.0), but the community is very active. It tries to build RCP artifacts  in the similiar way than Eclipse.</li>
</ul>
<h3>The Proceeding</h3>
<p>During working the tutorials out the impression occurs that the main problem is to solve the dependency problem. So this is the first task for the introduction of Maven Tycho.</p>
<h3>Solution of the dependency problem</h3>
<p>In Maven the dependencies are declared in the POM file. In Eclipse the dependencies are declared by a target definition file. The goal is to merge these both worlds.  Maven Tycho enables Maven to build against a pre-defined target definition file.</p>
<p>The next question is where the dependecies come from.  Maven&#8217;s solution is the Maven Repository.  Eclipse has its own solution, P2 repository.  In Eclipse&#8217;s target definition file you can specify an URL to a P2 repository and Eclipse searchs after the needed dependencies, automatically.</p>
<p>A further requirement is that the Maven repository can still use. The reason is that our server artifacts are stored in a Maven repository and the communication between client and server is via Hessian, so some artifacts are needed by client and server. Furthermore, many third party libraries are only available in a Maven repository.</p>
<p>All examples in the tutorial work only with P2 repositories. But the introducing of a P2 repository is not an option, because then two repositories have to be administered.</p>
<h4>First Approach &#8211; Define a Target Definition File with the Type  &#8216;Directory&#8217;</h4>
<p>The idea of this approach is that you can define a folder with jars  (that are the dependencies)  in the target definition file. So it seems that the problem can be reduced to how I get the dependencies to this folder.</p>
<p>This problem can be solved by the Maven Dependency Plugin ([9]). It has the goal <em>copy-dependencies</em>. This goal copies all dependecies that are declared in the <em>&lt;dependencies&gt;</em>-element of the pom file to a declared output directory. The configuration of the dependency plugin could look like the following one:</p>
<p><pre class="brush: xml;">
&lt;plugin&gt;
 &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
 &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
 &lt;version&gt;2.3&lt;/version&gt;
 &lt;executions&gt;
  &lt;execution&gt;
   &lt;id&gt;copy-dependencies&lt;/id&gt;
   &lt;phase&gt;process-resources&lt;/phase&gt;
   &lt;goals&gt;
    &lt;goal&gt;copy-dependencies&lt;/goal&gt;
   &lt;/goals&gt;
   &lt;configuration&gt;
    &lt;excludeTransitive&gt;true&lt;/excludeTransitive&gt;
    &lt;outputDirectory&gt;${project.build.directory}/plugins&lt;/outputDirectory&gt;
   &lt;/configuration&gt;
  &lt;/execution&gt;
 &lt;/executions&gt;
&lt;/plugin&gt;
</pre></p>
<p>This solution works well in Eclipse, but not in with Maven&#8217;s<em> mvn clean install</em>, because Maven Tycho doesn&#8217;t support target type &#8216;Directory&#8217;, only the target type &#8216;Software Site&#8217;. So this solution doesn&#8217;t work for us.</p>
<h4>Second Approach &#8211; A solution based on Maven&#8217;s &#8216;pom-first&#8217; approach</h4>
<p>With Maven Tycho, you can define that the RCP artifacts should be built against the dependencies that are defined in the POM (old-known Maven way).</p>
<p><pre class="brush: xml;">
&lt;plugin&gt;
&lt;groupId&gt;org.eclipse.tycho&lt;/groupId&gt;
&lt;artifactId&gt;target-platform-configuration&lt;/artifactId&gt;
&lt;version&gt;0.13.0&lt;/version&gt;
&lt;configuration&gt;
&lt;pomDependencies&gt;consider&lt;/pomDependencies&gt;
&lt;/configuration&gt;
&lt;/plugin&gt;

</pre></p>
<p>With Maven Tycho, the build works fine. But in Eclipse you cannot work in Eclipse-known way, because it has not the needed dependencies. I thought I could solve this problem with the Maven Eclipse Plugin and its goal <em>eclipse:eclipse</em>. This plugin generates all needed Eclipse files but the dependencies are generated in the <em>Java Build Path</em> named <em>Referenced Library</em>. But Eclipse needs the dependencies for the RCP plugin development in the <em>Java Build Path</em> named <em>Plug-in Dependencies</em>. Next try!</p>
<h4>Third Approach &#8211; Nexus P2 Repository Plugin</h4>
<p>A further research results that Nexus OSS should get a new plugin that can simulate the access to a Maven repository whether it would be a P2 repository (P2 proxy) (see [4]). This plugin is an experimental feature at the moment, so you can only use the SNAPSHOT version of this plugin. Unfortunately, the SNAPSHOT version (mid december 2011) that I used did not work with Nexus OSS version 1.9.2.2. But I think this would be a good idea for this problem.</p>
<p><strong>Fourth Approach &#8211; Generation of a Local P2 Repository</strong></p>
<p>A hint in the Tycho user mailing list (see [5]) helps me to find this approach. It exits a Maven Tycho plugin (see [6]), that can generate a P2 repository from a directory with a bunch of bundles.  In the first approach, we used the Maven Dependency Plugin to copy all needed dependencies in a directory. For this approach I combine these two plugins with two another plugins to build a local P2 repository.</p>
<p>By the Maven Dependency Plugin all dependencies are copied to a directory named <em>plugins</em>. The Tycho P2 Extra Plugin can generate from this directory a local P2 repository. Unfortunately, this plugin does not generate the needed <em>feature.jar</em>. But without this jar Eclipse does not recognize that we have here a P2 repository (an introduction to the P2 repository you can find in [10]).  So we have to build this jar.</p>
<p>We create a new Maven project with the packaging option <em>jar</em>. In this project, there is only one file: <em>feature.xml</em>. In this xml file the name of the bundles of the <em>plugins</em>  directory are stored. The next code snippet shows an example for this entry:</p>
<p><pre class="brush: xml;">

&lt;plugin
id=&quot;org.eclipse.core.contenttype&quot;
download-size=&quot;0&quot;
install-size=&quot;0&quot;
version=&quot;3.4.100.v20110423-0524&quot;
unpack=&quot;false&quot;/&gt;

</pre></p>
<p>Then this new generated <em>feature.jar</em> are copied by the Maven Dependency Plugin to the directory <em>feature</em>s. Now with these two directories (<em>features</em> and <em>plugins</em>), the Tycho P2 Extra Plugin can generate a  local P2 repository that are recognized by Eclipse.</p>
<p>The next problem is that the target definition file accepts only absolute path for the targret type &#8216;Software Site&#8217;. But we want a target definition file that is independent from the platform. So we save a target definition file with a token for the location of the local P2 repository in <em>src/main/resources</em>. During the Maven build this token are replaced by absolute platform-dependent path to the location of the local P2 repository. This replacement is done by the Maven Replacer Plugin ([11]). The next code snippet shows the whole plugin configuration for the above described solution:</p>
<p><pre class="brush: xml;">

&lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
&lt;version&gt;2.3&lt;/version&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;id&gt;copy-dependencies&lt;/id&gt;
&lt;phase&gt;process-resources&lt;/phase&gt;
&lt;goals&gt;
&lt;goal&gt;copy-dependencies&lt;/goal&gt;
&lt;/goals&gt;
&lt;configuration&gt;
&lt;excludeTransitive&gt;true&lt;/excludeTransitive&gt;
&lt;outputDirectory&gt;${project.build.directory}/source/plugins&lt;/outputDirectory&gt;
&lt;/configuration&gt;
&lt;/execution&gt;
&lt;execution&gt;
&lt;id&gt;copy-feature&lt;/id&gt;
&lt;phase&gt;process-resources&lt;/phase&gt;
&lt;goals&gt;
&lt;goal&gt;copy&lt;/goal&gt;
&lt;/goals&gt;
&lt;configuration&gt;
&lt;artifactItems&gt;
&lt;artifactItem&gt;
&lt;groupId&gt;skm.p2&lt;/groupId&gt;
&lt;artifactId&gt;repository.feature&lt;/artifactId&gt;
&lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
&lt;type&gt;jar&lt;/type&gt;
&lt;overWrite&gt;true&lt;/overWrite&gt;
&lt;outputDirectory&gt;${project.build.directory}/source/features&lt;/outputDirectory&gt;
&lt;/artifactItem&gt;
&lt;/artifactItems&gt;
&lt;/configuration&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
&lt;version&gt;2.5&lt;/version&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;id&gt;copy-target-definition&lt;/id&gt;
&lt;phase&gt;process-resources&lt;/phase&gt;
&lt;goals&gt;
&lt;goal&gt;copy-resources&lt;/goal&gt;
&lt;/goals&gt;
&lt;configuration&gt;
&lt;resources&gt;
&lt;resource&gt;
&lt;directory&gt;src/main/resources&lt;/directory&gt;
&lt;includes&gt;
&lt;include&gt;${target.definition}&lt;/include&gt;
&lt;/includes&gt;
&lt;/resource&gt;
&lt;/resources&gt;
&lt;outputDirectory&gt;${project.build.directory}&lt;/outputDirectory&gt;
&lt;/configuration&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;
&lt;plugin&gt;
&lt;groupId&gt;com.google.code.maven-replacer-plugin&lt;/groupId&gt;
&lt;artifactId&gt;maven-replacer-plugin&lt;/artifactId&gt;
&lt;version&gt;1.4.0&lt;/version&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;phase&gt;prepare-package&lt;/phase&gt;
&lt;goals&gt;
&lt;goal&gt;replace&lt;/goal&gt;
&lt;/goals&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;configuration&gt;
&lt;ignoreMissingFile&gt;false&lt;/ignoreMissingFile&gt;
&lt;file&gt;target/${target.definition}&lt;/file&gt;
&lt;regex&gt;false&lt;/regex&gt;
&lt;replacements&gt;
&lt;replacement&gt;
&lt;token&gt;$repository.location$&lt;/token&gt;
&lt;value&gt;${project.build.directory}/repository/&lt;/value&gt;
&lt;/replacement&gt;
&lt;replacement&gt;
&lt;token&gt;\&lt;/token&gt;
&lt;value&gt;/&lt;/value&gt;
&lt;/replacement&gt;
&lt;/replacements&gt;
&lt;/configuration&gt;
&lt;/plugin&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.eclipse.tycho.extras&lt;/groupId&gt;
&lt;artifactId&gt;tycho-p2-extras-plugin&lt;/artifactId&gt;
&lt;version&gt;0.13.0&lt;/version&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;phase&gt;prepare-package&lt;/phase&gt;
&lt;goals&gt;
&lt;goal&gt;publish-features-and-bundles&lt;/goal&gt;
&lt;/goals&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;configuration&gt;
&lt;compress&gt;false&lt;/compress&gt;
&lt;/configuration&gt;
&lt;/plugin&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.eclipse.tycho&lt;/groupId&gt;
&lt;artifactId&gt;tycho-p2-repository-plugin&lt;/artifactId&gt;
&lt;version&gt;0.13.0&lt;/version&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;phase&gt;package&lt;/phase&gt;
&lt;goals&gt;
&lt;goal&gt;archive-repository&lt;/goal&gt;
&lt;/goals&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
&lt;artifactId&gt;build-helper-maven-plugin&lt;/artifactId&gt;
&lt;version&gt;1.7&lt;/version&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;id&gt;attach-artifacts&lt;/id&gt;
&lt;phase&gt;package&lt;/phase&gt;
&lt;goals&gt;
&lt;goal&gt;attach-artifact&lt;/goal&gt;
&lt;/goals&gt;
&lt;configuration&gt;
&lt;artifacts&gt;
&lt;artifact&gt;
&lt;file&gt;target/${target.definition}&lt;/file&gt;
&lt;type&gt;target&lt;/type&gt;
&lt;classifier&gt;indigo&lt;/classifier&gt;
&lt;/artifact&gt;
&lt;/artifacts&gt;
&lt;/configuration&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;

</pre></p>
<p>In Eclipse, this generated target definition file works fine, but in Maven Tycho it does not work:  Before Maven Tycho builds the local P2 repository and the target definition file, it tries to build the RCP plugins against the not yet existing target definition file and the build failed.</p>
<p><strong>Fivth Approach and Final Solution &#8211; Combination of Dependency in the POM and Target Definition</strong></p>
<p>We know Maven works with in the POM defined dependencies, perfectly and Eclipse works with the target platform, perfectly. So the idea is to combine this two approaches, so that every tool can work in its perfect way. So I combine the first both approachs that are described in the above chapters.</p>
<p>All dependencies that are used by all RCP plugins are defined in the root project POM, so that every sub module that defines one RCP plugin is built against these dependencies and one sub module is for the building of the target definition file (this build is described in the first approach). Maven Tycho builds the RCP artifacts in the known Maven way and in Eclipse the RCP artifacts are developed with the generated target definition file.</p>
<h2>Links</h2>
<p>[1] <a title="Maven Tycho Home Page" href="http://www.eclipse.org/tycho/" target="_blank">Maven Tycho Home Page</a><br />
[2] <a href="http://mattiasholmqvist.se/2010/02/building-with-tycho-part-1-osgi-bundles/">Tutorial by Matthias Holmqvist &#8211; Good for the first introduction</a><br />
[3] <a href="http://it-republik.de/jaxenter/artikel/Eclipse-RCP-Anwendungen-mit-Maven-und-Tycho-bauen-4156.html">Tutorial with example (in German)</a><br />
[4] <a href="https://docs.sonatype.org/display/Nexus/Nexus+OSGi+Experimental+Features+-+P2+Repository+Plugin">Nexus P2 Repository Plugin (Experimental Feature)</a><br />
[5] <a title="Post Tycho Mailing List" href="http://dev.eclipse.org/mhonarc/lists/tycho-user/msg01422.html" target="_blank">Post on Tycho User Mailing List &#8211; How to build local P2 Repository</a><br />
[6] <a title="Tycho P2 Extra Plugin" href="https://docs.sonatype.org/display/TYCHO/Tycho-extras+-+FeaturesAndBundlesPublisher" target="_blank">Introduction to the Tycho-P2-Extra-Plugin</a><br />
[7] <a title="PDE Maven Plugin" href="http://mojo.codehaus.org/pde-maven-plugin/" target="_blank">PDE Maven Plugin</a><br />
[8] <a title="Hessian Protocol" href="http://en.wikipedia.org/wiki/Hessian_%28web_service_protocol%29" target="_blank">Hessian Protocol</a><br />
[9] <a title="Maven Dependency Plugin" href="http://maven.apache.org/plugins/maven-dependency-plugin/" target="_blank">Maven Dependency Plugin </a><br />
[10] <a title="Format p2 repository" href="http://eclipse.org/equinox/p2/repository_packaging.html#Repository" target="_blank">Introduction to the format of  P2 repositoy<br />
</a>[11] <a title="Maven Replacer Plugin" href="http://code.google.com/p/maven-replacer-plugin/" target="_blank">Maven Replacer Plugin</a></p>
<br />Filed under: <a href='http://berndadamowicz.wordpress.com/category/maven/'>Maven</a>, <a href='http://berndadamowicz.wordpress.com/category/tycho/'>Tycho</a> Tagged: <a href='http://berndadamowicz.wordpress.com/tag/maven-tycho/'>Maven Tycho</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/berndadamowicz.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/berndadamowicz.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/berndadamowicz.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/berndadamowicz.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/berndadamowicz.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/berndadamowicz.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/berndadamowicz.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/berndadamowicz.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/berndadamowicz.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/berndadamowicz.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/berndadamowicz.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/berndadamowicz.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/berndadamowicz.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/berndadamowicz.wordpress.com/105/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=105&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://berndadamowicz.wordpress.com/2012/01/14/automated-build-of-rcp-artifacts-with-maven-tycho-a-field-report-part-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a71ceddb4103aea1f6c3087d88e9b462?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">skosmalla</media:title>
		</media:content>
	</item>
		<item>
		<title>Removing Hosts from Stored Configurations</title>
		<link>http://berndadamowicz.wordpress.com/2012/01/04/removing-hosts-from-stored-configurations/</link>
		<comments>http://berndadamowicz.wordpress.com/2012/01/04/removing-hosts-from-stored-configurations/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 14:33:06 +0000</pubDate>
		<dc:creator>Bernd Adamowicz</dc:creator>
				<category><![CDATA[Configuration Management]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[Stored Configurations]]></category>

		<guid isPermaLink="false">http://berndadamowicz.wordpress.com/?p=209</guid>
		<description><![CDATA[Removing Hosts from Stored Configurations Once a host which has been integrated into Puppet along with stored configurations is removed again from Puppet, it has to be removed from the MySQL database which holds the data of the stored configurations as well. There&#8217;s no automatic deletion. This is not a big issue, but it might [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=209&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Removing Hosts from Stored Configurations</h1>
<p>Once a host which has been integrated into Puppet along with <i>stored configurations</i> is removed again from Puppet, it has to be removed from the MySQL database which holds the data of the stored configurations as well. There&#8217;s no automatic deletion.</p>
<p>This is not a big issue, but it might be interesting for those not familiar with MySQL or for those just want to have a quick solution.</p>
<p><strong>Login to MySQL</strong><br />
<pre class="brush: bash;">
[root@somehost ~]# mysql -u puppet -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g. 
Your MySQL connection id is 38160
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql&gt;
</pre></p>
<p><strong>Switch the database</strong><br />
<pre class="brush: bash;">
mysql&gt; use puppet;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql&gt; 
</pre></p>
<p><strong>Get the host&#8217;s ID.</strong><br />
<pre class="brush: bash;">
mysql&gt; select id,name from hosts where name like 'myhost%';
+----+--------------------------+
| id | name                     |   
+----+--------------------------+
| 40 | myhost.somedomain.net | 
+----+--------------------------+
1 row in set (0.00 sec)

mysql&gt;
</pre></p>
<p><strong>Delete the host&#8217;s resources using its ID.</strong><br />
<pre class="brush: bash;">
mysql&gt; delete from resources where host_id=40;
Query OK, 331 rows affected (0.14 sec)

mysql&gt; commit;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; 
</pre></p>
<p><strong>Delete the host.</strong><br />
<pre class="brush: bash;">
mysql&gt; delete from hosts where id=40;
Query OK, 1 row affected (0.02 sec)

mysql&gt; commit;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; 
</pre></p>
<p><strong>Leave MySQL</strong><br />
<pre class="brush: bash;">
mysql&gt; quit
Bye
[root@somehost ~]#
</pre></p>
<p>That&#8217;s it.</p>
<br />Filed under: <a href='http://berndadamowicz.wordpress.com/category/configuration-management/'>Configuration Management</a>, <a href='http://berndadamowicz.wordpress.com/category/mysql/'>MySQL</a>, <a href='http://berndadamowicz.wordpress.com/category/puppet/'>Puppet</a>, <a href='http://berndadamowicz.wordpress.com/category/stored-configurations/'>Stored Configurations</a> Tagged: <a href='http://berndadamowicz.wordpress.com/tag/mysql/'>MySQL</a>, <a href='http://berndadamowicz.wordpress.com/tag/puppet/'>Puppet</a>, <a href='http://berndadamowicz.wordpress.com/tag/stored-configurations/'>Stored Configurations</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/berndadamowicz.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/berndadamowicz.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/berndadamowicz.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/berndadamowicz.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/berndadamowicz.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/berndadamowicz.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/berndadamowicz.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/berndadamowicz.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/berndadamowicz.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/berndadamowicz.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/berndadamowicz.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/berndadamowicz.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/berndadamowicz.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/berndadamowicz.wordpress.com/209/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=209&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://berndadamowicz.wordpress.com/2012/01/04/removing-hosts-from-stored-configurations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7b162108ae0b9ce384456b5461da59ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">berndadamowicz</media:title>
		</media:content>
	</item>
		<item>
		<title>Recognize Puppet Managed Files &#8211; Part 1</title>
		<link>http://berndadamowicz.wordpress.com/2011/12/30/recognize-puppet-managed-files/</link>
		<comments>http://berndadamowicz.wordpress.com/2011/12/30/recognize-puppet-managed-files/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 20:27:48 +0000</pubDate>
		<dc:creator>Bernd Adamowicz</dc:creator>
				<category><![CDATA[Configuration Management]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[VIM]]></category>

		<guid isPermaLink="false">http://berndadamowicz.wordpress.com/?p=200</guid>
		<description><![CDATA[Recognize Puppet Managed Files On Puppet managed systems it might be interesting and sometimes even important to know, if a file is managed by Puppet, because manual changes will be overridden next time Puppet executes. There are some exceptions from this behavior, e.g. files below /var/spool/cron still allow manual changes. In any case, it would [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=200&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Recognize Puppet Managed Files</h1>
<p>On Puppet managed systems it might be interesting and sometimes even important to know, if a file is managed by Puppet, because manual changes will be overridden next time Puppet executes. There are some exceptions from this behavior, e.g. files below <i>/var/spool/cron</i> still allow manual changes. In any case, it would be nice to know if the file is managed by Puppet. Of course it&#8217;s good practice to have a header in every file from Puppet, but this may not be possible in every case.</p>
<p>I&#8217;m only using <a href="http://www.vim.org/" title="VIM" target="_blank">vim</a> on my machines and discovered a very nice plugin. It&#8217;s called <a href="https://launchpad.net/tangledstrings" title="Tangledstrings Plugin" target="_blank">Tangledstrings</a> by Chris Jones and displays a warning message once a file is opened or saved. However, it does of course not prevent from saving the file.</p>
<p>This plugin is both simple and awesome! So I&#8217;d like to share some of my experiences and the way I rolled out the plugin on my Puppet boxes.</p>
<p>Once the plugin is downloaded &#8211; it&#8217;s just a simple file &#8211; open it with vim:<br />
<pre class="brush: bash; light: true;">
[root@somehost ~]# vim tangledstrings.vba
</pre><br />
Then, inside vim, source the plugin in command mode by issuing:<br />
<pre class="brush: bash; light: true;">
:so %
</pre></p>
<p>Then you may quit vim or continue working as usual. However, looking at the directory structure below <i>~/.vim</i> brings up these files:<br />
<pre class="brush: bash; light: true;">
[root@somehost ~]# tree .vim
.vim
├── doc
├── tags
│ └── tangledstrings.txt
├── plugin
│ ├── tangledstrings.vba
│ └── tangledstrings.vim
└── .VimballRecord
</pre></p>
<p>For rolling out with Puppet, I simply copied this directory structure to the <i>files</i> directory of my <i>unix-common</i> module. A very common <i>file</i> resource then takes care of having everything in place on my machines:<br />
<pre class="brush: ruby; wrap-lines: false;">
file {&quot;/root/.vim&quot;:
    ensure =&gt; directory,
    source =&gt; 'puppet:///modules/unix-common/vim',
    recurse =&gt; true,
    purge =&gt; false,
    group =&gt; &quot;root&quot;,
    owner =&gt; &quot;root&quot;,
    mode =&gt; 0755,
  }
</pre><br />
Beware that I used user <i>root</i> for installing and rolling out the plugin. There&#8217;s some hard-wired user stuff inside the plugin after installing. So if you want to use it for other users, please refer to the second part of this post <a href="http://berndadamowicz.wordpress.com/2012/01/16/recognize-puppet-managed-files-part-2/" title="Recognize Puppet Managed Files – Part&nbsp;2">here</a>.</p>
<p><strong>Verifying</strong><br />
If everything went well and you open a Puppet managed file, you will see a warning message like this one:<br />
<div id="attachment_250" class="wp-caption alignleft" style="width: 414px"><a href="http://berndadamowicz.files.wordpress.com/2012/01/screen-tangledstrings1.jpg"><img src="http://berndadamowicz.files.wordpress.com/2012/01/screen-tangledstrings1.jpg?w=519" alt="Tangledstrings warning message." title="screen.tangledstrings"   class="size-full wp-image-250" /></a><p class="wp-caption-text">Warning message displayed when a Puppet managed file is opened.</p></div></p>
<p><strong>Credits</strong></p>
<ul>
<li>Thanks to Chris Jones who provided this plugin! He gives a short introduction on the plugin on his blog <a href="http://www.tenshu.net/2010/08/adventures-in-puppet-tangled-strings.html" title="Chris Jone's introduction on the Tangledstrings plugin." target="_blank">here</a>.</li>
<li>Download the plugin from its launchpad site <a href="https://launchpad.net/tangledstrings" title="Download Tangledstrings" target="_blank">here</a>.</li>
</ul>
<p>By the way: <a href="http://www.vim.org/" title="VIM" target="_blank">VIM</a> turned 20 this year (2011)! Congratulations!</p>
<br />Filed under: <a href='http://berndadamowicz.wordpress.com/category/configuration-management/'>Configuration Management</a>, <a href='http://berndadamowicz.wordpress.com/category/puppet/'>Puppet</a>, <a href='http://berndadamowicz.wordpress.com/category/vim/'>vim</a> Tagged: <a href='http://berndadamowicz.wordpress.com/tag/puppet/'>Puppet</a>, <a href='http://berndadamowicz.wordpress.com/tag/vim-2/'>VIM</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/berndadamowicz.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/berndadamowicz.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/berndadamowicz.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/berndadamowicz.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/berndadamowicz.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/berndadamowicz.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/berndadamowicz.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/berndadamowicz.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/berndadamowicz.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/berndadamowicz.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/berndadamowicz.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/berndadamowicz.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/berndadamowicz.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/berndadamowicz.wordpress.com/200/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=200&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://berndadamowicz.wordpress.com/2011/12/30/recognize-puppet-managed-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7b162108ae0b9ce384456b5461da59ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">berndadamowicz</media:title>
		</media:content>

		<media:content url="http://berndadamowicz.files.wordpress.com/2012/01/screen-tangledstrings1.jpg" medium="image">
			<media:title type="html">screen.tangledstrings</media:title>
		</media:content>
	</item>
		<item>
		<title>Monitoring Puppet &#8211; Part 3</title>
		<link>http://berndadamowicz.wordpress.com/2011/12/27/monitoring-puppet-part-3/</link>
		<comments>http://berndadamowicz.wordpress.com/2011/12/27/monitoring-puppet-part-3/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 15:17:34 +0000</pubDate>
		<dc:creator>Bernd Adamowicz</dc:creator>
				<category><![CDATA[Configuration Management]]></category>
		<category><![CDATA[Icinga]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[logfile]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[NRPE]]></category>
		<category><![CDATA[perl plugin]]></category>
		<category><![CDATA[puppet master]]></category>

		<guid isPermaLink="false">http://berndadamowicz.wordpress.com/?p=180</guid>
		<description><![CDATA[Monitoring Puppet &#8211; Part 3 Ever been concerned about the health of your Puppet agents? You know they are executing, but you don&#8217;t know if execution is successful? I&#8217;d like to show how to achieve this by monitoring the syslog of the Puppet machines. In case any errors occur during Puppet&#8217;s execution, the appropriate error [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=180&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Monitoring Puppet &#8211; Part 3</h1>
<p>Ever been concerned about the health of your Puppet agents? You know they are executing, but you don&#8217;t know if execution is successful? I&#8217;d like to show how to achieve this by monitoring the syslog of the Puppet machines. In case any errors occur during Puppet&#8217;s execution, the appropriate error messages will be logged to &#8211; most probably &#8211; <i>/var/log/messages</i>. So the only thing left to do is to scan this file for fishy patterns.</p>
<p>The best tool known to me is the NRPE plugin <a href="http://exchange.nagios.org/directory/Plugins/Log-Files/check_logfiles/details" title="check_logfiles plugin" target="_blank">check_logfiles</a>. It&#8217;s a powerful Perl plugin with many configuration options. I will not give an introduction on this plugin, but you will find the plugin&#8217;s <a href="http://berndadamowicz.wordpress.com/2011/12/07/keeping-puppet-dashboards-database-small/" title="check_logfiles website" target="_blank">website</a> useful. Instead I will simply show two examples of how I am monitoring my Puppet agents and my Puppet master machines.</p>
<p>For my agents, I have this command configuration inside my <i>nrpe.cfg</i>:<br />
<pre class="brush: bash; light: true;">
command[check_puppet_errors_agent]=/usr/lib64/nagios/plugins/check_logfiles -config /usr/lib64/nagios/plugins/check_puppet_errors_agent.conf
</pre></p>
<p>About the same for the masters:<br />
<pre class="brush: bash; light: true;">
command[check_puppet_errors_master]=/usr/lib64/nagios/plugins/check_logfiles -config /usr/lib64/nagios/plugins/check_puppet_errors_master.conf
</pre></p>
<p>As you can see, all the configuration stuff is done within the configuration file. Let&#8217;s start with the agent&#8217;s configuration <i>check_puppet_errors_agent.conf</i>:<br />
<pre class="brush: ruby; wrap-lines: false;">
$scriptpath = '/usr/bin';
$prescript = 'sudo';
$prescriptparams = 'setfacl -m u:$CL_USERNAME$:r-- /var/log/messages*';
@searches = ({
  tag =&gt; 'puppet-failing',
  rotation =&gt; 'loglog0log1',
  logfile =&gt; '/var/log/messages',
  criticalpatterns =&gt; [
     '.*Too\ many\ open\ files.*',
       '.*Could\ not\ retrieve\ catalog.*',
       '.*Retrieved\ certificate\ does\ not\ match\ private\ key.*',],
  okpatterns =&gt; ['.*puppetd.*Finished\ catalog\ run\ in.*'],
  options =&gt; 'noperfdata',
});
</pre><br />
Let&#8217;s look at the details:</p>
<ul>
<li>Line 1: Define the path to scripts being executed.</li>
<li>Line 2: The script to be executed before the actual check takes place.</li>
<li>Line 3: The parameters handed over to the prescript. Basically what is happening here is to grant access (setfacl) to all files matching <i>/var/log/messages</i> to the user this plugin is executed with. In my case this is <i>nrpe</i>. Beware that <i>$CL_USERNAME$</i> is replaced with the actual user name. You may want to check your <i>nrpe.cfg</i>.</li>
<li>Line 6: The log rotation method. This plugin is also capable of scanning rotated logs.</li>
<li>Line 7: The actual log file to scan.</li>
<li>Lines 8-11: These are the patterns which are used for indicating failed Puppet runs. Basically this is the sum of all error messages I detected manually while setting up all my agents. Of course one may add or remove patterns as desired.</li>
<li>Line 12: One run may fail, the next run may be OK again. In this case we don&#8217;t want to have any critical errors any more. That&#8217;s what the OK pattern is for.</li>
<li>Line 13: Disable performance data. (Admittedly I never had a closer look what performance data would be actually generated here.)</li>
</ul>
<p>The Puppet master is configured pretty much the same way. However there are a lot more error patterns which may occur on a master, so I will show only the patterns here:<br />
<pre class="brush: ruby; wrap-lines: false;">
  criticalpatterns =&gt; [
     '.*Too\ many\ open\ files.*',
       '.*Could\ not\ retrieve\ catalog.*',
       '.*Syntax\ error\ at.*of\ file.*',
       '.*Mysql\:\:Error.*',
       '.*MySQL\ server\ has\ gone\ away.*',
       '.*Could\ not\ read\ YAML\ data.*',
       '.*Could\ not\ run\ Puppet\ configuration\ client.*',
       '.*Parameter\ group\ failed.*Invalid\ group\ name.*'],
</pre></p>
<p>It is very important to allow user <i>nrpe</i> executing the <i>setfacl</i> command along with <i>sudo</i>. That&#8217;s why I have this line inside my <i>/etc/sudoers</i>:<br />
<pre class="brush: bash; light: true;">
nrpe    ALL=NOPASSWD:/usr/bin/setfacl
</pre></p>
<p>Of course all the configuration files as well as the <i>check_logfiles</i> plugin are maintained by Puppet itself. Everything is done using <i>stored configurations</i>, so every new Puppet agent attached to the system will establish its own monitoring. By the time of writing this, I had these checks running for several months now and it gives me a very reliable overview of my agent&#8217;s health as soon as I have a look at Icinga&#8217;s front end.</p>
<h2>Related topics</h2>
<p>Some other posts I made covering Puppet monitoring might also be interesting:</p>
<ul>
<li><a href="http://berndadamowicz.wordpress.com/2011/10/28/monitoring-puppet-part-1/" title="Monitoring Puppet – Part 1" target="_blank">Monitoring Puppet &#8211; Part 1</a> shows how to keep the clients alive and how to check proper execution using the master&#8217;s <i>/var/log/puppet/masterhttp.log</i> file.</li>
<li><a href="http://berndadamowicz.wordpress.com/2011/12/27/monitoring-puppet-part-2/" title="Monitoring Puppet – Part&nbsp;2" target="_blank">Monitoring Puppet &#8211; Part 2</a> describes how to monitor the execution intervals of a Puppet agent.</li>
</ul>
<br />Filed under: <a href='http://berndadamowicz.wordpress.com/category/configuration-management/'>Configuration Management</a>, <a href='http://berndadamowicz.wordpress.com/category/icinga/'>Icinga</a>, <a href='http://berndadamowicz.wordpress.com/category/nagios/'>Nagios</a>, <a href='http://berndadamowicz.wordpress.com/category/puppet/'>Puppet</a> Tagged: <a href='http://berndadamowicz.wordpress.com/tag/icinga/'>Icinga</a>, <a href='http://berndadamowicz.wordpress.com/tag/logfile/'>logfile</a>, <a href='http://berndadamowicz.wordpress.com/tag/monitoring/'>Monitoring</a>, <a href='http://berndadamowicz.wordpress.com/tag/nagios/'>Nagios</a>, <a href='http://berndadamowicz.wordpress.com/tag/nrpe/'>NRPE</a>, <a href='http://berndadamowicz.wordpress.com/tag/perl-plugin/'>perl plugin</a>, <a href='http://berndadamowicz.wordpress.com/tag/puppet/'>Puppet</a>, <a href='http://berndadamowicz.wordpress.com/tag/puppet-master/'>puppet master</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/berndadamowicz.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/berndadamowicz.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/berndadamowicz.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/berndadamowicz.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/berndadamowicz.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/berndadamowicz.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/berndadamowicz.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/berndadamowicz.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/berndadamowicz.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/berndadamowicz.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/berndadamowicz.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/berndadamowicz.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/berndadamowicz.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/berndadamowicz.wordpress.com/180/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=180&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://berndadamowicz.wordpress.com/2011/12/27/monitoring-puppet-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7b162108ae0b9ce384456b5461da59ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">berndadamowicz</media:title>
		</media:content>
	</item>
		<item>
		<title>Monitoring Puppet &#8211; Part 2</title>
		<link>http://berndadamowicz.wordpress.com/2011/12/27/monitoring-puppet-part-2/</link>
		<comments>http://berndadamowicz.wordpress.com/2011/12/27/monitoring-puppet-part-2/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 15:14:05 +0000</pubDate>
		<dc:creator>Bernd Adamowicz</dc:creator>
				<category><![CDATA[Configuration Management]]></category>
		<category><![CDATA[Icinga]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[nagios plugins]]></category>

		<guid isPermaLink="false">http://berndadamowicz.wordpress.com/?p=174</guid>
		<description><![CDATA[Monitoring Puppet &#8211; Part 2 As mentioned in one of my previous posts here, there are some more possibilities of observing the health of a Puppet agent. This one shows how I observe the state of an agent using its file /var/lib/puppet/state/state.yaml. Every time the Puppet agent executes, this file is being regenerated. By simply [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=174&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Monitoring Puppet &#8211; Part 2</h1>
<p>As mentioned in one of my previous posts <a title="Monitoring Puppet – Part&nbsp;1" href="http://berndadamowicz.wordpress.com/2011/10/28/monitoring-puppet-part-1/" target="_blank">here</a>, there are some more possibilities of observing the health of a Puppet agent. This one shows how I observe the state of an agent using its file <strong>/var/lib/puppet/state/state.yaml</strong>.</p>
<p>Every time the Puppet agent executes, this file is being regenerated. By simply checking the age of the file, one may get a hint if the agent has executed within a certain time. The NRPE plugin used for this check is the <a title="check_file_age plugin" href="https://www.monitoringexchange.org/wiki/Plugin:check_file_age" target="_blank">check_file_age</a> plugin.</p>
<p>The help screen gives all relevant information for configuring the plugin:</p>
<p><pre class="brush: bash;">
[root@somehost plugins]# ./check_file_age --help
check_file_age v1.4.15 (nagios-plugins 1.4.15)
...
Usage:
  check_file_age [-w ] [-c ] [-W ] [-C ] -f
  check_file_age [-h | --help]
  check_file_age [-V | --version]

    File must be no more than this many seconds old (default: warn 240 secs, crit 600)
    File must be at least this many bytes long (default: crit 0 bytes)
...
[root@somehost plugins]#
</pre></p>
<p>I wanted to have a warning issued once the client did not run for more than 35 minutes (2100 secs) and a critical error as soon as execution time was more than 65 minutes (3900 secs) ago. To achieve this, I added this line to the NRPE configuration file <em>nrpe.cfg</em>:</p>
<p><pre class="brush: bash; light: true;">
command[check_puppet_client_state_file]=/usr/lib64/nagios/plugins/check_file_age -w 2100 -c 3900 -f /var/lib/puppet/state/state.yaml
</pre></p>
<p>This check is then applied to every agent with an appropriate <em>stored configuration</em> manifest in Puppet:</p>
<p><pre class="brush: ruby;">
   @@nagios_service { &quot;check_puppet_client_state_file_${hostname}&quot;:
      use =&gt; &quot;generic-service&quot;,
      host_name =&gt; &quot;$fqdn&quot;,
      service_description =&gt; &quot;${prefix}Puppet client state file&quot;,
      check_command =&gt; &quot;check_nrpe!check_puppet_client_state_file&quot;,
      }
</pre></p>
<p>Beware that this check only indicates if the agent has executed. It <b>does not</b> detect any errors <i>while</i> executing. For detecting errors, you may want to have a look at this <a href="http://berndadamowicz.wordpress.com/2011/12/27/monitoring-puppet-part-3/" title="Monitoring Puppet – Part&nbsp;3" target="_blank">post</a> I made.</p>
<h2>Related topics</h2>
<p>I got several other posts covering the monitoring of Puppet which might be interesting:</p>
<ol>
<li><a href="http://berndadamowicz.wordpress.com/2011/10/28/monitoring-puppet-part-1/" title="Monitoring Puppet – Part&nbsp;1" target="_blank">Monitoring Puppet &#8211; Part 1</a> shows how to keep the clients alive and how to check proper execution using the master&#8217;s <i>/var/log/puppet/masterhttp.log</i> file.</li>
<li><a href="http://berndadamowicz.wordpress.com/2011/12/27/monitoring-puppet-part-3/" title="Monitoring Puppet – Part&nbsp;3" target="_blank">Monitoring Puppet &#8211; Part 3</a> describes how to scan syslog for Puppet errors.</li>
</ol>
<p>If you think this tip is useful and maybe if you applied it to your Puppet system, I&#8217;d be glad if you share your experiences and give some feedback. Thanks!</p>
<br />Filed under: <a href='http://berndadamowicz.wordpress.com/category/configuration-management/'>Configuration Management</a>, <a href='http://berndadamowicz.wordpress.com/category/icinga/'>Icinga</a>, <a href='http://berndadamowicz.wordpress.com/category/nagios/'>Nagios</a>, <a href='http://berndadamowicz.wordpress.com/category/puppet/'>Puppet</a> Tagged: <a href='http://berndadamowicz.wordpress.com/tag/icinga/'>Icinga</a>, <a href='http://berndadamowicz.wordpress.com/tag/monitoring/'>Monitoring</a>, <a href='http://berndadamowicz.wordpress.com/tag/nagios-plugins/'>nagios plugins</a>, <a href='http://berndadamowicz.wordpress.com/tag/puppet/'>Puppet</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/berndadamowicz.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/berndadamowicz.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/berndadamowicz.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/berndadamowicz.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/berndadamowicz.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/berndadamowicz.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/berndadamowicz.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/berndadamowicz.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/berndadamowicz.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/berndadamowicz.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/berndadamowicz.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/berndadamowicz.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/berndadamowicz.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/berndadamowicz.wordpress.com/174/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=174&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://berndadamowicz.wordpress.com/2011/12/27/monitoring-puppet-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7b162108ae0b9ce384456b5461da59ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">berndadamowicz</media:title>
		</media:content>
	</item>
		<item>
		<title>Make NRPE talk to rsyslog</title>
		<link>http://berndadamowicz.wordpress.com/2011/12/17/make-nrpe-talk-to-rsyslog/</link>
		<comments>http://berndadamowicz.wordpress.com/2011/12/17/make-nrpe-talk-to-rsyslog/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 00:05:16 +0000</pubDate>
		<dc:creator>Bernd Adamowicz</dc:creator>
				<category><![CDATA[Icinga]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[NRPE]]></category>
		<category><![CDATA[Syslog]]></category>
		<category><![CDATA[syslog daemon]]></category>

		<guid isPermaLink="false">http://berndadamowicz.wordpress.com/?p=137</guid>
		<description><![CDATA[Make NRPE talk to rsyslog Ever wondered why switching the NRPE daemon to debug mode has no effect in any log files at all? I did, a lot of times. You may have a configuration something like this in your nrpe.cfg file: Line 1 indicates it should log everything to the syslog daemon. Depending on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=137&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Make NRPE talk to rsyslog</h1>
<p>Ever wondered why switching the NRPE daemon to debug mode has no effect in any log files at all? I did, a lot of times. You may have a configuration something like this in your <i>nrpe.cfg</i> file:<br />
<pre class="brush: bash; highlight: [1,7];">
log_facility=daemon
pid_file=/var/run/nrpe.pid
server_port=5666
nrpe_user=nrpe
nrpe_group=nrpe
allowed_hosts=some.ip.address.here
debug=1
</pre></p>
<p>Line 1 indicates it should log everything to the syslog daemon. Depending on your system, this will most likely be the file <i>/var/log/messages</i> or something else depending on your log daemon. Line 7 should switch the NRPE daemon to debug mode and issue some more information than the usual standard output &#8211; but it does not.</p>
<p>My clients observed by Icinga were all running on RHEL6. So I decided to have a closer look at the syslog configuration. It turned out that <i>rsyslog</i> was running on my boxes. The configuration file for this log daemon is <i>/etc/rsyslog.conf</i>. Digging into the man pages and some &#8216;googling&#8217; I found out that something like this was missing inside this file:<br />
<pre class="brush: bash;">
*.debug    /var/log/debug
</pre></p>
<p>After adding this line and restarting the daemon with<br />
<pre class="brush: bash;">
[root@somehost ~]# service rsyslog restart
</pre><br />
I got all the debug information I was missing so far in <i>/var/log/debug</i>.</p>
<p>Even though this might be a little help when trying to find errors when executing remote Icinga/Nagios checks, this may not be sufficient. Maybe you will also have a look at another post I made which covers a very special case <a href="http://berndadamowicz.wordpress.com/2011/12/16/nrpe-and-selinux/" title="NRPE and&nbsp;SELinux" target="_blank">here</a> which covers a problem with failing remote checks caused by SELinux.</p>
<br />Filed under: <a href='http://berndadamowicz.wordpress.com/category/icinga/'>Icinga</a>, <a href='http://berndadamowicz.wordpress.com/category/nagios/'>Nagios</a>, <a href='http://berndadamowicz.wordpress.com/category/nrpe/'>NRPE</a>, <a href='http://berndadamowicz.wordpress.com/category/syslog/'>Syslog</a> Tagged: <a href='http://berndadamowicz.wordpress.com/tag/syslog-daemon/'>syslog daemon</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/berndadamowicz.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/berndadamowicz.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/berndadamowicz.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/berndadamowicz.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/berndadamowicz.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/berndadamowicz.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/berndadamowicz.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/berndadamowicz.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/berndadamowicz.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/berndadamowicz.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/berndadamowicz.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/berndadamowicz.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/berndadamowicz.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/berndadamowicz.wordpress.com/137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=137&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://berndadamowicz.wordpress.com/2011/12/17/make-nrpe-talk-to-rsyslog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7b162108ae0b9ce384456b5461da59ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">berndadamowicz</media:title>
		</media:content>
	</item>
		<item>
		<title>NRPE and SELinux</title>
		<link>http://berndadamowicz.wordpress.com/2011/12/16/nrpe-and-selinux/</link>
		<comments>http://berndadamowicz.wordpress.com/2011/12/16/nrpe-and-selinux/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 16:15:18 +0000</pubDate>
		<dc:creator>Bernd Adamowicz</dc:creator>
				<category><![CDATA[Configuration Management]]></category>
		<category><![CDATA[Icinga]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[NRPE]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[selinux]]></category>

		<guid isPermaLink="false">http://berndadamowicz.wordpress.com/?p=139</guid>
		<description><![CDATA[NRPE and SELinux Ever had an Unable to read output error when executing an Icinga/Nagios remote check using NRPE? I&#8217;m pretty sure you had since everyone working with NRPE will run into this error sooner or later. Most solutions are trivial (e.g. wrong file permissions) and I don&#8217;t want to repeat the few thousand posts [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=139&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>NRPE and SELinux</h1>
<p>Ever had an <i>Unable to read output</i> error when executing an Icinga/Nagios remote check using NRPE? I&#8217;m pretty sure you had since everyone working with NRPE will run into this error sooner or later. Most solutions are trivial (e.g. wrong file permissions) and I don&#8217;t want to repeat the few thousand posts already covering this issue here.</p>
<p>However in a very particular case I had today, I already had eliminated all the <i>usual suspects</i> and still was not able to execute the check from my Icinga host. The check that failed was a Perl file which is automatically rolled out by Puppet along with some other check plugins. On some hosts it worked, on some hosts not and I was not able to figure out what the actual cause was since everything was identical on all hosts. Besides the <i>Unable to read output</i> error message there was no additional information nowhere. Even not when turning on debugging for NRPE.</p>
<p>More or less accidentally I had a look at the SELinux configuration on that box:<br />
<pre class="brush: bash;">
[root@somehost plugins]# getenforce 
Enforcing
[root@somehost plugins]# 
</pre><br />
Then I checked another box where the check was executed successfully and it was set to <i>permissive</i>. So obviously the reason was found. For testing purposes I set SELinux on the failing host to permissive with this command:</p>
<p><pre class="brush: bash;">
[root@somehost plugins]# setenforce 0
[root@somehost plugins]# getenforce 
Permissive
[root@somehost plugins]#
</pre><br />
I executed the check and it worked as expected. No more error message!</p>
<p>Of course I did not want to have SELinux in permissive mode on that box so I made some investigations. First, I checked the SELinux settings on the failing file:<br />
<pre class="brush: bash; wrap-lines: false;">
[root@somehost plugins]# ls -Z check_mem.pl
-rwxr-xr-x. root root system_u:object_r:bin_t:s0       check_mem.pl
[root@somehost plugins]# 
</pre></p>
<p>Then I checked the settings of a file which was installed along with NRPE&#8217;s RPM:<br />
<pre class="brush: bash; wrap-lines: false;">
[root@somehost plugins]# ls -Z check_swap 
-rwxr-xr-x. root root system_u:object_r:nagios_system_plugin_exec_t:s0 check_swap
[root@somehost plugins]# 
</pre></p>
<p>Obviously the SELinux type was different. So I changed the settings of the failing plugin and made them identical with the above shown <i>check_swap</i>:<br />
<pre class="brush: bash; toolbar: false;">
[root@somehost plugins]# chcon system_u:object_r:nagios_system_plugin_exec_t:s0 check_mem.pl
</pre><br />
Of course I already had the overall SELinux setting of that machine set back to <i>enabled</i> by that time. Now I checked again and it still worked. So the final solution was found!</p>
<p>The last step was to have everything configured in Puppet. I never made SELinux stuff in Puppet before. But it turned out to be quite easy. Just use the arguments of the <i>chcon</i> command shown above and add the appropriate attributes to the file resource responsible for the check plugin like this:<br />
<pre class="brush: ruby; wrap-lines: false;">
  file { &quot;/usr/lib64/nagios/plugins/check_mem.pl&quot;:
    owner =&gt; &quot;root&quot;,
    group =&gt; &quot;root&quot;,
    mode =&gt; &quot;0755&quot; ,
    replace =&gt; true,
    source =&gt; &quot;puppet:///modules/icinga/check_mem.pl&quot;,
    require =&gt; Package[&quot;nagios-plugins-nrpe&quot;],
    seluser =&gt; &quot;system_u&quot;,
    selrole =&gt; &quot;object_r&quot;,
    seltype =&gt; &quot;nagios_system_plugin_exec_t&quot;,
    selrange =&gt; &quot;s0&quot;,
  }
</pre><br />
After committing this change I just had to sit back and wait until all red Icinga lights went off. Great thing, but hard to find out.</p>
<br />Filed under: <a href='http://berndadamowicz.wordpress.com/category/configuration-management/'>Configuration Management</a>, <a href='http://berndadamowicz.wordpress.com/category/icinga/'>Icinga</a>, <a href='http://berndadamowicz.wordpress.com/category/nagios/'>Nagios</a>, <a href='http://berndadamowicz.wordpress.com/category/nrpe/'>NRPE</a>, <a href='http://berndadamowicz.wordpress.com/category/puppet/'>Puppet</a> Tagged: <a href='http://berndadamowicz.wordpress.com/tag/nrpe/'>NRPE</a>, <a href='http://berndadamowicz.wordpress.com/tag/selinux/'>selinux</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/berndadamowicz.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/berndadamowicz.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/berndadamowicz.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/berndadamowicz.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/berndadamowicz.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/berndadamowicz.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/berndadamowicz.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/berndadamowicz.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/berndadamowicz.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/berndadamowicz.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/berndadamowicz.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/berndadamowicz.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/berndadamowicz.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/berndadamowicz.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=139&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://berndadamowicz.wordpress.com/2011/12/16/nrpe-and-selinux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7b162108ae0b9ce384456b5461da59ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">berndadamowicz</media:title>
		</media:content>
	</item>
		<item>
		<title>Keeping Puppet Dashboard&#8217;s Database small</title>
		<link>http://berndadamowicz.wordpress.com/2011/12/07/keeping-puppet-dashboards-database-small/</link>
		<comments>http://berndadamowicz.wordpress.com/2011/12/07/keeping-puppet-dashboards-database-small/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 22:14:56 +0000</pubDate>
		<dc:creator>Bernd Adamowicz</dc:creator>
				<category><![CDATA[Configuration Management]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Puppet]]></category>
		<category><![CDATA[Puppet Dashboard]]></category>
		<category><![CDATA[Dashboard]]></category>

		<guid isPermaLink="false">http://berndadamowicz.wordpress.com/?p=110</guid>
		<description><![CDATA[Keeping Puppet Dashboard&#8217;s Database small Just encountered that the MySQL database which is used for storing the Puppet reports for the Dashboard has grown very large. The regular backup dumps I&#8217;ve created had more than 2GB of size. So I thought it&#8217;s time to have a look if everything is going well and if I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=110&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Keeping Puppet Dashboard&#8217;s Database small</h1>
<p>Just encountered that the MySQL database which is used for storing the Puppet reports for the Dashboard has grown very large. The regular backup dumps I&#8217;ve created had more than 2GB of size. So I thought it&#8217;s time to have a look if everything is going well and if I can get rid of some old records. No, I had no cron job so far for deleting old records as recommended by Puppet&#8217;s documentation. However this cron job is now in place and I&#8217;d like to share some experiences I&#8217;ve made while analysing the database and while deleting old records manually.</p>
<p><strong>The Analysis</strong><br />
First I wanted to find out if it is really Dashboard&#8217;s database which is responsible for the huge size of the dumps. So I logged in as root to MySQL and had a look:</p>
<p><pre class="brush: bash; highlight: [5]; wrap-lines: false;">
mysql&gt; SELECT table_schema &quot;Data Base Name&quot;, SUM( data_length + index_length) / 1024 / 1024 &quot;Data Base Size in MB&quot; FROM information_schema.TABLES GROUP BY table_schema;
+----------------------+----------------------+
| Data Base Name       | Data Base Size in MB |
+----------------------+----------------------+
| dashboard_production |        2878.34375000 | 
| information_schema   |           0.00390625 | 
| mysql                |           0.52497292 | 
| puppet               |          26.93750000 | 
+----------------------+----------------------+
4 rows in set (1.30 sec)

mysql&gt;
</pre></p>
<p>Obviously no doubt that <i>dashboard_production</i> alone creates 2.8GB of data. Digging a little deeper showed the table which holds the most records:</p>
<p><pre class="brush: bash; highlight: [18]; wrap-lines: false;">
mysql&gt; SELECT TABLE_NAME, table_rows, data_length, index_length,  round(((data_length + index_length) / 1024 / 1024),2) &quot;Size in MB&quot; FROM information_schema.TABLES WHERE table_schema = &quot;dashboard_production&quot;;
+------------------------------+------------+-------------+--------------+------------+
| TABLE_NAME                   | table_rows | data_length | index_length | Size in MB |
+------------------------------+------------+-------------+--------------+------------+
| metrics                      |    1010174 |    51986432 |     14172160 |      63.09 | 
| node_class_memberships       |          0 |       16384 |            0 |       0.02 | 
| node_classes                 |          0 |       16384 |            0 |       0.02 | 
| node_group_class_memberships |          0 |       16384 |            0 |       0.02 | 
| node_group_edges             |          0 |       16384 |            0 |       0.02 | 
| node_group_memberships       |          0 |       16384 |            0 |       0.02 | 
| node_groups                  |          0 |       16384 |            0 |       0.02 | 
| nodes                        |         39 |       16384 |            0 |       0.02 | 
| old_reports                  |          0 |       16384 |            0 |       0.02 | 
| parameters                   |          0 |       16384 |            0 |       0.02 | 
| report_logs                  |    1112049 |   330104832 |     15220736 |     329.33 | 
| reports                      |      20866 |     2637824 |      2048000 |       4.47 | 
| resource_events              |     882791 |   107610112 |     13123584 |     115.14 | 
| resource_statuses            |    7925550 |  2369781760 |    109723648 |    2364.64 | 
| schema_migrations            |         45 |       16384 |            0 |       0.02 | 
| timeline_events              |      44091 |     3686400 |            0 |       3.52 | 
+------------------------------+------------+-------------+--------------+------------+
16 rows in set (1.07 sec)

mysql&gt;
</pre></p>
<p>Table <i>resource_statuses</i> held almost 8 Million records producing some 2.3GB of data. So I had a look at Puppet&#8217;s documentation which says to issue a <i>rake</i> command to drop old records:</p>
<p><pre class="brush: bash; gutter: false;">
rake RAILS_ENV=production reports:prune upto=1 unit=mon
</pre></p>
<p>This command will delete all records older than one month. So I gave it a try, but:</p>
<p><pre class="brush: bash; wrap-lines: false;">
[root@phost puppet-dashboard]# rake RAILS_ENV=production reports:prune upto=1 unit=wk
(in /usr/share/puppet-dashboard)
Deleting reports before 2011-11-24 13:37 UTC...
Deleted 66 reports.
Deleting resource_statuses records before 2011-11-24 13:37 UTC...
rake aborted!
Mysql::Error: The total number of locks exceeds the lock table size: DELETE FROM `resource_statuses` WHERE (time &lt; &#039;2011-11-24 13:37:32&#039;) 

(See full trace by running task with --trace)
[root@phost puppet-dashboard]# 
</pre></p>
<p>Seemed, MySQL had not enough buffer to lock all records. So I increased the buffer pool of the InnoDB by adding the appropriate configuration to <i>my.cnf</i> and restarted MySQL:</p>
<p><pre class="brush: bash; gutter: false;">
innodb_buffer_pool_size=1024M
</pre></p>
<p>Those 1024M might be too much, I&#8217;m not quite sure. However, it worked. After some estimated 15 minutes the task was finished. But after checking the table sizes again, it turned out that <i>resource_statuses</i> still had the same size of 2.3GB. Some research in Puppet&#8217;s user list showed up some posts with this problem. One advice was to add a patch to file <i>/usr/share/puppet-dashboard/lib/tasks/prune_reports.rake</i>. That&#8217;s the file which is executed by the above <i>rake</i> command and does the actual deletion of the table records. That&#8217;s the patch:</p>
<p><pre class="brush: bash;">
--- prune_reports.rake	2011-09-08 12:42:54.433928840 -0700
+++ prune_reports.rake-new	2011-09-08 12:44:01.928583735 -0700
@@ -52,5 +52,11 @@
     puts &quot;Deleting reports before #{cutoff}...&quot;
     deleted_count = Report.delete_all(['time &amp;lt; ?&#039;, cutoff])
     puts &amp;quot;Deleted #{deleted_count} reports.&amp;quot;
+
+    # inserted to clean up resource_statuses table simultaneously
+    puts &amp;quot;Deleting resource_statuses records before #{cutoff}...&amp;quot;
+    deleted_count = ResourceStatus.delete_all([&#039;time &amp;lt; ?&#039;, cutoff])
+    puts &amp;quot;Deleted #{deleted_count} resource_status records.&amp;quot;
</pre></p>
<p>Obviously only the table <i>reports</i> is deleted by this script, but this table only makes up some 4.5MB. So the solution of this patch is to add the table <i>resource_statuses</i> to this script.</p>
<p>Once again I triggered the <i>rake</i> command after applying the patch and after execution the table size really had decreased:</p>
<p><pre class="brush: bash; highlight: [9]; wrap-lines: false;">
mysql&gt; SELECT TABLE_NAME, table_rows, data_length, index_length,  round(((data_length + index_length) / 1024 / 1024),2) &quot;Size in MB&quot; FROM information_schema.TABLES WHERE table_schema = &quot;dashboard_production&quot;;
+------------------------------+------------+-------------+--------------+------------+
| TABLE_NAME                   | table_rows | data_length | index_length | Size in MB |
+------------------------------+------------+-------------+--------------+------------+
...
| report_logs                  |     971812 |   331153408 |     15220736 |     330.33 | 
| reports                      |      21109 |     2637824 |      2031616 |       4.45 | 
| resource_events              |     899663 |   107610112 |     13123584 |     115.14 | 
| resource_statuses            |    3331699 |  1037041664 |     45694976 |    1032.58 | 
...
</pre></p>
<p>So the solution was found. Now I wanted to have everything managed by Puppet. First I created a bash script which would be executed by a cron job:</p>
<p><pre class="brush: bash;">
#!/bin/bash
DASHBOARD_DIR=/usr/share/puppet-dashboard

cd ${DASHBOARD_DIR}
rake RAILS_ENV=production reports:prune upto=1 unit=wk
rake RAILS_ENV=production db:raw:optimize
</pre></p>
<p>This script calls the <i>rake</i> command I executed manually before along with another command that optimizes the database. Though Puppet&#8217;s documentation recommends to optimize the database only once a month, I have this script is running once every night. And, as you can see, I now delete all records older than just one week which is perfectly OK for our system.</p>
<p>The Puppet configuration which is responsible for executing the cron job and having the patched file in place is this:</p>
<p><pre class="brush: ruby;">
  $purge_file=&quot;purgeDashboardDatabase.sh&quot;
  $prune_reports_file=&quot;/usr/share/puppet-dashboard/lib/tasks/prune_reports.rake&quot;

  file{&quot;${prune_reports_file}&quot;:
    ensure =&gt; file,
    mode =&gt; 0644,
    source =&gt; &quot;puppet:///modules/mysql/${prune_reports_file}&quot;,
    replace =&gt; true,
    before =&gt; &quot;${bin_dir}/${purge_file}&quot;,
  }
  
  file{&quot;${bin_dir}/${purge_file}&quot;:
    ensure =&gt; file,
    mode =&gt; 0755,
    source =&gt; &quot;puppet:///modules/mysql/${purge_file}&quot;,
    replace =&gt; true,
    require =&gt; File[&quot;${bin_dir}&quot;],
  }
  
  cron { purge-dashboard-database:
    command =&gt; &quot;${bin_dir}/${purge_file}&quot;,
    ensure =&gt; present,
    user =&gt; &quot;root&quot;,
    hour =&gt; 2,
    minute =&gt; 0, 
    require =&gt; File[&quot;${bin_dir}/${purge_file}&quot;],
  }
</pre></p>
<p><strong>finally{}</strong><br />
Beware that this solution covers Puppet 2.6.6 along with its Ruby libraries. The <i>rake</i> script might be enhanced in newer versions. So you may want to check if this is necessary for you once you run into the same problem.</p>
<p><strong>Credits</strong><br />
Thanks to <a href="http://www.mkyong.com/mysql/how-to-calculate-the-mysql-database-size/" title="Mkyong's Blog" target="_blank">Mkyong&#8217;s</a> blog post who provided the SQL statements for analysing the database and tables. And of course thanks to <a href="http://groups.google.com/group/puppet-users?hl=en" title="Puppet user list" target="_blank">Puppet&#8217;s user list</a> which is always a very good resource if something does not work as expected.</p>
<br />Filed under: <a href='http://berndadamowicz.wordpress.com/category/configuration-management/'>Configuration Management</a>, <a href='http://berndadamowicz.wordpress.com/category/mysql/'>MySQL</a>, <a href='http://berndadamowicz.wordpress.com/category/puppet/'>Puppet</a>, <a href='http://berndadamowicz.wordpress.com/category/puppet-dashboard/'>Puppet Dashboard</a> Tagged: <a href='http://berndadamowicz.wordpress.com/tag/dashboard/'>Dashboard</a>, <a href='http://berndadamowicz.wordpress.com/tag/mysql/'>MySQL</a>, <a href='http://berndadamowicz.wordpress.com/tag/puppet/'>Puppet</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/berndadamowicz.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/berndadamowicz.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/berndadamowicz.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/berndadamowicz.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/berndadamowicz.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/berndadamowicz.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/berndadamowicz.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/berndadamowicz.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/berndadamowicz.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/berndadamowicz.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/berndadamowicz.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/berndadamowicz.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/berndadamowicz.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/berndadamowicz.wordpress.com/110/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=berndadamowicz.wordpress.com&amp;blog=27524340&amp;post=110&amp;subd=berndadamowicz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://berndadamowicz.wordpress.com/2011/12/07/keeping-puppet-dashboards-database-small/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7b162108ae0b9ce384456b5461da59ae?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">berndadamowicz</media:title>
		</media:content>
	</item>
	</channel>
</rss>
