<?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>Mathiaz&#039;s Weblog &#187; puppet</title>
	<atom:link href="http://ubuntumathiaz.wordpress.com/category/puppet/feed/" rel="self" type="application/rss+xml" />
	<link>http://ubuntumathiaz.wordpress.com</link>
	<description>Some thoughts from an Ubuntu Developer</description>
	<lastBuildDate>Thu, 29 Sep 2011 15:59:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='ubuntumathiaz.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Mathiaz&#039;s Weblog &#187; puppet</title>
		<link>http://ubuntumathiaz.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://ubuntumathiaz.wordpress.com/osd.xml" title="Mathiaz&#039;s Weblog" />
	<atom:link rel='hub' href='http://ubuntumathiaz.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Overview of a Puppet Split CA architecture</title>
		<link>http://ubuntumathiaz.wordpress.com/2010/10/06/overview-of-a-puppet-split-ca-architecture/</link>
		<comments>http://ubuntumathiaz.wordpress.com/2010/10/06/overview-of-a-puppet-split-ca-architecture/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 21:49:14 +0000</pubDate>
		<dc:creator>Mathias Gug</dc:creator>
				<category><![CDATA[cloud]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://ubuntumathiaz.wordpress.com/?p=247</guid>
		<description><![CDATA[The Puppet Master CA is the only Certificate Authority (CA) in the whole infrastructure. It issues certificates for all Puppet agents. It also manages the Puppet Master systems. The Puppet Masters are only responsible for compiling catalogs requested by Puppet Agents &#8211; they don&#8217;t act as CA themselves. They only accept Puppet Agents which certificates [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ubuntumathiaz.wordpress.com&#038;blog=4897956&#038;post=247&#038;subd=ubuntumathiaz&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://ubuntumathiaz.files.wordpress.com/2010/10/overview.png"><img class="aligncenter size-full wp-image-252" title="Puppet Split CA architecture" src="http://ubuntumathiaz.files.wordpress.com/2010/10/overview.png?w=450" alt=""   /></a><br />
The Puppet Master CA is the only Certificate Authority (CA) in the whole infrastructure. It issues certificates for all Puppet agents. It also manages the Puppet Master systems.</p>
<p>The Puppet Masters are only responsible for compiling catalogs requested by Puppet Agents &#8211; they don&#8217;t act as CA themselves. They only accept Puppet Agents which certificates have been issued by the Puppet Master CA.</p>
<p>The Puppet Agent retrieves their certificates from the Puppet Master CA the first time they run. They connect to the Puppet Masters afterwards to get their catalogs. They won&#8217;t contact the Puppet Master CA anymore.</p>
<h3>Puppet Master CA</h3>
<p>The Puppet Master CA manages all Puppet Masters. In particular it distributes its own Certificate Revocation List (CRL) file to every Puppet Master. The Puppet Master CA also issues certificates to Puppet Agents.</p>
<h3>Puppet Master</h3>
<p>A Puppet Master runs under Apache and Passenger. Apache ssl module is configured to <strong>require</strong> certificates signed by the Puppet Master CA (<em>/etc/apache2/site-available/puppetmaster</em>):</p>
<pre> # Require certificates to be valid
 SSLVerifyClient require
 SSLVerifyDepth  1</pre>
<p>The Puppet Master is also configured to not act as a Puppet CA (<em>/etc/puppet/puppet.conf</em>):</p>
<pre> [main]
 ca = false</pre>
<h3>Puppet Agent</h3>
<p>Puppet Agents retrieve their certificate from the Puppet Master CA and request their catalog from one of the Puppet Masters (<em>/etc/puppet/puppet.conf</em>):</p>
<pre> [agent]
 ca_server = PUPPET_MASTER_CA
 server = PUPPET_MASTER</pre>
<h3>Conclusion</h3>
<p>From a security perspective setting the <em>SSLVerifyClient</em> option to <strong>require</strong> increases the protection of Puppet Masters from unknown requests and revoked Puppet Agents. Having the Puppet Master CA manage the Puppet Masters also facilitates the distribution of the Puppet Master CA CRL.</p>
<p>On the reliability front new systems won&#8217;t be added to the infrastructure if the Puppet Master CA is unavailable. However existing Puppet Agents are still functional as long as they can connect to a Puppet Master.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ubuntumathiaz.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ubuntumathiaz.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ubuntumathiaz.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ubuntumathiaz.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ubuntumathiaz.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ubuntumathiaz.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ubuntumathiaz.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ubuntumathiaz.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ubuntumathiaz.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ubuntumathiaz.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ubuntumathiaz.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ubuntumathiaz.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ubuntumathiaz.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ubuntumathiaz.wordpress.com/247/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ubuntumathiaz.wordpress.com&#038;blog=4897956&#038;post=247&#038;subd=ubuntumathiaz&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ubuntumathiaz.wordpress.com/2010/10/06/overview-of-a-puppet-split-ca-architecture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mathiaz</media:title>
		</media:content>

		<media:content url="http://ubuntumathiaz.files.wordpress.com/2010/10/overview.png" medium="image">
			<media:title type="html">Puppet Split CA architecture</media:title>
		</media:content>
	</item>
		<item>
		<title>Deploying a Hadoop cluster on EC2/UEC with Puppet and Ubuntu Maverick</title>
		<link>http://ubuntumathiaz.wordpress.com/2010/09/27/deploying-a-hadoop-cluster-on-ec2uec-with-puppet-and-ubuntu-maverick/</link>
		<comments>http://ubuntumathiaz.wordpress.com/2010/09/27/deploying-a-hadoop-cluster-on-ec2uec-with-puppet-and-ubuntu-maverick/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 01:02:08 +0000</pubDate>
		<dc:creator>Mathias Gug</dc:creator>
				<category><![CDATA[cloud]]></category>
		<category><![CDATA[hadoop]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://ubuntumathiaz.wordpress.com/?p=228</guid>
		<description><![CDATA[A Hadoop Cluster running on EC2/UEC deployed by puppet on Ubuntu Maverick. How it works The Cloud Conductor is located outside the AWS infrastructure as it needs AWS credentials to start new instances. The Puppet Master runs in EC2 and uses S3 to check which clients it should accept. The Hadoop Namenode, Jobtracker and Worker [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ubuntumathiaz.wordpress.com&#038;blog=4897956&#038;post=228&#038;subd=ubuntumathiaz&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://ubuntumathiaz.files.wordpress.com/2010/09/overview.png"><img class="alignnone size-full wp-image-229" title="Hadoop_Cluster_EC2_Puppet_Ubuntu" src="http://ubuntumathiaz.files.wordpress.com/2010/09/overview.png?w=450&h=300" alt="" width="450" height="300" /></a><br />
A Hadoop Cluster running on EC2/UEC deployed by puppet on Ubuntu Maverick.</p>
<h3>How it works</h3>
<p>The <a href="https://ubuntumathiaz.wordpress.com/2010/04/07/using-puppet-in-uecec2-node-classification-4/">Cloud Conductor</a> is located outside the AWS infrastructure as it needs AWS credentials to start new instances. The Puppet Master runs in EC2 and uses S3 to check which clients it should accept.</p>
<p>The Hadoop Namenode, Jobtracker and Worker are also running in EC2. The Puppet Master automatically configures them so that each Worker can connect to the Namenode and Jobtracker.</p>
<p>The Puppet Master uses<a href="http://projects.puppetlabs.com/projects/puppet/wiki/Using_Stored_Configuration"> Stored Configuration</a> to distribute configuration between all the Hadoop components. For example the Namenode IP address is automatically pushed to the Jobtracker and the Worker nodes so that they can connect to the Namenode.</p>
<p>Ubuntu Maverick is used since Puppet 2.6 is required. The excellent <a href="http://www.cloudera.com/">Cloudera</a> CDH3 Beta2 packages provide the base Hadoop foundation.</p>
<p>Puppet recipes and the Cloud Conductor scripts are available in a <a href="https://code.launchpad.net/~mathiaz/+junk/hadoop-cluster-puppet-conf/">bzr branch on Launchpad</a>.</p>
<h3>Setup the Cloud Conductor</h3>
<p>The first part of the Cloud Conductor is the <strong>start_instance.py</strong> script. It takes care of starting new instances in EC2 and registering them in S3. Its configuration lives in <strong>start_instance.yaml</strong>. Both files are located in the <strong>conductor</strong> directory of the bzr branch.</p>
<p>The following options are available on the cloud conductor:</p>
<ul>
<li><em>s3_bucket_name</em>: Sets the name of the S3 bucket used to store the list of instances started by the Cloud Conductor. The Puppet Master uses the same bucket to check which Puppet Client should be accepted.</li>
<li><em>ami_id</em>: Sets the id of the AMI the Cloud Conductor will use to start new instances.</li>
<li><em>cloud_init</em>: Sets specific cloud-init parameters. All of the puppet client configuration is defined here.Public ssh keys (for example from Launchpad) can be configured using the <strong>ssh_import_id</strong> option. The <a href="http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/maverick/cloud-init/maverick/files/head%3A/doc/">cloud-init documentation </a>has more information [1] about what can be configured when starting new instances.</li>
</ul>
<p>A sample <strong>start_instance.yaml</strong> file looks like this:</p>
<p><code># Name of the S3 bucket to use to store the certname of started instances<br />
s3_bucket_name: mathiaz-hadoop-cluster<br />
# Base AMI id to use to start all instances<br />
ami_id: ami-c210e5ab<br />
# Extra information passed to cloud-init when starting new instances<br />
# see cloud-init documentation for available options.<br />
cloud_init: &amp;site-cloud-init<br />
ssh_import_id: mathiaz</code></p>
<p>Once the Cloud Conductor is configured a Puppet Master can be started:<br />
<code> </code></p>
<p><code>./start_instance.py puppetmaster</code></p>
<h3>Setup the Puppet Master</h3>
<p>Once the instance has started and its ssh fingerprints can be verified the puppet recipes are deployed on the Puppet Master:<br />
<code> </code></p>
<p><code>bzr branch lp:~mathiaz/+junk/hadoop-cluster-puppet-conf ~/puppet/<br />
sudo mv /etc/puppet/ /etc/old.puppet<br />
sudo mv ~/puppet/ /etc/</code></p>
<p>The S3 bucket name is set in the Puppet Master configuration <strong>/etc/puppet/manifests/puppetmaster.pp</strong>:<br />
<code> </code></p>
<p><code>node default {<br />
class {<br />
"puppet::ca":<br />
node_bucket =&gt; "https://mathiaz-hadoop-cluster.s3.amazonaws.com";<br />
}<br />
}</code></p>
<p>And finally the Puppet Master installation can be completed by puppet itself:</p>
<p><code>sudo puppet apply /etc/puppet/manifests/puppetmaster.pp</code></p>
<p>A Puppet Master is now running into EC2 with all the recipes required to deploy the different components of a Hadoop Cluster.</p>
<h3>Update the Cloud Conductor configuration</h3>
<p>Since the Cloud Conductor starts instances that will connect to the Puppet Master it needs to know some information about the Puppet Master:</p>
<ul>
<li>the Puppet Master internal IP address or DNS name. For example the DNS name of the instance (which is the FQDN) can be used.</li>
<li>the Puppet Master certificate (located in <strong>/var/lib/puppet/ssl/ca/ca_crt.pem</strong>):</li>
</ul>
<p>On the Cloud Conductor the information gathered on the Puppet Master is added to <strong>start_instance.yaml</strong>:</p>
<p><code> agent:<br />
# Puppet server hostname or IP<br />
# In EC2 the Private DNS of the instance should be used<br />
server: domU-12-31-38-00-35-98.compute-1.internal<br />
# NB: the certname will automatically be added by start_instance.py<br />
# when a new instance is started.<br />
# Puppetmaster ca certificate<br />
# located in /var/lib/puppet/ssl/ca/ca_crt.pem on the puppetmaster system<br />
ca_cert: |<br />
-----BEGIN CERTIFICATE-----<br />
MIICFzCCAYCgAwIBAgIBATANBgkqhkiG9w0BAQUFADAUMRIwEAYDVQQDDAlQdXBw<br />
[ ... ]<br />
k0r/nTX6Tmr8TTU=<br />
-----END CERTIFICATE-----</code></p>
<h3>Start the Hadoop Namenode</h3>
<p>Once the Puppet Master and Cloud Conductor are configured the Hadoop Cluster can be deployed. First in line is the Hadoop Namenode:<br />
<code> </code></p>
<p><code>./start_instance.py namenode</code></p>
<p>After a few minutes the Namenode puppet client requests a certificate:<br />
<code> puppet-master[7397]: Starting Puppet master version 2.6.1<br />
puppet-master[7397]: 53b0b7bf-723c-4a0f-b4b1-082ebec84041 has a waiting certificate request</code><br />
The Master signs the CSR:<br />
<code> </code></p>
<p><code>CRON[8542]: (root) CMD (/usr/local/bin/check_csr https://mathiaz-hadoop-cluster.s3.amazonaws.com)<br />
check_csr[8543]: INFO: Signing request: 53b0b7bf-723c-4a0f-b4b1-082ebec84041</code></p>
<p>And finally the Master compiles the manifest for the Namenode:<br />
<code> </code></p>
<p><code>node_classifier[8989]: DEBUG: Checking url https://mathiaz-hadoop-cluster.s3.amazonaws.com/53b0b7bf-723c-4a0f-b4b1-082ebec84041<br />
node_classifier[8989]: INFO: Getting node configuration: 53b0b7bf-723c-4a0f-b4b1-082ebec84041<br />
node_classifier[8989]: DEBUG: Node configuration (53b0b7bf-723c-4a0f-b4b1-082ebec84041): classes: ['hadoop::namenode']<br />
puppet-master[7397]: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find stage hadoop-base specified by Class[Hadoop::Base] at /etc/puppet/modules/hadoop/manifests/init.pp:142 on node 53b0b7bf-723c-4a0f-b4b1-082ebec84041</code></p>
<p>Unfortunately there is a bug related to puppet stages. As a workaround the puppet agent can be restarted:<br />
<code> </code></p>
<p><code>sudo /etc/init.d/puppet restart</code></p>
<p>Looking at the syslog file on the Namenode the Puppet Agent installs and configures the Hadoop Namenode:<br />
<code> </code></p>
<p><code>puppet-agent[1795]: Starting Puppet client version 2.6.1<br />
puppet-agent[1795]: (/Stage[apt]/Hadoop::Apt/Apt::Key[cloudera]/File[/etc/apt/cloudera.key]/ensure) defined content as '{md5}dc59b632a1ce2ad325c40d0ba4a4927e'<br />
puppet-agent[1795]: (/Stage[apt]/Hadoop::Apt/Apt::Key[cloudera]/Exec[import apt key cloudera]) Triggered 'refresh' from 1 events<br />
puppet-agent[1795]: (/Stage[apt]/Hadoop::Apt/Apt::Sources_list[canonical]/File[/etc/apt/sources.list.d/canonical.list]/ensure) created<br />
puppet-agent[1795]: (/Stage[apt]/Hadoop::Apt/Apt::Sources_list[cloudera]/File[/etc/apt/sources.list.d/cloudera.list]/ensure) created<br />
puppet-agent[1795]: (/Stage[apt]/Apt::Apt/Exec[apt-get_update]) Triggered 'refresh' from 3 events</code></p>
<p>The first stage of the puppet run sets up the Canonical partner archive and the Cloudera archive. The Sun JVM is pulled from the Canonical archive while Hadoop packages are downloaded from the Cloudera archive.</p>
<p>The following stage creates a common Hadoop configuration:<br />
<code> </code></p>
<p><code>puppet-agent[1795]: (/Stage[hadoop-base]/Hadoop::Base/File[/var/cache/debconf/sun-java6.seeds]/ensure) defined content as '{md5}1e3a7ac4c2dc9e9c3a1ae9ab2c040794'<br />
puppet-agent[1795]: (/Stage[hadoop-base]/Hadoop::Base/Package[sun-java6-bin]/ensure) ensure changed 'purged' to 'latest'<br />
puppet-agent[1795]: (/Stage[hadoop-base]/Hadoop::Base/Package[hadoop-0.20]/ensure) ensure changed 'purged' to 'latest'<br />
puppet-agent[1795]: (/Stage[hadoop-base]/Hadoop::Base/File[/var/lib/hadoop-0.20/dfs]/ensure) created<br />
puppet-agent[1795]: (/Stage[hadoop-base]/Hadoop::Base/File[/etc/hadoop-0.20/conf.puppet]/ensure) created<br />
puppet-agent[1795]: (/Stage[hadoop-base]/Hadoop::Base/File[/etc/hadoop-0.20/conf.puppet/hdfs-site.xml]/ensure) defined content as '{md5}1f9788fceffdd1b2300c06160e7c364e'<br />
puppet-agent[1795]: (/Stage[hadoop-base]/Hadoop::Base/Exec[/usr/sbin/update-alternatives --install /etc/hadoop-0.20/conf hadoop-0.20-conf /etc/hadoop-0.20/conf.puppet 15]) Triggered 'refresh' from 1 events<br />
puppet-agent[1795]: (/Stage[hadoop-base]/Hadoop::Base/File[/etc/default/hadoop-0.20]/content) content changed '{md5}578894d1b3f7d636187955c15b8edb09' to '{md5}ecb699397751cbaec1b9ac8b2dd0b9c3'</code><br />
Finally the Hadoop Namenode is configured:<br />
<code> </code></p>
<p><code>puppet-agent[1795]: (/Stage[main]/Hadoop::Namenode/Package[hadoop-0.20-namenode]/ensure) ensure changed 'purged' to 'latest'<br />
puppet-agent[1795]: (/Stage[main]/Hadoop::Namenode/File[hadoop-core-site]/ensure) defined content as '{md5}2f2445bf3d4e26f5ceb3c32047b19419'<br />
puppet-agent[1795]: (/Stage[main]/Hadoop::Namenode/File[/var/lib/hadoop-0.20/dfs/name]/ensure) created<br />
puppet-agent[1795]: (/Stage[main]/Hadoop::Namenode/Exec[format-dfs]) Triggered 'refresh' from 1 events<br />
puppet-agent[1795]: (/Stage[main]/Hadoop::Namenode/Service[hadoop-0.20-namenode]/ensure) ensure changed 'stopped' to 'running'<br />
puppet-agent[1795]: (/Stage[main]/Hadoop::Namenode/Service[hadoop-0.20-namenode]) Failed to call refresh: Could not start Service[hadoop-0.20-namenode]: Execution of '/etc/init.d/hadoop-0.20-namenode start' returned 1:  at /etc/puppet/modules/hadoop/manifests/init.pp:177</code></p>
<p>There is another bug in the Hadoop init script this time: the Namenode cannot be started. The puppet agent can be restarted or the next puppet run will start it:<br />
<code> </code></p>
<p><code>sudo /etc/init.d/puppet restart</code></p>
<p>The Namenode daemon is running and logs information to its log file in <strong>/var/log/hadoop/hadoop-hadoop-namenode-*.log</strong>:<br />
<code> </code></p>
<p><code>[...]<br />
INFO org.apache.hadoop.hdfs.server.namenode.NameNode: Web-server up at: 0.0.0.0:50070<br />
[...]<br />
INFO org.apache.hadoop.ipc.Server: IPC Server handler 9 on 8200: starting<br />
INFO org.apache.hadoop.ipc.Server: IPC Server handler 8 on 8200: starting</code></p>
<h3>Start the Hadoop Jobtracker</h3>
<p>The next component to start is the Hadoop Jobtracker:<br />
<code> </code></p>
<p><code>./start_instance.py jobtracker</code></p>
<p>After some time the Puppet Master compiles the Jobtracker manifest:<br />
<code> </code></p>
<p><code>DEBUG: Checking url https://mathiaz-hadoop-cluster.s3.amazonaws.com/2faa4de9-c708-45ab-a515-ae041a9d0239<br />
node_classifier[30683]: INFO: Getting node configuration: 2faa4de9-c708-45ab-a515-ae041a9d0239<br />
node_classifier[30683]: DEBUG: Node configuration (2faa4de9-c708-45ab-a515-ae041a9d0239): classes: ['hadoop::jobtracker']<br />
puppet-master[23542]: Compiled catalog for 2faa4de9-c708-45ab-a515-ae041a9d0239 in environment production in 2.00 seconds</code></p>
<p>On the instance the puppet agent configures the Hadoop Jobtracker:<br />
<code> </code></p>
<p><code>puppet-agent[1035]: (/Stage[main]/Hadoop::Jobtracker/File[hadoop-mapred-site]/ensure) defined content as '{md5}af3b65a08df03e14305cc5fd56674867'<br />
puppet-agent[1035]: (/Stage[main]/Hadoop::Jobtracker/File[hadoop-core-site]/ensure) defined content as '{md5}2f2445bf3d4e26f5ceb3c32047b19419'<br />
puppet-agent[1035]: (/Stage[main]/Hadoop::Jobtracker/Package[hadoop-0.20-jobtracker]/ensure) ensure changed 'purged' to 'latest'<br />
puppet-agent[1035]: (/Stage[main]/Hadoop::Jobtracker/Service[hadoop-0.20-jobtracker]/ensure) ensure changed 'stopped' to 'running'<br />
puppet-agent[1035]: (/Stage[main]/Hadoop::Jobtracker/Service[hadoop-0.20-jobtracker]) Failed to call refresh: Could not start Service[hadoop-0.20-jobtracker]: Execution of '/etc/init.d/hadoop-0.20-jobtracker start' returned 1:  at /etc/puppet/modules/hadoop/manifests/init.pp:135</code></p>
<p>There is the same bug in the init script. Let&#8217;s restart the puppet agent:<br />
<code> </code></p>
<p><code>sudo /etc/init.d/puppet restart</code></p>
<p>The Jobtracker connects to the Namenode and error messages are logged on a regular basis to both the Namenode and Jobtracker log files:<br />
<code> </code></p>
<p><code>INFO org.apache.hadoop.ipc.Server: IPC Server handler 7 on 8200, call<br />
addBlock(/hadoop/mapred/system/jobtracker.info, DFSClient_-268101966, null)<br />
from 10.122.183.121:54322: error: java.io.IOException: File<br />
/hadoop/mapred/system/jobtracker.info could only be replicated to 0 nodes,<br />
instead of 1<br />
java.io.IOException: File /hadoop/mapred/system/jobtracker.info could only be<br />
replicated to 0 nodes, instead of 1</code></p>
<p>This is normal as there aren&#8217;t any Datanode daemon available for data replication.</p>
<h3>Start Hadoop workers</h3>
<p>It&#8217;s now time to start the Hadoop Worker to get an operational Hadoop Cluster:<br />
<code> </code></p>
<p><code>./start_instance.py worker</code></p>
<p>The Hadoop Worker holds both a Data node and a Task tracker. The Puppet agent configures them to talk to the Namenode and Job tracker respectively.</p>
<p>After some time the Puppet Master compiles the catalog for the Hadoop Worker:<br />
<code> </code></p>
<p><code>node_classifier[8368]: DEBUG: Checking url https://mathiaz-hadoop-cluster.s3.amazonaws.com/b72a8f4d-55e6-4059-ac4b-26927f1a1016<br />
node_classifier[8368]: INFO: Getting node configuration: b72a8f4d-55e6-4059-ac4b-26927f1a1016<br />
node_classifier[8368]: DEBUG: Node configuration (b72a8f4d-55e6-4059-ac4b-26927f1a1016): classes: ['hadoop::worker']<br />
puppet-master[23542]: Compiled catalog for b72a8f4d-55e6-4059-ac4b-26927f1a1016 in environment production in 0.18 seconds</code></p>
<p>On the instance the puppet agent installs the Hadoop worker:<br />
<code> </code></p>
<p><code>puppet-agent[1030]: (/Stage[main]/Hadoop::Worker/File[hadoop-mapred-site]/ensure) defined content as '{md5}af3b65a08df03e14305cc5fd56674867'<br />
puppet-agent[1030]: (/Stage[main]/Hadoop::Worker/Package[hadoop-0.20-datanode]/ensure) ensure changed 'purged' to 'latest'<br />
puppet-agent[1030]: (/Stage[main]/Hadoop::Worker/File[/var/lib/hadoop-0.20/dfs/data]/ensure) created<br />
puppet-agent[1030]: (/Stage[main]/Hadoop::Worker/Package[hadoop-0.20-tasktracker]/ensure) ensure changed 'purged' to 'latest'<br />
puppet-agent[1030]: (/Stage[main]/Hadoop::Worker/File[hadoop-core-site]/ensure) defined content as '{md5}2f2445bf3d4e26f5ceb3c32047b19419'<br />
puppet-agent[1030]: (/Stage[main]/Hadoop::Worker/Service[hadoop-0.20-datanode]/ensure) ensure changed 'stopped' to 'running'<br />
puppet-agent[1030]: (/Stage[main]/Hadoop::Worker/Service[hadoop-0.20-datanode]) Failed to call refresh: Could not start Service[hadoop-0.20-datanode]: Execution of '/etc/init.d/hadoop-0.20-datanode start' returned 1:  at /etc/puppet/modules/hadoop/manifests/init.pp:103<br />
puppet-agent[1030]: (/Stage[main]/Hadoop::Worker/Service[hadoop-0.20-tasktracker]/ensure) ensure changed 'stopped' to 'running'<br />
puppet-agent[1030]: (/Stage[main]/Hadoop::Worker/Service[hadoop-0.20-tasktracker]) Failed to call refresh: Could not start Service[hadoop-0.20-tasktracker]: Execution of '/etc/init.d/hadoop-0.20-tasktracker start' returned 1:  at /etc/puppet/modules/hadoop/manifests/init.pp:103</code></p>
<p>Again the same init script bug &#8211; let&#8217;s restart the puppet agent:<br />
<code> </code></p>
<p><code>sudo /etc/init.d/puppet restart</code></p>
<p>Once the worker is installed the Datanode daemon connects to the Namenode:<br />
<code> </code></p>
<p><code>INFO org.apache.hadoop.hdfs.StateChange: BLOCK* NameSystem.registerDatanode: node registration from 10.249.187.5:50010 storage DS-2066068566-10.249.187.5-50010-1285276011214<br />
INFO org.apache.hadoop.net.NetworkTopology: Adding a new node: /default-rack/10.249.187.5:50010</code></p>
<p>Similarly the Task Tracker daemon registers itself with the Jobtracker:<br />
<code> INFO org.apache.hadoop.net.NetworkTopology: Adding a new node: /default-rack/domU-12-31-39-03-B8-F7.compute-1.internal</code></p>
<p>The Hadoop Cluster is up and running.</p>
<h3>Conclusion</h3>
<p>Once the initial setup of the Puppet master is done and the Hadoop Namenode and Jobtracker are up and running adding new Hadoop Workers is<br />
just one command:</p>
<p><code> ./start_instance.py worker</code></p>
<p>Puppet automatically configures them to join the Hadoop Cluster.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ubuntumathiaz.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ubuntumathiaz.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ubuntumathiaz.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ubuntumathiaz.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ubuntumathiaz.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ubuntumathiaz.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ubuntumathiaz.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ubuntumathiaz.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ubuntumathiaz.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ubuntumathiaz.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ubuntumathiaz.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ubuntumathiaz.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ubuntumathiaz.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ubuntumathiaz.wordpress.com/228/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ubuntumathiaz.wordpress.com&#038;blog=4897956&#038;post=228&#038;subd=ubuntumathiaz&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ubuntumathiaz.wordpress.com/2010/09/27/deploying-a-hadoop-cluster-on-ec2uec-with-puppet-and-ubuntu-maverick/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mathiaz</media:title>
		</media:content>

		<media:content url="http://ubuntumathiaz.files.wordpress.com/2010/09/overview.png" medium="image">
			<media:title type="html">Hadoop_Cluster_EC2_Puppet_Ubuntu</media:title>
		</media:content>
	</item>
		<item>
		<title>Using puppet in UEC/EC2: Improving performance with Phusion Passenger</title>
		<link>http://ubuntumathiaz.wordpress.com/2010/04/08/using-puppet-in-uecec2-improving-performance-with-phusion-passenger/</link>
		<comments>http://ubuntumathiaz.wordpress.com/2010/04/08/using-puppet-in-uecec2-improving-performance-with-phusion-passenger/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 01:55:37 +0000</pubDate>
		<dc:creator>Mathias Gug</dc:creator>
				<category><![CDATA[cloud]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://ubuntumathiaz.wordpress.com/?p=187</guid>
		<description><![CDATA[Now that we have an efficient process to start instances within UEC/EC2 and get them configured for their task by puppet we&#8217;ll dive into improving the performance of the puppetmaster with Phusion Passenger. Why? The default configuration used by puppetmasterd is based on webrick which doesn&#8217;t really scale well. One popular choice to improve puppetmasterd [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ubuntumathiaz.wordpress.com&#038;blog=4897956&#038;post=187&#038;subd=ubuntumathiaz&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Now that we have an efficient process to <a class="reference external" href="http://ubuntumathiaz.wordpress.com/2010/03/24/using-puppet-in-uecec2-puppet-support-in-ubuntu-images/">start instances within UEC/EC2</a> and get them <a class="reference external" href="http://ubuntumathiaz.wordpress.com/2010/03/25/using-puppet-in-uecec2-automating-the-signing-process/">configured</a> <a class="reference external" href="http://ubuntumathiaz.wordpress.com/2010/04/07/using-puppet-in-uecec2-node-classification-4/">for their task</a> by puppet we&#8217;ll dive into improving the performance of the <tt class="docutils literal">puppetmaster</tt> with <a class="reference external" href="http://www.modrails.com/">Phusion Passenger</a>.</p>
<div id="why" class="section">
<h3>Why?</h3>
<p>The default configuration used by puppetmasterd is based on webrick which doesn&#8217;t really scale well. One popular choice to improve puppetmasterd performance is to use mod passenger from the <a class="reference external" href="http://packages.ubuntu.com/lucid/libapache2-mod-passenger">libapache2-mod-passenger package</a>.</p>
</div>
<div id="apache2-setup" class="section">
<h3>Apache2 setup</h3>
<p>The configuration is based on the <a class="reference external" href="http://projects.reductivelabs.com/projects/puppet/wiki/Using_Passenger">Puppet passenger documentation</a>. It is available from the <a class="reference external" href="https://code.launchpad.net/~mathiaz/+junk/uec-ec2-puppet-config-passenger">bzr branch</a> as we&#8217;ll use puppet to actually configure the instance running puppetmasterd.</p>
<p>The <a class="reference external" href="http://bazaar.launchpad.net/~mathiaz/%2Bjunk/uec-ec2-puppet-config-passenger/annotate/head%3A/modules/puppet/manifests/init.pp">puppet module</a> has been updated to make sure the apache2 and libapache2-mod-passenger packages are installed. It also creates the relevant files and directories required to run puppetmasterd as a rack application.</p>
<p>Passenger and SSL modules are enabled in the <a class="reference external" href="http://bazaar.launchpad.net/~mathiaz/%2Bjunk/uec-ec2-puppet-config-passenger/annotate/head%3A/modules/puppet/templates/apache2.conf">apache2 configuration</a>. All of their configuration is done inside a virtual host definition. Note that the SSL options related to certificates and private keys files points directly to<tt class="docutils literal"> /var/lib/puppet/ssl/</tt>.</p>
<p>Apache2 is also configured to only listen on the default puppetmaster port by replacing apache2 default <a class="reference external" href="http://bazaar.launchpad.net/%7Emathiaz/%2Bjunk/uec-ec2-puppet-config-passenger/annotate/head%3A/modules/puppet/files/ports.conf">ports.conf</a> and <a class="reference external" href="http://bazaar.launchpad.net/%7Emathiaz/%2Bjunk/uec-ec2-puppet-config-passenger/annotate/head%3A/modules/puppet/manifests/init.pp#L64">disabling</a> the default virtual site.</p>
<p>Finally the <a class="reference external" href="http://bazaar.launchpad.net/~mathiaz/%2Bjunk/uec-ec2-puppet-config-passenger/annotate/head%3A/puppet.conf">configuration</a> of puppetmasterd has been updated so that it can correctly process the certificate clients while being run under passenger.</p>
<p>Note that puppetmasterd needs to be run once in order to be able to generate its ssl configuration. This happens automatically when the puppetmaster package is installed since puppetmasterd is started during the package installation.</p>
</div>
<div id="deploying-an-improved-puppetmaster" class="section">
<h3>Deploying an improved puppetmaster</h3>
<p>Log on the puppetmaster instance and update the puppet configuration using the<a class="reference external" href="https://code.launchpad.net/~mathiaz/+junk/uec-ec2-puppet-config-passenger"> bzr branch</a>:</p>
<blockquote><p>bzr pull &#8211;remember lp:~mathiaz/+junk/uec-ec2-puppet-config-passenger /etc/puppet/</p></blockquote>
<p>Update the configuration:</p>
<blockquote><p>sudo puppet &#8211;node_terminus=plain /etc/puppet/manifests/puppetmaster.pp</p></blockquote>
<p>On the <tt class="docutils literal">Cloud Conductor</tt> start a new instance with <tt class="docutils literal">start_instance.py</tt>. If you&#8217;re starting from scratch remember to update the <tt class="docutils literal">start_instance.yaml</tt><br />
file with the puppetmaster CA and internal IP:</p>
<blockquote><p>./start_instance.py -c start_instance.yaml AMI_NUMBER</p></blockquote>
<p>Following <tt class="docutils literal">/var/log/syslog</tt> on the puppetmaster you should see the new instance requesting a certificate:</p>
<blockquote><p>Apr  8 00:40:08 ip-10-195-93-129 puppetmasterd[3353]: Starting Puppet server version 0.25.4<br />
Apr  8 00:40:08 ip-10-195-93-129 puppetmasterd[3353]: 7d6b61a7-3772-4c41-a23d-471b417d9c47 has a waiting certificate request</p></blockquote>
<p>Now that the puppetmasterd process is run by apache2 and mod-passenger you can check in <tt class="docutils literal">/var/log/apache2/other_vhosts_access.logs.log</tt> the http requests made by the puppet client to get its certificate signed:</p>
<blockquote><p>ip-10-195-93-129.ec2.internal:8140 10.195.94.224 &#8211; - [08/Apr/2010:00:40:06 +0000] &#8220;GET /production/certificate/7d6b61a7-3772-4c41-a23d-471b417d9c47 HTTP/1.1&#8243; 404 2178 &#8220;-&#8221; &#8220;-&#8221;<br />
ip-10-195-93-129.ec2.internal:8140 10.195.94.224 &#8211; - [08/Apr/2010:00:40:08 +0000] &#8220;GET /production/certificate_request/7d6b61a7-3772-4c41-a23d-471b417d9c47 HTTP/1.1&#8243; 404 2178 &#8220;-&#8221; &#8220;-&#8221;<br />
ip-10-195-93-129.ec2.internal:8140 10.195.94.224 &#8211; - [08/Apr/2010:00:40:08 +0000] &#8220;PUT /production/certificate_request/7d6b61a7-3772-4c41-a23d-471b417d9c47 HTTP/1.1&#8243; 200 2082 &#8220;-&#8221; &#8220;-&#8221;<br />
ip-10-195-93-129.ec2.internal:8140 10.195.94.224 &#8211; - [08/Apr/2010:00:40:08 +0000] &#8220;GET /production/certificate/7d6b61a7-3772-4c41-a23d-471b417d9c47 HTTP/1.1&#8243; 404 2178 &#8220;-&#8221; &#8220;-&#8221;<br />
ip-10-195-93-129.ec2.internal:8140 10.195.94.224 &#8211; - [08/Apr/2010:00:40:08 +0000] &#8220;GET /production/certificate/7d6b61a7-3772-4c41-a23d-471b417d9c47 HTTP/1.1&#8243; 404 2178 &#8220;-&#8221; &#8220;-&#8221;</p></blockquote>
<p>Once <tt class="docutils literal">check_csr</tt> is run by cron the certificate will be signed and the puppet client is able to retrieve its certificate:</p>
<blockquote><p>ip-10-195-93-129.ec2.internal:8140 10.195.94.224 &#8211; - [08/Apr/2010:00:42:08 +0000] &#8220;GET /production/certificate/7d6b61a7-3772-4c41-a23d-471b417d9c47 HTTP/1.1&#8243; 200 2962 &#8220;-&#8221; &#8220;-&#8221;<br />
ip-10-195-93-129.ec2.internal:8140 10.195.94.224 &#8211; - [08/Apr/2010:00:42:08 +0000] &#8220;GET /production/certificate_revocation_list/ca HTTP/1.1&#8243; 200 2450 &#8220;-&#8221; &#8220;-&#8221;</p></blockquote>
<p>The puppet client ends up requesting its manifest:</p>
<blockquote><p>ip-10-195-93-129.ec2.internal:8140 10.195.94.224 &#8211; - [08/Apr/2010:00:42:09 +0000] &#8220;GET /production/catalog/7d6b61a7-3772-4c41-a23d-471b417d9c47?facts_format=b64_zlib_yaml&amp;facts=eNp [....] HTTP/1.1&#8243; 200 2354 &#8220;-&#8221; &#8220;-&#8221;</p></blockquote>
</div>
<div id="conclusion" class="section">
<h3>Conclusion</h3>
<p>I&#8217;ve just outlined how to configure mod passeenger to run puppetmasterd which is a much more efficient setup than using the default webrick server. Most of the configuration is detailed in the files available in the <a class="reference external" href="https://code.launchpad.net/~mathiaz/+junk/uec-ec2-puppet-config-passenger">bzr branch</a>.</p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ubuntumathiaz.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ubuntumathiaz.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ubuntumathiaz.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ubuntumathiaz.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ubuntumathiaz.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ubuntumathiaz.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ubuntumathiaz.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ubuntumathiaz.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ubuntumathiaz.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ubuntumathiaz.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ubuntumathiaz.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ubuntumathiaz.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ubuntumathiaz.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ubuntumathiaz.wordpress.com/187/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ubuntumathiaz.wordpress.com&#038;blog=4897956&#038;post=187&#038;subd=ubuntumathiaz&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ubuntumathiaz.wordpress.com/2010/04/08/using-puppet-in-uecec2-improving-performance-with-phusion-passenger/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mathiaz</media:title>
		</media:content>
	</item>
		<item>
		<title>Using puppet in UEC/EC2: Node classification</title>
		<link>http://ubuntumathiaz.wordpress.com/2010/04/07/using-puppet-in-uecec2-node-classification-4/</link>
		<comments>http://ubuntumathiaz.wordpress.com/2010/04/07/using-puppet-in-uecec2-node-classification-4/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 20:58:57 +0000</pubDate>
		<dc:creator>Mathias Gug</dc:creator>
				<category><![CDATA[cloud]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://ubuntumathiaz.wordpress.com/?p=177</guid>
		<description><![CDATA[In a previous article I discussed how to set up an automated registration process for puppet instances. We&#8217;ll now have a look at how we can tell these instances what they should be doing. Going back to the overall architecture the Cloud conductor is the component responsible for starting new instances. Of all the three [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ubuntumathiaz.wordpress.com&#038;blog=4897956&#038;post=177&#038;subd=ubuntumathiaz&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In a <a class="reference external" href="https://ubuntumathiaz.wordpress.com/2010/03/25/using-puppet-in-uecec2-automating-the-signing-process/">previous article</a> I discussed how to set up an automated registration process for puppet instances. We&#8217;ll now have a look at how we can tell these instances what they should be doing.</p>
<p>Going back to the <a class="reference external" href="https://ubuntumathiaz.wordpress.com/2010/03/25/using-puppet-in-uecec2-automating-the-signing-process/#overview">overall architecture</a> the <tt class="docutils literal">Cloud conductor</tt> is the component responsible for starting new instances. Of all the three components it&#8217;s him that has the most knowledge about what an instance should be: it is the one responsible for starting a new instance after all.</p>
<div id="using-s3-to-store-node-definitions" class="section">
<h3>Using S3 to store node definitions</h3>
<p>We&#8217;ll use the <a class="reference external" href="http://projects.reductivelabs.com/projects/puppet/wiki/External_Nodes">puppet external node</a> feature to connect the <tt class="docutils literal">Cloud conductor</tt> with the <tt class="docutils literal">puppetmaster</tt>. The external node script -<a class="reference external" href="http://bazaar.launchpad.net/%7Emathiaz/%2Bjunk/uec-ec2-puppet-config-tut3/annotate/head%3A/scripts/node_classifier.py">node_classifier.py</a> &#8211; will be responsible for telling which classes each instance is supposed to have. Whenever a puppet client connects to the master the <tt class="docutils literal">node_classifier.py</tt> script is called with the certificate name. It is responsible for providing a description of the classes, environments and parameters for the client on its standard output in a yaml format.</p>
<p>Given that the <tt class="docutils literal">Cloud conductor</tt> creates a file with the certificate name for each instance it spawns we&#8217;ll extend the <a class="reference external" href="http://bazaar.launchpad.net/%7Emathiaz/%2Bjunk/uec-ec2-puppet-config-tut3/annotate/head%3A/scripts/start_instance.py">start_instance.py</a> script to store the node classification in the content of the file created in the S3 bucket.</p>
<p>You may have noticed that instances started by <tt class="docutils literal">start_instance.py</tt> don&#8217;t have an ssh public key associated with them. So we&#8217;re going to create a<tt class="docutils literal"><span class="pre"> login-allowed</span></tt> class that will install the authorized key for the ubuntu user.</p>
</div>
<div id="setup-the-puppetmaster-to-use-the-node-classifier" class="section">
<h3>Setup the puppetmaster to use the node classifier</h3>
<p>We&#8217;ll use the <a class="reference external" href="http://uec-images.ubuntu.com/releases/lucid/beta-2/">Ubuntu Lucid Beta2 image</a> as the base image on which to build our Puppet infrastructure.</p>
<p>Start an instance of the Lucid Beta2 AMI using an ssh key. Once it&#8217;s running write down its public and private DNS addresses. The public DNS address will be used to setup the puppetmaster via ssh. The private DNS address will be used as the puppetmaster hostname given out to puppet clients.</p>
<p>Log on the started instance via ssh to install and setup the puppet master:</p>
<ol class="arabic">
<li>
<p class="first">Update apt files:</p>
<blockquote><p>sudo apt-get update</p></blockquote>
</li>
<li>
<p class="first">Install the puppet and bzr packages:</p>
<blockquote><p>sudo apt-get install puppet bzr</p></blockquote>
</li>
<li>
<p class="first">Change the ownership of the puppet directory so that the ubuntu user can directly edit the puppet configuration files:</p>
<blockquote><p>sudo chown -R ubuntu:ubuntu /etc/puppet/</p></blockquote>
</li>
<li>
<p class="first">On the puppetmaster check out the <a class="reference external" href="https://code.launchpad.net/~mathiaz/+junk/uec-ec2-puppet-config-tut3">tutorial3</a> bzr branch:</p>
<blockquote><p>bzr branch &#8211;use-existing-dir lp:~mathiaz/+junk/uec-ec2-puppet-config-tut3 /etc/puppet/</p></blockquote>
<p>You&#8217;ll get a conflict for the puppet.conf file. You can ignore the conflict as the puppet.conf file from the branch is the one that supports an external node classifier:</p>
<blockquote><p>bzr resolve /etc/puppet/puppet.conf</p></blockquote>
</li>
</ol>
<p>Edit the node classifier script <tt class="docutils literal">scripts/node_classifier.py</tt> to set the correct location of your S3 bucket.</p>
<p>Note that the script is set to return 1 if the certificate name doesn&#8217;t have a corresponding file in the S3 bucket. You may want to change the return code to 0 if you want to use the normal nodes definition. See the <a class="reference external" href="http://projects.reductivelabs.com/projects/puppet/wiki/External_Nodes">puppet external node</a> documentation for more information.</p>
<p>The puppetmaster configuration in <tt class="docutils literal">puppet.conf</tt> has been updated to use the external node script.</p>
<p>There is also the <tt class="docutils literal"><span class="pre">login-allowed</span></tt> class defined in the <tt class="docutils literal">manifests/site.pp</tt><tt> </tt>file. It sets the authorized key file for the ubuntu user.</p>
<p>On the puppetmaster edit <tt class="docutils literal">manifests/site.pp</tt> to update the public key with your EC2 public key. You can get the public key from<tt class="docutils literal"><span class="pre"> ~ubuntu/.ssh/authorized_key</span></tt> on the puppetmaster.</p>
<p>To bootstrap the new puppetmaster configuration run the puppet client:</p>
<blockquote><p>sudo puppet &#8211;node_terminus=plain /etc/puppet/manifests/puppetmaster.pp</p></blockquote>
<p>Note that you&#8217;ll have to set the node_terminus to plain to avoid calling the node classifier script when configuring the puppetmaster itself. Otherwise the puppet run would fail since the puppetmaster certificate name (which defaults the to fqdn of the instance) doesn&#8217;t have a corresponding file in the S3 bucket.</p>
<p>We have now our puppetmaster configured to look up the node classification for each puppet client.</p>
</div>
<div id="update-start-instance-py-to-provide-a-node-definition" class="section">
<h3>Update start_instance.py to provide a node definition</h3>
<p>It&#8217;s time to update the <tt class="docutils literal">Cloud conductor</tt> to provide the relevant node classification information whenever it starts a new instance.</p>
<p>Update the bzr branch on the <tt class="docutils literal">Cloud conductor</tt> system:</p>
<blockquote><p>bzr pull &#8211;remember lp:~mathiaz/uec-puppet-config-tut3</p></blockquote>
<p>The <tt class="docutils literal">start_instance.py</tt> script has been updated to write the node classification information when it creates the instance file in the S3 bucket. That information is actually set in the <tt class="docutils literal">start_instance.yaml</tt> file under the node key. All of the node classification information expected by the puppetmaster from the external node classifier script is set under the <tt class="docutils literal">node</tt><tt> </tt>key in <tt class="docutils literal">start_instance.yaml</tt>. See the <a class="reference external" href="http://projects.reductivelabs.com/projects/puppet/wiki/External_Nodes">puppet external node</a> documentation for more information on the information that can be provided by the external node script.</p>
<p>Review the <tt class="docutils literal">start_instance.yaml</tt> file to make sure the S3 bucket name, the puppetmaster server IP and CA certificate are still valid for your own setup.</p>
<p>Start an instance:</p>
<blockquote><p>./start_instance.py -c start_instance.yaml AMI_NUMBER</p></blockquote>
<p>Following <tt class="docutils literal">/var/log/syslog</tt> you should see something similar to this:</p>
<blockquote><p>Apr  7 19:15:37 domU-12-31-39-07-D6-52 puppetmasterd[1644]: 77ad2a3c-5d52-4ca7-9fea-b99b767b09d0 has a waiting certificate request</p></blockquote>
<p>The instance has booted and registered with the puppetmaster.</p>
<blockquote><p>Apr  7 19:16:01 domU-12-31-39-07-D6-52 CRON[2188]: (root) CMD (/usr/local/bin/check_csr &#8211;log-level=debug <a class="reference external" href="https://mathiaz-puppet-nodes-1.s3.amazonaws.com">https://mathiaz-puppet-nodes-1.s3.amazonaws.com</a>)<br />
Apr  7 19:16:02 domU-12-31-39-07-D6-52 check_csr[2189]: DEBUG: List of waiting csr: 77ad2a3c-5d52-4ca7-9fea-b99b767b09d0<br />
Apr  7 19:16:02 domU-12-31-39-07-D6-52 check_csr[2189]: DEBUG: Checking 77ad2a3c-5d52-4ca7-9fea-b99b767b09d0<br />
Apr  7 19:16:02 domU-12-31-39-07-D6-52 check_csr[2189]: DEBUG: Checking url <a class="reference external" href="https://mathiaz-puppet-nodes-1.s3.amazonaws.com/77ad2a3c-5d52-4ca7-9fea-b99b767b09d0">https://mathiaz-puppet-nodes-1.s3.amazonaws.com/77ad2a3c-5d52-4ca7-9fea-b99b767b09d0</a><br />
Apr  7 19:16:03 domU-12-31-39-07-D6-52 check_csr[2189]: INFO: Signing request: 77ad2a3c-5d52-4ca7-9fea-b99b767b09d0</p></blockquote>
<p>The puppetmaster checked if the client request is expected and signs it.</p>
<blockquote><p>Apr  7 19:17:39 domU-12-31-39-07-D6-52 node_classifier[2240]: DEBUG: Checking url <a class="reference external" href="https://mathiaz-puppet-nodes-1.s3.amazonaws.com/77ad2a3c-5d52-4ca7-9fea-b99b767b09d0">https://mathiaz-puppet-nodes-1.s3.amazonaws.com/77ad2a3c-5d52-4ca7-9fea-b99b767b09d0</a><br />
Apr  7 19:17:39 domU-12-31-39-07-D6-52 node_classifier[2240]: INFO: Getting node configuration: 77ad2a3c-5d52-4ca7-9fea-b99b767b09d0<br />
Apr  7 19:17:39 domU-12-31-39-07-D6-52 node_classifier[2240]: DEBUG: Node configuration (77ad2a3c-5d52-4ca7-9fea-b99b767b09d0): classes: [login-allowed]<br />
Apr  7 19:17:39 domU-12-31-39-07-D6-52 puppetmasterd[1644]: Compiled catalog for 77ad2a3c-5d52-4ca7-9fea-b99b767b09d0 in 0.01 seconds</p></blockquote>
<p>The puppetmaster compiled a manifest for the client according to the information provided by the node classifier script.</p>
<p>Make sure that the instance that has been started doesn&#8217;t have any ssh key associated with it:</p>
<blockquote><p>euca-describe-instances</p></blockquote>
<p>Make a note of the instance ID and its public DNS name.</p>
<p>Login into the instance:</p>
<ol class="arabic">
<li>
<p class="first">Run <tt class="docutils literal"><span class="pre">euca-get-console-output</span> instance_ID</tt> to get the ssh fingerprint.  You may need to scroll back to get the fingerprints.</p>
</li>
<li>
<p class="first">Login into the instances using your EC2 public key:</p>
<blockquote><p>ssh -i ~/.ssh/ec2_key <a class="reference external" href="mailto:ubuntu@public_dns">ubuntu@public_dns</a></p></blockquote>
</li>
</ol>
</div>
<div id="conclusion" class="section">
<h3>Conclusion</h3>
<p>The <a class="reference external" href="http://bazaar.launchpad.net/%7Emathiaz/%2Bjunk/uec-ec2-puppet-config-tut3/annotate/head%3A/scripts/start_instance.py">start_instance.py</a> script is currently very simple and should be considered as a proof of concept.</p>
<p>Storing the node classification information into an S3 bucket makes it also easy to edit the content of the file. It also provides an easy way to get a list of the nodes that have been started by the Cloud Conductor as well as their classification.</p>
<p>If you look at the <a class="reference external" href="http://bazaar.launchpad.net/%7Emathiaz/%2Bjunk/uec-ec2-puppet-config-tut3/annotate/head%3A/scripts/start_instance.py">start_instance.py</a> script you&#8217;ll notice that the ACL on the S3 bucket is &#8216;public-read&#8217;. That means anyone can read the list of your nodes as well as the list of classes and other node classification information for each of them. You may wanna use S3 private url instead.</p>
<p>We now have a puppet infrastructure where <tt class="docutils literal">instances</tt> are started by a<tt class="docutils literal"> Cloud conductor</tt> in order to achieve a specific task. These <tt class="docutils literal">instances</tt> automatically connect to the <tt class="docutils literal">puppetmaster</tt> to get configured automatically for the task they&#8217;ve been created for. All of the <tt class="docutils literal">instances</tt> configuration is stored in a reliable and scalable system: S3.</p>
<p>With instances being created on demand our puppet infrastructure can grow quickly. The <tt class="docutils literal">puppetmaster</tt> can easily be responsible for managing hundreds of instances. Next we&#8217;ll have a look at how improving the performance of the<tt class="docutils literal"> puppetmaster</tt>.</p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ubuntumathiaz.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ubuntumathiaz.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ubuntumathiaz.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ubuntumathiaz.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ubuntumathiaz.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ubuntumathiaz.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ubuntumathiaz.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ubuntumathiaz.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ubuntumathiaz.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ubuntumathiaz.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ubuntumathiaz.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ubuntumathiaz.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ubuntumathiaz.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ubuntumathiaz.wordpress.com/177/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ubuntumathiaz.wordpress.com&#038;blog=4897956&#038;post=177&#038;subd=ubuntumathiaz&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ubuntumathiaz.wordpress.com/2010/04/07/using-puppet-in-uecec2-node-classification-4/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mathiaz</media:title>
		</media:content>
	</item>
		<item>
		<title>Using puppet in UEC/EC2: Automating the signing process</title>
		<link>http://ubuntumathiaz.wordpress.com/2010/03/25/using-puppet-in-uecec2-automating-the-signing-process/</link>
		<comments>http://ubuntumathiaz.wordpress.com/2010/03/25/using-puppet-in-uecec2-automating-the-signing-process/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 20:54:03 +0000</pubDate>
		<dc:creator>Mathias Gug</dc:creator>
				<category><![CDATA[cloud]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://ubuntumathiaz.wordpress.com/?p=151</guid>
		<description><![CDATA[I outlined in the previous article how to setup a puppetmaster instance on UEC/EC2 and how to start instances that will automatically register with the puppetmaster. We&#8217;re going to look at automating the process of signing puppet client certificate requests. Overview Our puppet infrastructure on the cloud can be broken down into three components: The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ubuntumathiaz.wordpress.com&#038;blog=4897956&#038;post=151&#038;subd=ubuntumathiaz&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I outlined in the <a class="reference external" href="http://ubuntumathiaz.wordpress.com/2010/03/24/using-puppet-in-uecec2-puppet-support-in-ubuntu-images/">previous article</a> how to setup a puppetmaster instance on UEC/EC2 and how to start instances that will automatically register with the puppetmaster. We&#8217;re going to look at automating the process of signing puppet client certificate requests.</p>
<div class="section" id="overview">
<h3>Overview</h3>
<p>Our puppet infrastructure on the cloud can be broken down into three components:</p>
<ul class="simple">
<li>The <tt class="docutils literal"><span class="pre">Cloud</span> <span class="pre">conductor</span></tt> responsible for starting new instances in our cloud.</li>
<li>A <tt class="docutils literal"><span class="pre">Puppetmaster</span></tt> responsible for configuring all the instances running in our cloud.</li>
<li><tt class="docutils literal"><span class="pre">Instances</span></tt> acting as puppet clients asking to be setup correctly.</li>
</ul>
<p>The idea is to have the <tt class="docutils literal"><span class="pre">Cloud</span> <span class="pre">conductor</span></tt> start <tt class="docutils literal"><span class="pre">instances</span></tt> and notify the <tt class="docutils literal"><span class="pre">puppetmaster</span></tt> that these new instances are coming up. The <tt class="docutils literal"><span class="pre">puppetmaster</span></tt> can then automatically sign their certificate requests.</p>
<p>We&#8217;ll use S3 as the way to communicate between the <tt class="docutils literal"><span class="pre">Cloud</span> <span class="pre">conductor</span></tt> and the <tt class="docutils literal"><span class="pre">puppetmaster</span></tt>. The <tt class="docutils literal"><span class="pre">Cloud</span> <span class="pre">conductor</span></tt> will also assign a random certificate to each instance it starts.</p>
<p>The <tt class="docutils literal"><span class="pre">Cloud</span> <span class="pre">conductor</span></tt> will be located on a sysadmin workstation while the <tt class="docutils literal"><span class="pre">puppetmaster</span></tt> and <tt class="docutils literal"><span class="pre">instances</span></tt> will be running in the cloud. The <a class="reference external" href="https://code.launchpad.net/~mathiaz/+junk/uec-ec2-puppet-config-tut2">bzr branch</a> contains all the scripts necessary to setup such a solution.</p>
</div>
<div class="section" id="the-cloud-conductor-start-instance-py">
<h3>The Cloud conductor: start_instance.py</h3>
<ol class="arabic">
<li>
<p class="first">Get the tutorial2 bzr on the <tt class="docutils literal"><span class="pre">Cloud</span> <span class="pre">conductor</span></tt> (an admin workstation):</p>
<blockquote>
<p>bzr branch lp:~mathiaz/+junk/uec-ec2-puppet-config-tut2</p>
</blockquote>
<p>In the <tt class="docutils literal"><span class="pre">scripts/</span></tt> directory <a class="reference external" href="http://bazaar.launchpad.net/%7Emathiaz/%2Bjunk/uec-ec2-puppet-config-tut2/annotate/head%3A/scripts/start_instance.py">start_instance.py</a> plays the role of the <tt class="docutils literal"><span class="pre">Cloud</span> <span class="pre">conductor</span></tt>. It creates new instances and stores their certname in S3. The <em>start_instance.yaml</em> configuration file provides almost the same information as the <tt class="docutils literal"><span class="pre">user-data.yaml</span></tt> file we used in the previous article.</p>
</li>
<li>
<p class="first">Edit the <em>start_instance.yaml</em> file and update each setting:</p>
<ul class="simple">
<li>Choose a unique S3 bucket name.</li>
<li>Use the private DNS hostname of the instance running the puppetmaster.</li>
<li>Add the puppetmaster ca certificate found on the puppetmaster.</li>
</ul>
</li>
<li>
<p class="first">Make sure your AWS/UEC credentials are available in the environment. The <em>start_instance.py</em> uses these to access EC2 to start new instances and S3 to store the instance certificate names.</p>
</li>
<li>
<p class="first">Start a new instance of the Lucid Beta1 AMI:</p>
<blockquote>
<p>./start_instance.py -c ./start_instance.yaml ami-ad09e6c4</p>
</blockquote>
<p><em>start_instance.py</em> starts a new instance using the AMI specified on the command line. The instance user data holds a random UUID for the puppet client certificate name. <em>start_instance.py</em> also creates a new file in its S3 bucket named after the puppet client certificate name.</p>
</li>
<li>
<p class="first">On the puppetmater looking at the puppetmaster log you should see a certificate request show up after some time:</p>
<blockquote>
<p>Mar 19 19:09:33 ip-10-245-197-226 puppetmasterd[20273]: a83b0057-ab8d-426e-b2ab-175729742adb has a waiting certificate request</p>
</blockquote>
</li>
</ol>
</div>
<div class="section" id="automating-the-signing-process-on-the-puppetmaster">
<h3>Automating the signing process on the puppetmaster</h3>
<p>It&#8217;s time to setup the puppetmaster to check if there are any certificate requests waiting and signs only the ones started by the <tt class="docutils literal"><span class="pre">Cloud</span> <span class="pre">conductor</span></tt>. We&#8217;ll use the <a class="reference external" href="http://bazaar.launchpad.net/%7Emathiaz/%2Bjunk/uec-ec2-puppet-config-tut2/annotate/head%3A/scripts/check_csr.py">check_csr.py cron job</a> that will get the list of waiting certificate requests via <tt class="docutils literal"><span class="pre">puppetca</span> <span class="pre">--list</span></tt> and checks whether there is a corresponding file in the S3 bucket.</p>
<ol class="arabic">
<li>
<p class="first">On the puppetmaster get the <cite>tutorial2</cite> bzr branch:</p>
<blockquote>
<p>bzr pull &#8211;remember lp:~mathiaz/+junk/uec-ec2-config/tut2 /etc/puppet/</p>
</blockquote>
</li>
<li>
<p class="first">The <a class="reference external" href="http://bazaar.launchpad.net/%7Emathiaz/%2Bjunk/uec-ec2-puppet-config-tut2/annotate/head%3A/manifests/puppetmaster.pp">puppetmaster.pp</a> manifest has been updated to setup the <tt class="docutils literal"><span class="pre">check_csr.py</span></tt> cron job to run every 2 minutes. You need to update the cron job command line in <tt class="docutils literal"><span class="pre">/etc/puppet/manifests/puppetmaster.pp</span></tt> with your own S3 bucket name.</p>
</li>
<li>
<p class="first">Update the puppetmaster configuration:</p>
<blockquote>
<p>sudo puppet /etc/puppet/manifests/puppetmaster.pp</p>
</blockquote>
</li>
<li>
<p class="first">Watching <tt class="docutils literal"><span class="pre">/var/log/syslog</span></tt> you should see <em>check_csr</em> being run by cron every other minute:</p>
<blockquote>
<p>Mar 19 19:10:01 ip-10-245-197-226 CRON[21858]: (root) CMD (/usr/local/bin/check_csr &#8211;log-level=debug <a class="reference external" href="https://mathiaz-puppet-nodes-1.s3.amazonaws.com">https://mathiaz-puppet-nodes-1.s3.amazonaws.com</a>)</p>
</blockquote>
<p><em>check_csr</em> gets the list of waiting certificate requests and checks if there is a corresponding file in its S3 bucket:</p>
<blockquote>
<p>Mar 19 19:10:03 ip-10-245-197-226 check_csr[21859]: DEBUG: List of waiting csr: a83b0057-ab8d-426e-b2ab-175729742adb<br />
Mar 19 19:10:03 ip-10-245-197-226 check_csr[21859]: DEBUG: Checking a83b0057-ab8d-426e-b2ab-175729742adb<br />
Mar 19 19:10:03 ip-10-245-197-226 check_csr[21859]: DEBUG: Checking url <a class="reference external" href="https://mathiaz-puppet-nodes-1.s3.amazonaws.com/a83b0057-ab8d-426e-b2ab-175729742adb">https://mathiaz-puppet-nodes-1.s3.amazonaws.com/a83b0057-ab8d-426e-b2ab-175729742adb</a></p>
</blockquote>
<p>If so it will sign the certificate request:</p>
<blockquote>
<p>Mar 19 19:10:03 ip-10-245-197-226 check_csr[21859]: INFO: Signing request: a83b0057-ab8d-426e-b2ab-175729742adb</p>
</blockquote>
</li>
</ol>
</div>
<div class="section" id="s3-bucket-acl">
<h3>S3 bucket ACL</h3>
<p>For now the S3 bucket ACL is set so that anyone can get the list files available in the bucket. However only authenticated requests can create new files in the bucket. Given that the filename are just random UUID this is not a big issue.</p>
</div>
<div class="section" id="using-sqs-instead-of-s3">
<h3>Using SQS instead of S3</h3>
<p>Another implementation of the same idea is to use SQS to handle the notification of the <tt class="docutils literal"><span class="pre">puppetmaster</span></tt> by the <tt class="docutils literal"><span class="pre">Cloud</span> <span class="pre">conductor</span></tt> about new <tt class="docutils literal"><span class="pre">instances</span></tt>. While SQS would seem to be the best tool to provide that functionality it is not available in UEC in Lucid.</p>
</div>
<div class="section" id="conclusion">
<h3>Conclusion</h3>
<p>We end up with a puppet infrastructure where legitimate instances are automatically accepted. Now that instances can easily show up and be automatically enrolled <em>what</em> should these be configured as? We&#8217;ll dive into this issue in the next article.</p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ubuntumathiaz.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ubuntumathiaz.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ubuntumathiaz.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ubuntumathiaz.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ubuntumathiaz.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ubuntumathiaz.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ubuntumathiaz.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ubuntumathiaz.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ubuntumathiaz.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ubuntumathiaz.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ubuntumathiaz.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ubuntumathiaz.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ubuntumathiaz.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ubuntumathiaz.wordpress.com/151/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ubuntumathiaz.wordpress.com&#038;blog=4897956&#038;post=151&#038;subd=ubuntumathiaz&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ubuntumathiaz.wordpress.com/2010/03/25/using-puppet-in-uecec2-automating-the-signing-process/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mathiaz</media:title>
		</media:content>
	</item>
		<item>
		<title>Using puppet in UEC/EC2: puppet support in Ubuntu images</title>
		<link>http://ubuntumathiaz.wordpress.com/2010/03/24/using-puppet-in-uecec2-puppet-support-in-ubuntu-images/</link>
		<comments>http://ubuntumathiaz.wordpress.com/2010/03/24/using-puppet-in-uecec2-puppet-support-in-ubuntu-images/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 20:56:32 +0000</pubDate>
		<dc:creator>Mathias Gug</dc:creator>
				<category><![CDATA[cloud]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://ubuntumathiaz.wordpress.com/?p=142</guid>
		<description><![CDATA[One of the focus for the Lucid release cycle in the Ubuntu Server team is to improve the integration between puppet and UEC/EC2. I&#8217;ll discuss in a series of articles how to setup a puppet infrastructure to manage Ubuntu Lucid instances running on UEC/EC2. I&#8217;ll focus on the bootstrapping process rather than writing puppet recipes. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ubuntumathiaz.wordpress.com&#038;blog=4897956&#038;post=142&#038;subd=ubuntumathiaz&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the focus for the Lucid release cycle in the Ubuntu Server team is to <a class="reference external" href="https://blueprints.launchpad.net/ubuntu/+spec/server-lucid-puppet-uec-ec2-integration">improve the integration between puppet and UEC/EC2</a>. I&#8217;ll discuss in a series of articles how to setup a puppet infrastructure to manage Ubuntu Lucid instances running on UEC/EC2. I&#8217;ll focus on the bootstrapping process rather than writing puppet recipes.</p>
<p>Today we&#8217;ll look at configuring a puppetmaster into an instance and how to start instances that will register automatically with the puppetmaster.</p>
<p>We&#8217;ll work with the <a class="reference external" href="http://uec-images.ubuntu.com/releases/lucid/beta-1/">Lucid Beta1 image</a> on EC2. All the instances started through out this article will be based on this AMI.</p>
<div class="section" id="puppetmaster-setup">
<h2>Puppetmaster setup</h2>
<p>Let&#8217;s start by creating a puppetmaster running on EC2. We&#8217;ll setup all the puppet configuration via ssh using a bzr branch on Launchpad: <a class="reference external" href="https://code.launchpad.net/~mathiaz/+junk/uec-ec2-puppet-config-tut1">lp:~mathiaz/+junk/uec-ec2-puppet-config-tut1</a>.</p>
<p>Start an instance of the Lucid Beta1 AMI using an ssh key. Once it&#8217;s running write down its public and private DNS addresses. The public DNS address will be used to setup the puppetmaster via ssh. The private DNS address will be used as the puppetmaster hostname given out to puppet clients.</p>
<p>We&#8217;ll actually install the puppetmaster using puppet itself.</p>
<p>Log on the started instance via ssh to install and setup the puppet master:</p>
<ol class="arabic">
<li>
<p class="first">Update apt files:</p>
<blockquote>
<p>sudo apt-get update</p>
</blockquote>
</li>
<li>
<p class="first">Install the puppet and bzr packages:</p>
<blockquote>
<p>sudo apt-get install puppet bzr</p>
</blockquote>
</li>
<li>
<p class="first">Change the ownership of the puppet directory so that the ubuntu user can directly edit the puppet configuration files:</p>
<blockquote>
<p>sudo chown ubuntu:ubuntu /etc/puppet/</p>
</blockquote>
</li>
<li>
<p class="first">Get the puppet configuration branch:</p>
<blockquote>
<p>bzr branch &#8211;use-existing-directory lp:~mathiaz/+junk/uec-ec2-puppet-config-tut1 /etc/puppet/</p>
</blockquote>
<p>Before doing the actual configuration let&#8217;s have a look at the content of the <tt class="docutils literal"><span class="pre">/etc/puppet/</span></tt> directory created from the bzr branch.</p>
<p>The layout follows the <a class="reference external" href="http://projects.reductivelabs.com/projects/puppet/wiki/Puppet_Best_Practice">recommended puppet practices</a>. The puppet module available in the <tt class="docutils literal"><span class="pre">modules</span></tt> directory defines a <tt class="docutils literal"><span class="pre">puppet::master</span></tt> class. The class makes sure that the puppetmaster package is installed and that the puppetmaster service is running. The <tt class="docutils literal"><span class="pre">manifests/puppetmaster.pp</span></tt> file defines the default node to be configured as a puppetmaster.</p>
</li>
<li>
<p class="first">We&#8217;ll now run the <tt class="docutils literal"><span class="pre">puppet</span></tt> client to setup the instance as a puppetmaster:</p>
<blockquote>
<p>sudo puppet /etc/puppet/manifests/puppetmaster.pp</p>
</blockquote>
</li>
</ol>
</div>
<div class="section" id="starting-a-new-instance">
<h2>Starting a new instance</h2>
<p>Now that we have puppetmaster available in our cloud we&#8217;ll have look at how a new instances of the Lucid Beta1 AMI can be started and automatically setup to register with the puppetmaster.</p>
<p>We&#8217;re going to use the <a class="reference external" href="http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/lucid/cloud-init/lucid/annotate/head%3A/doc/examples/cloud-config-puppet.txt">cloud-config puppet syntax</a> to boot an instance and have it configure itself to connect to the puppetmaster using its user data information:</p>
<ol class="arabic">
<li>
<p class="first">On the puppetmaster instance create a <tt class="docutils literal"><span class="pre">user-data.yaml</span></tt> file to include the relevant puppetmaster configuration:</p>
<blockquote>
<p>cp /usr/share/doc/cloud-init/examples/cloud-config-puppet.txt user-data.yaml</p>
</blockquote>
</li>
<li>
<p class="first">Update the <tt class="docutils literal"><span class="pre">server</span></tt> setting to point to the puppetmaster <em>private</em> dns hostname. I also strongly recommend to include the puppmaster ca certificate as the <tt class="docutils literal"><span class="pre">ca_cert</span></tt> setting.</p>
<p>The example <tt class="docutils literal"><span class="pre">certname</span></tt> setting uses a string extrapolation to make each puppet client certificate unique: for now %i is replace by the instance Id while %f is replaced by the FQDN of the instance.</p>
<p>The sample file has extensive comments about the format of the file. One of the key point is that you can set any of the puppet configuration options via the user data passed to the instance.</p>
<p>Note that you can remove all the comments to make the <tt class="docutils literal"><span class="pre">user-data.yaml</span></tt> file easier to copy and paste. However don&#8217;t remove the first line (<tt class="docutils literal"><span class="pre">#cloud-config</span></tt>) as this is used by the instance boot process to start the puppet installation.</p>
</li>
<li>
<p class="first">Launch a new instance using the content of the <tt class="docutils literal"><span class="pre">user-data.yaml</span></tt> file you&#8217;ve just created as the <tt class="docutils literal"><span class="pre">user-data</span></tt> option passed to the new instance.</p>
</li>
<li>
<p class="first">You can watch the puppetmaster log on the puppetmaster instance to see when the new instance will request a new certificate:</p>
<blockquote>
<p>tail -f /var/log/syslog</p>
</blockquote>
</li>
<li>
<p class="first">After some time you should see a request coming in:</p>
<blockquote>
<p>puppetmasterd[2637]: i-fdb31b96.ip-10-195-18-227.ec2.internal has a waiting certificate request</p>
</blockquote>
<p>During the boot process of the new instance the puppet cloud-config plugin used the user-data information to automatically install the puppet package, generate the <tt class="docutils literal"><span class="pre">/etc/puppet/puppet.conf</span></tt> file and start the <tt class="docutils literal"><span class="pre">puppetd</span></tt> daemon.</p>
</li>
<li>
<p class="first">You can then approve the new instance:</p>
<blockquote>
<p>sudo puppetca -s i-fdb31b96.ip-10-195-18-227.ec2.internal</p>
</blockquote>
</li>
<li>
<p class="first">Watching the puppetmaster log you&#8217;ll see that after some time the new instance will connect and get its new manifest compiled and sent:</p>
<blockquote>
<p>puppetmasterd[2637]: Compiled catalog for i-fdb31b96.ip-10-195-18-227.ec2.internal in 0.03 seconds</p>
</blockquote>
</li>
</ol>
<p>In conclusion we now have an instance acting as a puppetmaster and have a single user-data configuration for the whole puppet infrastructure. That user data can be passed to new instances which will automatically register with our puppetmaster.</p>
<p>Even though we&#8217;re able to make all our instances automatically register with our puppetmaster we still need to manually sign each request as outlined in step 6 above. We&#8217;ll have a look at automating this step in the <a href="http://ubuntumathiaz.wordpress.com/2010/03/25/using-puppet-in-uecec2-automating-the-signing-process/">next article</a>.</p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ubuntumathiaz.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ubuntumathiaz.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ubuntumathiaz.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ubuntumathiaz.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ubuntumathiaz.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ubuntumathiaz.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ubuntumathiaz.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ubuntumathiaz.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ubuntumathiaz.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ubuntumathiaz.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ubuntumathiaz.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ubuntumathiaz.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ubuntumathiaz.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ubuntumathiaz.wordpress.com/142/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ubuntumathiaz.wordpress.com&#038;blog=4897956&#038;post=142&#038;subd=ubuntumathiaz&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ubuntumathiaz.wordpress.com/2010/03/24/using-puppet-in-uecec2-puppet-support-in-ubuntu-images/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">mathiaz</media:title>
		</media:content>
	</item>
	</channel>
</rss>
