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

<channel>
	<title>Security Advancements at the Monastery &#187; ruby</title>
	<atom:link href="http://blog.securitymonks.com/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.securitymonks.com</link>
	<description>Information about developments at the Monastery</description>
	<lastBuildDate>Fri, 03 Sep 2010 05:41:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Interfacing with Request Tracker</title>
		<link>http://blog.securitymonks.com/2009/04/10/interfacing-with-request-tracker/</link>
		<comments>http://blog.securitymonks.com/2009/04/10/interfacing-with-request-tracker/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 23:52:22 +0000</pubDate>
		<dc:creator>John Gerber</dc:creator>
				<category><![CDATA[Request Tracker]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.securitymonks.com/?p=996</guid>
		<description><![CDATA[Building on my previous posts, &#8220;Request Tracker Installation (Part 1 of 2)&#8221; and &#8220;Request Tracker Installation (Part 2 of 2),&#8221; today we are going to discuss how to get programs interacting with Best Practical&#8217;s Request tracker (RT).  In later posts, we will build upon this to start having our security processes log information to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://bestpractical.com/images/clip_logofade.gif" align="left" width=50 />Building on my previous posts, &#8220;<a href="http://blog.securitymonks.com/2007/12/26/request-tracker-installation-part-1-of-2/">Request Tracker Installation (Part 1 of 2)</a>&#8221; and &#8220;<a href="http://blog.securitymonks.com/2008/08/03/request-tracker-installation-part-2-of-2/">Request Tracker Installation (Part 2 of 2)</a>,&#8221; today we are going to discuss how to get programs interacting with Best Practical&#8217;s Request tracker (<a href="http://www.bestpractical.com/rt/">RT</a>).  In later posts, we will build upon this to start having our security processes log information to RT.  Keep in mind, tickets do not need to only be done as part of a manual process.  Tickets can be generated by processes running on the system.  The tickets can also be updated by other processes.  </p>
<p><h3>The Database</h3>
<p>A few diagrams of the RT&#8217;s database schema are available:</p>
<ul>
<li><a href="http://web.mit.edu/sturner/www/rt/rtmodel.gif">Steve Turner&#8217;s Model</a></li>
<li><a href="http://bestpractical.com/rt/3.4-schema.png">The official RT 3.4 schema</a></li>
<li><a href="http://bestpractical.com/tutorial-demos/04_schema2_singleside.pdf">Jesse Vincent&#8217;s model</a> (pdf)</li>
</ul>
<p>If you are unfamiliar with some of the keys and conventions used in Visio graphs, the below table provides some helpful information. Mandatory (not null) columns are displayed in bold.
</p>
<p><table border=1>
<tr>
<td>PK</td>
<td>Primary key</td>
<td>&ndash;&ndash;&ndash;0+</td>
<td>0 or 1</td>
</tr>
<tr>
<td>FK</td>
<td>Foreign key</td>
<td>&ndash;&ndash;&ndash;0&lt;&ndash;</td>
<td>0 or more</td>
</tr>
<tr>
<td>U</td>
<td>Unique column</td>
<td>&ndash;&ndash;&ndash;++</td>
<td>Exactly 1</td>
</tr>
<tr>
<td>I</td>
<td>Indexed column</td>
<td>&ndash;&ndash;&ndash;+&lt;&ndash;</td>
<td>1 or more</td>
</tr>
<tr>
<td>O</td>
<td>Optimal columns</td>
<td></td>
<td></td>
</tr>
</table>
<p>
Further clarification can be found in chapter 8 titled &#8220;Architect&#8221; of the &#8220;<a href="http://oreilly.com/catalog/9780596006686/">RT Essentials</a>&#8221; book from O&#8217;Reilly.  Look for the section &#8220;Logical and Object Model&#8221; which takes a tour of RT&#8217;s logical and object models.
</p>
<h3>Perl Module</h3>
<p>Referring once more the the &#8220;<a href="http://oreilly.com/catalog/9780596006686/">RT Essentials</a>&#8221; book&#8217;s chapter 8 on architecture, the below diagram maps the layers involved with RT.<br />
<img src="http://my.safaribooksonline.com/getfile?item=Ni82czAvZG0wL3JnY2d0cDllL2lzODNmMGE1aXI2Lm5fZ3RpOGVsZXMxczB0aWEwc2Y-" alt="" width=500 /><br />
A quick overview of what the provide:
<ol>
<li>Allowing a database independent interface to Perl is the <a href="http://search.cpan.org/perldoc?DBI">DBI</a> module.</li>
<li><a href="http://search.cpan.org/perldoc?DBIx::SearchBuilder">DBIx::SearchBuilder</a> encapsulate SQL queries and rows in simple perl objects allowing object-oriented applications like RT to talk to a table-oriented relational database.</li>
<li>The RT application platform libraries provide database connectivity, logginng infrastructures, users, groups, access control, links, etc.  Basically it is the guts of RT.</li>
<li>The RT ticketing system libraries uses the RT application platform.</li>
<li>The Mason handler run on top of the RT core libraries and provides a wrapper around the Mason templating system.  The Mason templates consists of the user interface templates, which designed for end users to interact with their browsers, and the REST templates, which are designed to be easy for other software to interact with RT.</li>
</ol>
<p>Creating, querying, and editing tickets in an RT instance could be done by using <a href="http://wiki.bestpractical.com/view/CLI">RT Command Line Interface (CLI)</a> calls embedded in programs.  Or, one could directly plug into the RT libraries.  To maintain compatibility with future releases of RT, we will be using RT&#8217;s built in <a href="http://en.wikipedia.org/wiki/REST">REST</a> interface.</p>
<p>
Fortunately, <a href="http://search.cpan.org/~dmitri/">Dmitri Tikhonov</a> has created the <a href="http://search.cpan.org/dist/RT-Client-REST/">RT::Client::REST</a>.  If Ruby is your preferred language, Tom Lahti has cared a <a href="http://rubyforge.org/projects/rt-client">Ruby library</a> to interface with RT.
</p>
<p>
Jesse Vincent posted recently on the Best Practical blog, &#8220;<a href="http://blog.bestpractical.com/2009/03/it-should-come-as-no-suprise-to-folks-that-weve-been-hard-at-work-on--what-will-become-rt-40----weve-been-working-hard-to-o.html">RT 4 &#8211; status report</a>.&#8221;   While it will be awhile before RT4 is out, Jesse has written that &#8220;RT4 is based on Jifty and serves up both the legacy /REST/1.0 interface and Jifty&#8217;s much more <a href="http://cpansearch.perl.org/src/SARTAK/Jifty-0.80408/lib/Jifty/Plugin/REST/Dispatcher.pm">modern REST interface</a>.&#8221;  End result is  that compatibility will be maintained.
</p>
<p><h3>Perl Modules Installation</h3>
<p>Make sure to follow the instructions from &#8220;<a href="http://blog.securitymonks.com/2008/08/03/request-tracker-installation-part-2-of-2/">Request Tracker Installation (Part 2 of 2)</a>.&#8221;  The Perl foundation defines <a href="http://www.perlfoundation.org/perl5/index.cgi?kwalitee">kwalitee</a> as &#8220;a set of formalities that tend to coincide with quality, according to consensus.  It is of course much less useful than quality, but at least it can be measured.&#8221;  Install the Perl module <a href="http://search.cpan.org/dist/Module-CPANTS-Analyse/">Module::CPANTS::Analyse</a> and  <a href="http://search.cpan.org/dist/Test-Kwalitee/">Test::Kwalitee</a>, along with supporting modules, for quality testing.
</p>
<p><table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 /usr/local/src root# perl -MCPAN -e 'install Module::CPANTS::Analyse'
 /usr/local/src root# perl -MCPAN -e 'install Test::Kwalitee'
</pre>
</td>
</table>
<p>
If you have read any of <a href="http://www.terrygoodkind.com/">Terry Goodkind&#8217;s</a> Sword of Truth series of books, you maybe familiar with his character Zedd saying, &#8220;<strong>If the road is easy, you&#8217;re likely going the wrong way</strong>.&#8221;  No where is this more true than in IT.  Life is made a bit easier if you check active bugs when setting up software.  Fortunately, RT-Client-REST does have an <a href="http://rt.cpan.org/Public/Dist/Display.html?Name=RT-Client-REST">active bug listing</a>.
</p>
<p>
There is a bug involving <a href="http://rt.cpan.org/Public/Bug/Display.html?id=39868">CustomFields change in RT 3.8</a> and how RT matched on the # symbol.  RT incorrectly matched when using the REST interface because RT::Client::REST had a CustomField with a # at the end.  Jerrad Pierce has just posted that the necessary changes were mote extensive and the code should be pulled down from SVN.  We will pull the code from there. </p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
/usr/local/src root# svn checkout \
     http://rt-client-rest.googlecode.com/svn/trunk/ rt-client-rest-read-only
/usr/local/src root# cd  rt-client-rest-read-only/rt-client-rest
/usr/local/src/rt-client-rest-read-only/rt-client-rest root# perl Makefile.PL
/usr/local/src/rt-client-rest-read-only/rt-client-rest root# make
/usr/local/src/rt-client-rest-read-only/rt-client-rest root# make test
/usr/local/src/rt-client-rest-read-only/rt-client-rest root# make install
</pre>
</td>
</table>
<p>
</p>
<p>
Connecting up through SSL requires a few additional steps.  make sure to install the Perl module Crypt::SSLeay.</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 /usr/local/src root# perl -MCPAN -e 'install Crypt::SSLeay'
</pre>
</td>
</table>
<p>
</p>
<p><h3>Ruby</h3>
<p>If you need to install Ruby please see my earlier post &#8220;<a href="http://blog.securitymonks.com/2008/09/29/implementing-puppet-act-one/">Implementing Puppet: Act One</a>.&#8221;  Ruby 1.9.x is a fairly significant change.  See Josh Haberman post &#8220;<a href="http://blog.reverberate.org/2009/01/31/ruby-191-released/">Ruby 1.9.1 released</a>,&#8221;  Markus Prinz post &#8220;<a href="http://blog.nuclearsquid.com/writings/ruby-1-9-what-s-new-what-s-changed">Ruby 1.9 &#8211; What&#8217;s new? What&#8217;s changed?</a>&#8220;, and Peter Cooper&#8217;s post &#8220;<a href="http://www.rubyinside.com/23-useful-ruby-19-links-and-resources-1498.html">23 Useful Ruby 1.9 Links and Resources</a>.&#8221;  If you are working with Ruby, you need <a href="http://pragdave.pragprog.com/">Dave Thomas</a>&#8216; book &#8220;<a href="http://www.pragprog.com/titles/ruby3/programming-ruby-1-9">Programming Ruby 1.9: The Pragmatic Programmers&#8217; Guide</a>,&#8221; which is about to be released and is available in electronic format.
</p>
<p>
When you issue the &#8220;gem install rt-client,&#8221; errors involving the TMail file <strong>tmailscanner.c</strong> will occur.  First, it was looking for header files in directory /usr/local/include/ruby-1.9.1 instead of /usr/local/include/ruby-1.9.1/ruby and complaining about &#8220;<strong>re.h: No such file or directory</strong>&#8220;.  As Zedd would say, &#8220;<strong>Nothing is ever easy</strong>.&#8221;  If you fix that problem, TMail will complain about &#8220;struct RString.&#8221;  This is a show stopper if you want to use Ruby 1.9.x.  When this gets fixed, I will try and come back and update this post.
</p>
<p><h3>Connecting Securely</h3>
<p>Modify the RT_SiteConfig.pm to use port 443.</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
Before (Without SSL): Set($WebBaseURL , " http://<strong>rt.yourdomain.com</strong>");
After (With SSL): Set($WebBaseURL , " https://<strong>rt.yourdomain.com</strong>:443");
</pre>
</td>
</table>
<p>
</p>
<p>
Please change <strong>rt.yourdomain.com</strong> to the appropriate host value for your organization.
</p>
<p>
<strong>The REST Interface does not support HTTP-Authentication</strong>.  If your web server requires users to log in, you will end up with authentication problems.  As of this writing, there are <a href="http://rt.cpan.org/Public/Bug/Display.html?id=26873">problems</a> when when both authentication mechanisms are used together.  A work around, if your program is running on the same machine as the web server, is to setup a virtual host for 127.0.0.1 that does not use HTTP-Authentication.  Make sure to connections are allowed from client 127.0.0.1 only.  The outside world interface can continue to be forced to use HTTPS and HTTP-Authentication.
</p>
<p><h3>Sample Program</h3>
<p>With the supporting software in place, we can now write a program.  Below is a simple program that connects up to OpenSSL&#8217;s RT site, pulls out all new and open tickets belonging to the OpenSSL-Bugs queue, and prints out the id, subject, owner, status, and when the ticket was created.  </p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
#!/usr/local/bin/perl -w

  use strict;
  use Error qw(:try);
  use RT::Client::REST;
  use Data::Dumper;

  my %Config = (
      server      => 'http://rt.openssl.org/',
      username    => 'guest',
      password    => 'guest',
      queue       => 'OpenSSL-Bugs'
  );
  my $rt = RT::Client::REST->new(
    server => $Config{server},
    timeout => 30,
  );

  try {
    $rt->login(username => $Config{username}, password => $Config{password} );
  }
  catch Exception::Class::Base with {
    die "problem logging in: ", shift->message;
  };

  my @ids;
  try {
    @ids = $rt->search(
        type    => 'ticket',
        query   => qq[
            (Status = 'new' or Status = 'open')
            and
            Queue = '$Config{queue}'
        ],
    );
  }
  catch Exception::Class::Base with {
    die "search failed", shift->message;
  };
  for my $id (@ids) {
    my $ticket = $rt->show(type => 'ticket', id => $id);
    print "ID: $id\n";
    print Dumper($ticket);
   }
</pre>
</td>
</table>
<p>
</p>
<p><h3>Final Thoughts</h3>
</p>
<p>One of the more difficult aspect of connecting several different open source projects is what to do with various versions of the software.  While it is unfortunate that we will have to wait for software to get updated on the Ruby side, we are now ready to start working with Perl.  In the next post, we will go through the steps to take a program that monitors activity and informs administrators via email, to a system that uses RT to perform this function.  By doing so, we gain operational tracking capability.  We are about to start having some fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.securitymonks.com/2009/04/10/interfacing-with-request-tracker/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Implementing Puppet: Act One</title>
		<link>http://blog.securitymonks.com/2008/09/29/implementing-puppet-act-one/</link>
		<comments>http://blog.securitymonks.com/2008/09/29/implementing-puppet-act-one/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 06:58:02 +0000</pubDate>
		<dc:creator>John Gerber</dc:creator>
				<category><![CDATA[Puppet]]></category>
		<category><![CDATA[RubyGems]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.securitymonks.com/?p=113</guid>
		<description><![CDATA[Consider how valuable it would be to combine the monitoring and automation of system tasks with rapid and consistent responses across an organization.  Puppet is an automated administrative engine capable of automating nearly every aspect of a system administrator’s job, from user management, to software installation, to even configuring server services.  Puppet is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.paperhand.org"><img src="http://www.paperhand.org/images/shows/wsfb/fire.jpg" width=125 align="left" /></a>Consider how valuable it would be to combine the monitoring and automation of system tasks with rapid and consistent responses across an organization.  <a href="http://reductivelabs.com/projects/puppet/">Puppet</a> is an automated administrative engine capable of automating nearly every aspect of a system administrator’s job, from user management, to software installation, to even configuring server services.  Puppet is written in <a href="http://www.ruby-lang.org">Ruby</a>, but uses a configuration management abstraction language.  This allows for the modeling of resources instead of describing in details how to configure resources.  With Puppet you can perform normal administrative tasks (such as adding users, installing packages, and updating server configurations) on any number of systems, even if those systems are running <u>completely different operating systems</u>.  </p>
<p>
<a href="http://www.redmonk.com/cote/about/">Michael Coté</a>, an industry analyst with <a href="http://redmonk.com">RedMonk</a>, interviewed <a href="http://www.reductivelabs.com/">Reductive Lab</a>’s <a href="http://www.madstop.com/">Luke Kaines</a> and Google’s <a href="http://explanatorygap.net/">Nigel Kersten</a> on the podcast “<a href="http://www.redmonk.com/cote/2008/06/11/puppet-at-google-redmonk-radio-episode-48/">Puppet at Google &#8211; RedMonk Radio Episode 48</a>.”   To quote Coté, “Nigel has been using Puppet to manage ‘many, many thousands’ of Mac desktops used at Google by developers and others. He tells us how he got involved in using Puppet during <a href="http://developer.apple.com/wwdc">WWDC</a> last year and quickly applied its use to managing Google Mac desktop.”  <a href="http://www.blogger.com/profile/10492341480170667775">Pat Eyler</a> also posted, on the On Ruby blog, an <a href="http://on-ruby.blogspot.com/2008/02/puppet-interview-with-james-turnbull.html">interview with James Turnbull</a>. Turnbull is the author of “<a href="http://www.apress.com/book/view/1590599780">Pulling Strings with Puppet</a>.”  To quote Turnbull on Puppet, &#8220;It takes all the pain out of systematically and efficiently managing your host.&#8221;
</p>
<p>
<a href="http://www.windley.com/">Phil Windley</a>, Founder and Chief Technology Officer (CTO) of <a href="http://www.kynetx.com/">Kynetx</a> has been providing some great information on Puppet.  Phil recently attended the O&#8217;Reilly <a href="http://en.oreilly.com/velocity2008/public/content/home">Velocity 08</a> conference where he attended a talk given by Luke Kanies.  Phil shares his impression in the post &#8220;<a href="http://www.windley.com/archives/2008/06/velocity_08_puppet_indepth_and_handson.shtml">Velocity 08: Puppet In-Depth and Hands-On</a>.&#8221;  Phil is also the host of IT Conversations&#8217; <a href="http://itc.conversationsnetwork.org/series/technometria.html">Technometria</a> podcast.  He must have liked what he heard at Velocity 08, for he had Luke Kanies on his show to <a href="http://itc.conversationsnetwork.org/shows/detail3716.html">discuss Puppet</a>.  Plus, Phil has been sharing his experience implementing Puppet in his posts &#8220;<a href="http://www.windley.com/archives/2008/08/puppet_fun.shtml">Puppet Fun</a>&#8221; and &#8220;<a href="http://www.windley.com/archives/2008/08/using_a_precommit_hook_to_check_puppet_syntax.shtml">Using a Pre-Commit Hook to Check Puppet Syntax</a>.&#8221;
</p>
<p>
The point of today&#8217;s post is not to discuss how useful Puppet can be.  Its worth can be best determined through examining how it is used.  I have provided a few links to people making good use of Puppet.  I will also provide follow up posts describing integrating Puppet with other security software we have been discussing.  Today&#8217;s post is simply to set the groundwork by focusing on implementing a basic Puppet setup. </p>
<h3>Prerequisites</h3>
<p>Most of what Puppet requires will come as part of the Ruby standard library.  It is best to use the Ruby that comes with your OS.  I will still go through the installation of Ruby.  The only other required package is Reductive Lab&#8217;s <a href="http://www.reductivelabs.com/projects/facter/index.html">Facter</a>, which is a cross-platform Ruby library for retrieving facts from operating systems.  </p>
<ul>
<li><a href="http://www.ruby-lang.org/en/">Ruby</a></li>
<li><a href="http://www.reductivelabs.com/projects/facter/index.html">Facter</a></li>
</ul>
<p>The Ruby standard libraries that are required by Puppet include:</p>
<ul>
<li><a href="http://www.ruby-doc.org/stdlib/libdoc/base64/rdoc/index.html">base64</a></li>
<li><a href="http://www.ruby-doc.org/stdlib/libdoc/cgi/rdoc/index.html">cgi</a></li>
<li><a href="http://www.ruby-doc.org/stdlib/libdoc/digest/rdoc/index.html">digest/md5</a></li>
<li><a href="http://www.ruby-doc.org/stdlib/libdoc/etc/rdoc/index.html">etc</a></li>
<li><a href="http://www.ruby-doc.org/stdlib/libdoc/fileutils/rdoc/index.html">fileutils</a></li>
<li><a href="http://www.ruby-doc.org/stdlib/libdoc/ipaddr/rdoc/index.html">ipaddr</a></li>
<li><a href="http://www.ruby-doc.org/stdlib/libdoc/openssl/rdoc/index.html">openssl</a></li>
<li><a href="http://www.ruby-doc.org/stdlib/libdoc/strscan/rdoc/index.html">strscan</a></li>
<li><a href="http://www.ruby-doc.org/stdlib/libdoc/syslog/rdoc/index.html">syslog</a></li>
<li><a href="http://www.ruby-doc.org/stdlib/libdoc/uri/rdoc/index.html">uri</a></li>
<li><a href="http://www.ruby-doc.org/stdlib/libdoc/webrick/rdoc/index.html">webrick</a></li>
<li><a href="http://www.ruby-doc.org/stdlib/libdoc/webrick/rdoc/index.html">webrick/https</a></li>
<li><a href="http://www.ruby-doc.org/stdlib/libdoc/rdoc/rdoc/index.html">rdoc</a></li>
<li><a href="http://www.ruby-doc.org/stdlib/libdoc/xmlrpc/rdoc/index.html">xmlrpc</a></li>
</ul>
<h3>Installation</h3>
<p>In order to install all the required packages, we will start by installing Ruby, followed by checking that the required libraries are installed, and finish with Facter.  If any of these software packages are installed by default on your OS, you will likely want to skip the corresponding installation steps. </p>
<h4><strong>Ruby</strong></h4>
<p>The Ruby website describes Ruby as &#8220;a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.&#8221;  Below are the steps to do a source code installation.  Please note that there are other options listed in the <a href="http://www.ruby-lang.org/en/downloads/">Download Ruby</a> page.  I will be going through installation using the source code only because there are some systems that do not have Ruby installed.  If you are going to be working with Ruby, you may consider purchasing a great reference on Ruby titled &#8220;<a href="http://pragprog.com/titles/ruby3/programming-ruby-3">Programmers&#8217; Guide, 3rd Edition</a>&#8221; by Dave Thomas, with Chad Fowler and Andy Hunt.</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 root# cd /usr/local/src
 /usr/local/src root# wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p72.tar.gz
 /usr/local/src root#  /usr/bin/md5sum ruby-1.8.7-p72.tar.gz
5e5b7189674b3a7f69401284f6a7a36d  ruby-1.8.7-p72.tar.gz

 /usr/local/src root# tar xzf ruby-1.8.7-p72.tar.gz
 /usr/local/src root# cd ruby-1.8.7-p72
 /usr/local/src/ruby-1.8.7-p72 root# ./configure
 /usr/local/src/ruby-1.8.7-p72 root# make
 /usr/local/src/ruby-1.8.7-p72 root# make check
 /usr/local/src/ruby-1.8.7-p72 root# make install
</pre>
</td>
</table>
<p></p>
<h4><strong>RubyGems</strong></h4>
<p><a href="http://www.rubygems.org">RubyGems</a> is the premier Ruby packaging system. Quoting the RubyGems website, &#8220;it provides a standard format for distributing Ruby programs and libraries, an easy to use tool for managing the installation of gem packages, and a gem server utility for serving gems from any machine where RubyGems is installed.&#8221;  Using RubyGems makes handling libraries a great deal easier.  If you are behind a proxy server, you will either need to set <strong>HTTP_PROXY</strong> or include the proxy setting in the gem command.  </p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 root# cd /usr/local/src
 /usr/local/src root# wget http://rubyforge.org/frs/download.php/43985/rubygems-1.3.0.tgz
 /usr/local/src root# tar xzf rubygems-1.3.0.tgz
 /usr/local/src root# cd rubygems-1.3.0
 /usr/local/src/rubygems-1.3.0 root# ruby setup.rb
 /usr/local/src/rubygems-1.3.0 root# gem --version
1.3.0
 /usr/local/src/rubygems-1.3.0 root# gem update --system
Updating RubyGems
Updating rubygems-update
</pre>
</td>
</table>
<p></p>
<h4><strong>Ruby Libraries</strong></h4>
<p>Check that the libraries are installed with the commands:</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 root# ruby -rbase64 -e "puts :installed"
 root# ruby -rcgi -e "puts :installed"
 root# ruby -rdigest -e "puts :installed"
 root# ruby -retc -e "puts :installed"
 root# ruby -rfileutils -e "puts :installed"
 root# ruby -ripaddr -e "puts :installed"
 root# ruby -ropenssl -e "puts :installed"
 root# ruby -rstrscan -e "puts :installed"
 root# ruby -rsyslog -e "puts :installed"
 root# ruby -ruri -e "puts :installed"
 root# ruby -rwebrick -e "puts :installed"
 root# ruby -rrdoc/usage -e "puts :installed"
 root# ruby -rxmlrpc -e "puts :installed"
ruby: no such file to load -- xmlrpc (LoadError)
</pre>
</td>
</table>
<p>
With RubyGem installed, checking and installing Ruby libraries is fairly easy.  For future reference, a <strong>gem</strong> is a packaged Ruby application or library. Below we are going to look for a xmlrpc packaged library globally and install it locally.</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
bash-3.00# gem list -b ^xmlrpc
*** REMOTE GEMS ***
xmlrpcs (0.1.3)

bash-3.00#  gem install xmlrpcs
Successfully installed xmlrpcs-0.1.3
1 gem installed
Installing ri documentation for xmlrpcs-0.1.3...
Installing RDoc documentation for xmlrpcs-0.1.3...
</pre>
</td>
</table>
<p></p>
<h4><strong>Facter</strong></h4>
<p>Reductive Labs describes Facter as &#8220;a cross-platform Ruby library for retrieving facts from operating systems. Supports multiple resolution mechanisms, any of which can be restricted to working only on certain operating systems or environments.  Facter is especially useful for retrieving things like operating system names, IP addresses, MAC addresses, and SSH keys.&#8221; To install and confirm it is installed, issue the following commands:</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 root# cd /usr/local/src
 /usr/local/src root# wget http://www.reductivelabs.com/downloads/facter/facter-latest.tgz
 /usr/local/src root# tar xzf facter-latest.tgz
 /usr/local/src root# cd facter-1.5.2
 /usr/local/src/facter-1.5.2 root# ruby install.rb
 /usr/local/src/facter-1.5.2 root# facter --version
1.5.2
</pre>
</td>
</table>
<p>
There is an alternative method for installing Facter using RubyGem.  Currently, it does not appear to be working.  I&#8217;ll include the instructions with the hope that it will be fixed in the future.</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 root# gem install --remote --source http://reductivelabs.com/downloads/ facter
 root# facter --version
1.5.2
</pre>
</td>
</table>
<p></p>
<h4><strong>Puppet</strong></h4>
<p>Puppet can be installed via source, packages, or using RubyGem.  I&#8217;ll demonstrate installation using source and as a gem.  Since package installation is dependent on the OS, readers should view the Reductive Labs <a href="http://reductivelabs.com/trac/puppet/wiki/InstallationGuide">Wiki</a>.
</p>
<p>
The source contains both the Puppet server and client code.  Download and install Puppet with the following commands:</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 root# cd /usr/local/src
 /usr/local/src root# wget http://reductivelabs.com/downloads/puppet/puppet-latest.tgz
 /usr/local/src root# tar xzf puppet-latest.tgz
 /usr/local/src root# cd puppet-0.24.5
 /usr/local/src/puppet-0.24.5 root# ruby install.rb
 /usr/local/src/puppet-0.24.5 root# puppet --version
0.24.5
</pre>
</td>
</table>
<p>
</p>
<p>
As with Facter, using RubyGem to install Puppet does not seem to work.  I&#8217;ll include the instructions and hopefully it will be fixed in the future.</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 root# gem install --remote --source http://reductivelabs.com/downloads/ puppet
 root# puppet --version
0.24.5
</pre>
</td>
</table>
<p></p>
<h3>The Puppet Master</h3>
<p>Most of the functionality of Puppet can be run with default configuration.  The two things that need to be assigned is a user and a group to run along with a basic configuration to apply to the client.  </p>
<h4><strong>User and Group</strong></h4>
<p>Check if the puppet user and group exist on your system.  </p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 root# id puppet
uid=477(puppet) gid=149(puppet) groups=149(puppet)
</pre>
</td>
</table>
<p>
If that does not work for your OS, you can grep through the password and group files.</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 root# grep puppet /etc/passwd
 root# grep puppet /etc/group
</pre>
</td>
</table>
<p>
If you need to add the user and group puppet, under most unix version you would do so with the command:</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 root# groupadd puppet
 root# useradd -M -g puppet puppet
</pre>
</td>
</table>
<p>
Mac OS X Leopard (10.5) makes things a little more complicated if you are going to use the command line.  You will first need to look at what group ids (gid) are used, choose an unused gid, and then create the puppet group using that gid. This would be accomplished with the commands:</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 root# dscl . list /groups PrimaryGroupID | sort -k 2,2 -n | tail -2
rt                 503
httpd            10650
 root# dscl . create /groups/puppet gid 504
 root# dscl . create /groups/puppet passwd '*'
 root# dscl . read /groups/puppet
 root# dscl . list /users UniqueID | sort -k 2,2 -n | tail -2
ossecr             505
httpd              47008
 root# dscl localhost -create /Local/Default/Users/puppet
 root# dscl localhost -create /Local/Default/Users/puppet RecordName puppet
 root# dscl localhost -create /Local/Default/Users/puppet UserShell /sbin/nologin
 root# dscl localhost -create /Local/Default/Users/puppet RealName "Puppet"
 root# dscl localhost -create /Local/Default/Users/puppet UniqueID 506
 root# dscl localhost -create /Local/Default/Users/puppet PrimaryGroupID 504
 root# dscl localhost -create /Local/Default/Users/puppet NFSHomeDirectory /dev/null
 root# dscl . read /users/puppet
AppleMetaNodeLocation: /Local/Default
GeneratedUID: B71B9C49-5C59-4B17-B69C-415589832976
NFSHomeDirectory: /dev/null
PrimaryGroupID: 504
RealName: Puppet
RecordName: puppet
RecordType: dsRecTypeNative:users
UniqueID: 506
UserShell: /sbin/nologin
 root# id puppet
uid=506(puppet) gid=504(puppet) groups=504(puppet)
</pre>
</td>
</table>
<p></p>
<h4><strong>Configuration File</strong></h4>
<p>We are going to create a default configuration file <strong>/etc/puppet/manifests/site.pp</strong>.</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 root# mkdir -p /etc/puppet/manifests
 root# vi /etc/puppet/manifests/site.pp
</pre>
</td>
</table>
<p>
For a very simple example, we will have Puppet check the user and group ownership of /etc/passwd as well as its permissions.  The following would go into site.pp:</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
file { "/etc/passwd":
  owner => "root",
  group => "bin",
  mode => 644,
}
</pre>
</td>
</table>
<p></p>
<h4><strong>Starting</strong></h4>
<p>With a simple configuration file create, we can now start the master daemon.</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 root# puppetmasterd --verbose --no-daemonize
info: Starting server for Puppet version 0.24.5
info: Listening on port 8140
notice: Starting Puppet server version 0.24.5
</pre>
</td>
</table>
<p>
The <strong>&#8211;verbose</strong> option will turn on verbose logging while the <strong>&#8211;no-daemonize</strong> option forces the daemon to run in the foreground.  The daemon will start on <strong>TCP port 8140</strong>.  </p>
<h3>The Client</h3>
<p>The Puppet client will run as root in order to perform the required configuration actions on the node.  When you start the client for the first time, it will generate a local self-signed certificate, connect to the specified master, and request the certificate be signed.  Puppet relies on SSL when communicating between the server and clients.  Once the certificate is signed, the node will request whatever configuration is specified for that node.  Clients running on the same host as the server have their certificates automatically signed.
</p>
<p>
To test Puppet, have the group permission of the /etc/passwd file be &#8220;root&#8221; and see how Puppet handles it on the client (example: puppet1.securitymonks.com).  The client will first require the server (example: puppetmaster.securitymonks.com) to sign its certificate.  The client connects to the server when the <strong>puppetd</strong> command is run.  Until the certificate is signed, the group permission on /etc/passwd will not change.  From the client, issue the commands:</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 root# chgrp root /etc/passwd
 root# ls -l /etc/passwd
-rw-r--r--  1 root root 2800 Sep 28 05:53 /etc/passwd
 root# puppetd --server puppetmaster.securitymonks.com --verbose --waitforcert 60
notice: Starting Puppet client version 0.24.5
info: No classes to store
info: Caching catalog at /var/puppet/state/localconfig.yaml
 root# ls -l /etc/passwd
-rw-r--r--  1 root root 2800 Sep 28 05:53 /etc/passwd
</pre>
</td>
</table>
<p>
The <strong>&#8211;server</strong> option tells the client the name of the server (puppetmaster.securitymonks.com).  The <strong>&#8211;waitforcert</strong> tells the client to check every 60 seconds for the server to return signed certificate.  Over on the server, we see the message:</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
info: Caching node for puppet1.securitymonks.com
notice: Compiled catalog for puppet1.securitymonks.com in 0.04 seconds
</pre>
</td>
</table>
<p></p>
<h4><strong>Certificates</strong></h4>
<p>The Puppet master will sign certificates using the <strong>puppetca</strong> command, which controls the Puppet Certificate Authority.  While automatically signing certificates is possible, in the interest of security we will be manually approving requests.  Please read more about <a href="http://reductivelabs.com/trac/puppet/wiki/CertificatesAndSecurity">certificate management and security</a> at Reductive Labs&#8217; <a href="http://reductivelabs.com/trac/puppet/wiki">Wiki</a>.
</p>
<p>
From the server, puppetmaster.securitymonks.com, list the waiting certificate and sign the witht he commands: </p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
 root# puppetca --list
puppet1.securitymonks.com
 root# puppetca --sign puppet1.securitymonks.com
Signed puppet1.securitymonks.com
</pre>
</td>
</table>
<p>
Go back to the client and notice that it now has a certificate.  Also examine the group permission on the /etc/passwd file.</p>
<table width="100%" cellpadding="0" cellspacing="1" border="1">
<td class="code-outline" BGCOLOR="#F5F5F5">
<pre class="displaycode">
notice: Got signed certificate
notice: Starting catalog run
notice: //File[/etc/passwd]/group: group changed 'root' to 'bin'
notice: Finished catalog run in 0.08 seconds
 root# ls -l /etc/passwd
-rw-r--r--  1 root bin 2800 Sep 28 05:53 /etc/passwd
</pre>
</td>
</table>
<p></p>
<h3>Curtain Drops</h3>
<p>This brings to a close Act One of this Puppet implementation.  A very simple Puppet master daemon with one node has been created.  In Act Two, we will do a little more advance configuration.  If you plan on working with Puppet, buy the book &#8220;<a href="http://www.apress.com/book/view/1590599780">Pulling Strings with Puppet: Configuration Management Made Easy</a>&#8221; by James Turnbull.  It is available in print or as a PDF and is the most extensive source of information <u>in print</u> on Puppet.  The <a href="http://reductivelabs.com/trac/puppet/wiki">Reductive Labs Wiki</a> is another great source for up-to-date information.  Of course, the ultimate source for information on Puppet are the folks who created it.  Consider <a href="http://reductivelabs.com/services.html">hiring</a> Reductive Labs to provide training, services, or support.
</p>
<p>
While I work on writing Act Two, in order to keep you entertained, please enjoy <a href="http://www.madstop.com/">Luke Kanies&#8217;</a> Puppet presentation given at Silicon Valley&#8217;s <a href="http://www.baylisa.org/">BayLISA</a> event on August 2006.  It is a most informative and entertaining video with a run time of about 90 minutes.  Enjoy.  Exit stage right.
</p>
<p>
<embed id="VideoPlayback" src="http://video.google.com/googleplayer.swf?docid=8202036065161263530&#038;hl=en&#038;fs=true" style="width:400px;height:326px" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash"> </embed></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.securitymonks.com/2008/09/29/implementing-puppet-act-one/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ruby</title>
		<link>http://blog.securitymonks.com/2007/06/23/ruby/</link>
		<comments>http://blog.securitymonks.com/2007/06/23/ruby/#comments</comments>
		<pubDate>Sat, 23 Jun 2007 19:53:51 +0000</pubDate>
		<dc:creator>John Gerber</dc:creator>
				<category><![CDATA[Podcast]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.securitymonks.com/?p=40</guid>
		<description><![CDATA[&#8220;Penguins mate for life. Which doesn&#8217;t really surprise me, &#8217;cause they all look exactly alike. Its not like they&#8217;re gonna meet a better-looking penguin someday.&#8221;
&#8211; Ellen DeGeneres




Normally, I am pleased with myself if I can complete one post a week.  Still, I had to put in that extra effort this week in order to [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;<a href="http://en.thinkexist.com/quotation/penguins_mate_for_life-that_doesn-t_surprise_me/9849.html"><em>Penguins mate for life. Which doesn&#8217;t really surprise me, &#8217;cause they all look exactly alike. Its not like they&#8217;re gonna meet a better-looking penguin someday.</em></a>&#8221;<br />
&#8211; <strong><a href="http://en.wikipedia.org/wiki/Ellen_DeGeneres">Ellen DeGeneres</a></strong></p>
<p>
<a href="http://www.oreillynet.com/wateringhole/blog/strips/"><img src="/images/thewateringhole-008.png" alt="Ruby on Rails" align="left" width="100%" /></a>
</p>
<p>
Normally, I am pleased with myself if I can complete one post a week.  Still, I had to put in that extra effort this week in order to get <a href="http://www.oreillynet.com/pub/au/2978">James Turner </a> comic up.  The cartoon is bound to become a classic.  Well, maybe not among the masses.  Okay, maybe just among an elite group of people who can identify languages by the animals on their O&#8217;Reilly book covers.  Still, that is a pretty special group of people.
</p>
<p>Since I am posting a comic strip involving Ruby and Perl, I figured I would add a few pointers of interest.  If you are an old time Perl programmer, you will want to check out Jonathan Scott Duff&#8217;s posting on, &#8220;<a href="http://www.perl.com/pub/a/2007/05/10/everyday-perl-6.html">Everyday Perl 6</a>.&#8221;  <a href="http://www.perlcast.com/">Perlcast</a>, a podcast focus primarily on the Perl programming language, has posted a podcast on &#8220;<a href="http://wwhttp://perlcast.com/2007/06/18/presentation-learning-perl-6/">Learning Perl 6</a>.&#8221;  The presentation was done by <a href="http://www252.pair.com/comdog/">Brian D Foy</a> at the <a href="http://conferences.yapceurope.org/npw2007/">Nordic Perl Workshop 2007</a>.  <a href="http://www.pair.com/~comdog/Talks/LearningPerl6-NPW2007.pdf">Slides</a> along with the <a href="http://www.perlcast.com/audio/Perlcast_Presentation_004.mp3">audio podcast</a> of the presentation are available.  </p>
<p>
Not to show favoritism, on the <a href="http://google-code-updates.blogspot.com">Google Code Blog</a>, they did their <a href="http://google-code-updates.blogspot.com/2007/06/google-developer-podcast-episode-four.html">fourth podcast</a> where Mark Limber talks on <a href="http://sketchup.google.com/">Google SketchUp</a>.  To quote the Google SketchUp site:<br />
<blockquote>Developed for the conceptual stages of design, Google SketchUp is a powerful yet easy-to-learn 3D software tool that combines a simple, yet robust tool-set with an intelligent drawing system that streamlines and simplifies 3D design. From simple to complex, conceptual to realistic, Google SketchUp enables you to build and modify 3D models quickly and easily. If you use Google Earth, Google SketchUp allows you to place your models using real-world coordinates and share them with the world using the Google 3D Warehouse.</p></blockquote>
<p>Ruby is the scripting language that is used in SketchUp.  Sorry Perl.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.securitymonks.com/2007/06/23/ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.perlcast.com/audio/Perlcast_Presentation_004.mp3" length="25994357" type="audio/mpeg" />
		</item>
	</channel>
</rss>

