<?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>Vladimir Vuksan&#039;s blog &#187; mcollective</title>
	<atom:link href="http://blog.vuksan.com/tag/mcollective/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.vuksan.com</link>
	<description>Documenting the systems and network infrastructure madness</description>
	<lastBuildDate>Tue, 03 Jan 2012 03:50:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Bootstraping your cloud environment with puppet and mcollective</title>
		<link>http://blog.vuksan.com/2010/07/28/bootstraping-your-cloud-environment-with-puppet-and-mcollective/</link>
		<comments>http://blog.vuksan.com/2010/07/28/bootstraping-your-cloud-environment-with-puppet-and-mcollective/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 01:31:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Cloud provisioning]]></category>
		<category><![CDATA[Disaster Recovery]]></category>
		<category><![CDATA[mcollective]]></category>

		<guid isPermaLink="false">http://blog.vuksan.com/?p=298</guid>
		<description><![CDATA[This is a "recipe" on how to bootstrap your whole environment in case of a disaster ie. your data center goes dark or if you are migrating from one environment to another. This guide differs from others in that it uses mcollective and DNS to provide you with greater flexibility in deploying and bootstraping environments. [...]]]></description>
			<content:encoded><![CDATA[<p>This is a "recipe" on how to bootstrap your whole environment in case of a disaster ie. your data center goes dark or if you are migrating from one environment to another. This guide differs from others in that it uses mcollective and DNS to provide you with greater flexibility in deploying and bootstraping environments. Some of the alternate ways are <a href="http://github.com/ripienaar/ec2-boot-init#readme">ec2-boot-init by R.I. Pienaar</a> or Grig Gheorghiu's <a href="http://agiletesting.blogspot.com/2009/09/bootstrapping-ec2-images-as-puppet.html">Bootstrapping EC2 images as Puppet clients</a>.</p>
<h2>Intro</h2>
<p>You will need two disk images, your code repository and your DB backup and you can rebuild your whole environment from scratch in a relatively short period of time. This could be adapted to generic cloud provisioning however use case I'm trying to address is disaster recovery. We are using DNS so that we can keep hostnames consistent between environments ie. mail01 will be a mail server in all environments instead of domU-1-2-3-4 in one, rack-2345 in other etc.</p>
<h2>Set up a master node image</h2>
<p>Master node is the node that controls all the other nodes. Most importantly it contains all your configuration management data. You will need to install following</p>
<ul>
<li>mcollective with ActiveMQ</li>
<li>DnsMasq</li>
<li>Puppet from <a href="http://www.puppetlabs.com/">Puppet Labs</a></li>
</ul>
<p>1.  You will need to get a DNS name from a dynamic DNS provider such as DynDNS. Once you have that you will need to write a shell script that runs at boot and sets your EC2 private IP to that DNS name. Let's say we want our controller station to be known as controller.ec2.domain.com we can do something like this</p>
<pre>IP=`facter ipaddress`
change_my_dns_ip controller.ec2.domain.com
# Delete any entries from hosts
sed -i "/controller.ec2.domain.com/d" /etc/hosts
echo "${IP}     controller.ec2.domain.com" &gt;&gt; /etc/hosts</pre>
<p>2. Set up ActiveMQ to be used with mcollective <a href="http://code.google.com/p/mcollective/wiki/GettingStarted">http://code.google.com/p/mcollective/wiki/GettingStarted</a><br />
3. Set up mcollective</p>
<p>Configure controller.ec2.domain.com as the stomp host in your mcollective configuration for both client and server configuration.</p>
<p>4.Install dnsmasq. You don't need to configure anything since by default dnsmasq will read /etc/hosts and serve those names over DNS</p>
<p>5. Install puppetmaster, configure it anyway you want</p>
<p>6. Image it</p>
<h2>Set up a generic/worker node image</h2>
<p>You will need to Install following</p>
<ul>
<li>Mcollective</li>
<li>puppet agent</li>
</ul>
<p>1. On the worker node you need to configure the server piece of mcollective and make sure the stomp.host is pointed to the master ie.  controller.ec2.domain.com.</p>
<p>2. Create a reboot agent (we'll discuss later how to use it). Please visit <a href="http://code.google.com/p/mcollective/wiki/SimpleRPCIntroduction">http://code.google.com/p/mcollective/wiki/SimpleRPCIntroduction</a> for an example. Create a new file ie. reboot.rb. Paste this code in it</p>
<pre>module MCollective
 module Agent
  class Reboot&lt;RPC::Agent
    def reboot_action
     `/sbin/shutdown -r now`
    end
  end
 end
end</pre>
<p>Copy the resulting file to the mcollective agents directory</p>
<p>3. Add following script to the bootup</p>
<pre>MASTER=`host controller.ec2.domain.com | grep address | cut -f4 -d" "`
IS_ALREADY_SET=`grep -c ec2.domain.com /etc/resolv.conf`
if [ $IS_ALREADY_SET -lt 1 ]; then   
sed -i "s/^search .*/search ec2.domain.com/g" /etc/resolv.conf
sed -i "s/^nameserver/nameserver ${MASTER}\nnameserver/g" /etc/resolv.conf
fi
# Set Hostname
IP=`facter ipaddress`
MY_HOST=`/bin/ipcalc --silent --hostname ${IP} | cut -f2 -d=`
hostname ${MY_HOST}</pre>
<p>What that does is point tells your worker nodes to use controller DNS for resolving names as well as setting your hostname.</p>
<p>4. Get the mcollective puppet plugin from <a href="http://github.com/ripienaar/mcollective-plugins/tree/master/agent/puppetd/">github</a></p>
<p>5. Image it</p>
<h2>Bringing up the environment</h2>
<p>You will need to start the master instance first since that's the instance that everyone will be talking to. As soon as it's up you can start up as many instances as you'd like.</p>
<p>While you wait rsync your puppet manifests and configurations to the master node</p>
<p>To find out what nodes are up and available issue mc-ping from the master and you should get a response similar to this</p>
<pre># mc-ping
controller.ec2.domain.com               time=77.21 ms
domu-12-31-55-11-22-18.compute-1.internal time=188.76 ms</pre>
<p>Trouble is that hostnames on the worker nodes are set to Amazon names. We want to make them recognizable e.g. mail01.</p>
<p>To do so simply add the IP of the worker instance and it's name into /etc/hosts on the master e.g.</p>
<pre>echo "10.1.2.3      mail01.ec2.domain.com" &gt;&gt; /etc/hosts</pre>
<p>Reload dnsmasq configuration ie.</p>
<pre>/etc/init.d/dnsmasq reload</pre>
<p>What this has bought you is reverse DNS resolution of the node.  To take effect you will need to reboot the worker node. We already have the reboot agent on the worker nodes so all we have to do is run following command on the master node</p>
<pre>./mc-rpc -F hostname=domu-12-31-55-11-22-18 reboot reboot</pre>
<p>This will seek out the domU-1-2-3-4 host and reboot it (--arg is irrelevant so put anything). Once the machine is up it will advertise it's new name <img src='http://blog.vuksan.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ie. running mc-ping will show you this</p>
<pre># mc-ping
controller.ec2.domain.com           time=47.59 ms
mail01.ec2.domain.com               time=80.71 ms</pre>
<p>Now let's activate puppet. From master node run</p>
<pre># mc-puppetd -F hostname=mail01 runonce

 * [ ============================================================&gt; ] 1 / 1

Finished processing 1 / 1 hosts in 1051.23 ms</pre>
<p>Once that is done puppetca should give you this</p>
<pre>
<pre># puppetca --list
mail01.ec2.domain.com</pre>
</pre>
<p>Sign it</p>
<pre># puppetca –sign mail01.ec2.domain.com</pre>
<p>Now you can simply run</p>
<pre># mc-puppetd -F hostname=mail01 enable</pre>
<p>and off you go. Now lather, rinse, repeat to get the rest of the instances going. You would certainly want to automate this further but I leave that exercise to you <img src='http://blog.vuksan.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p>If you are looking for an easy cross-cloud API check out my "<a href="http://blog.vuksan.com/2010/07/20/provision-to-cloud-in-5-minutes-using-fog/">Provision to cloud in 5 minutes using fog</a>".</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vuksan.com/2010/07/28/bootstraping-your-cloud-environment-with-puppet-and-mcollective/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

