<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Infrastructure Automation with Chef</title>
	<atom:link href="http://techwhizbang.com/2010/04/cooking-with-chef/feed/" rel="self" type="application/rss+xml" />
	<link>http://techwhizbang.com/2010/04/cooking-with-chef/</link>
	<description>my work, life, and ideas</description>
	<lastBuildDate>Thu, 03 Nov 2011 10:04:26 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: techwhizbang</title>
		<link>http://techwhizbang.com/2010/04/cooking-with-chef/comment-page-1/#comment-238</link>
		<dc:creator>techwhizbang</dc:creator>
		<pubDate>Mon, 05 Sep 2011 19:56:51 +0000</pubDate>
		<guid isPermaLink="false">http://techwhizbang.com/?p=193#comment-238</guid>
		<description>If you don&#039;t want to mess with the Chef server to update all the nodes with chef-client? Use chef-solo. 

If don&#039;t want to worry about editing JSON files and uploading those JSON files for chef-solo to use? I would consider exporting temporary environment variables during the execution of a remote SSH command and then referencing those in your deploy recipes. Anything you can do with Ruby you can do with Chef. So something like:

&lt;pre lang=&quot;ruby&quot;&gt;

deploy &quot;/my/deploy/dir&quot; do
  repo &quot;git@github.com/whoami/project&quot;
  revision &quot;#{ENV[&#039;APP_REVISION&#039;]}&quot; # Use the temp environment vars..
  user &quot;deploy_ninja&quot;
  enable_submodules true
  migrate true
  migration_command &quot;rake db:migrate&quot;
  environment &quot;RAILS_ENV&quot; =&gt; &quot;production&quot;
  shallow_clone true
  action &quot;#{ENV[&#039;DEPLOY_OR_ROLLBACK&#039;]}&quot;
  restart_command &quot;touch tmp/restart.txt&quot;
  scm_provider Chef::Provider::Git
end

&lt;/pre&gt;

If you desire to make it look and feel exactly like Capistrano then write a shell script or a Ruby script that takes the same &quot;signature&quot; and then pass those arguments along accordingly. 

A few parting thoughts. Chef isn&#039;t for everyone, in fact, some might argue that automating your infrastructure is a separate concern from deployment. Deviating too far outside the pragmatic uses of Chef could just mean that it is not a good fit for your team. Don&#039;t try to shoehorn something in because it is trendy or seemingly cool. Maybe Capistrano is exactly what you need...</description>
		<content:encoded><![CDATA[<p>If you don&#8217;t want to mess with the Chef server to update all the nodes with chef-client? Use chef-solo. </p>
<p>If don&#8217;t want to worry about editing JSON files and uploading those JSON files for chef-solo to use? I would consider exporting temporary environment variables during the execution of a remote SSH command and then referencing those in your deploy recipes. Anything you can do with Ruby you can do with Chef. So something like:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">&nbsp;
deploy <span style="color:#996600;">&quot;/my/deploy/dir&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  repo <span style="color:#996600;">&quot;git@github.com/whoami/project&quot;</span>
  revision <span style="color:#996600;">&quot;#{ENV['APP_REVISION']}&quot;</span> <span style="color:#008000; font-style:italic;"># Use the temp environment vars..</span>
  user <span style="color:#996600;">&quot;deploy_ninja&quot;</span>
  enable_submodules <span style="color:#0000FF; font-weight:bold;">true</span>
  migrate <span style="color:#0000FF; font-weight:bold;">true</span>
  migration_command <span style="color:#996600;">&quot;rake db:migrate&quot;</span>
  environment <span style="color:#996600;">&quot;RAILS_ENV&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;production&quot;</span>
  shallow_clone <span style="color:#0000FF; font-weight:bold;">true</span>
  action <span style="color:#996600;">&quot;#{ENV['DEPLOY_OR_ROLLBACK']}&quot;</span>
  restart_command <span style="color:#996600;">&quot;touch tmp/restart.txt&quot;</span>
  scm_provider <span style="color:#6666ff; font-weight:bold;">Chef::Provider::Git</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>If you desire to make it look and feel exactly like Capistrano then write a shell script or a Ruby script that takes the same &#8220;signature&#8221; and then pass those arguments along accordingly. </p>
<p>A few parting thoughts. Chef isn&#8217;t for everyone, in fact, some might argue that automating your infrastructure is a separate concern from deployment. Deviating too far outside the pragmatic uses of Chef could just mean that it is not a good fit for your team. Don&#8217;t try to shoehorn something in because it is trendy or seemingly cool. Maybe Capistrano is exactly what you need&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nathan L Smith</title>
		<link>http://techwhizbang.com/2010/04/cooking-with-chef/comment-page-1/#comment-237</link>
		<dc:creator>Nathan L Smith</dc:creator>
		<pubDate>Mon, 05 Sep 2011 19:02:59 +0000</pubDate>
		<guid isPermaLink="false">http://techwhizbang.com/?p=193#comment-237</guid>
		<description>I guess the thing I&#039;m missing from Chef right now is I guess what I would call &quot;on-demand&quot; execution.

With Capistrano I do &quot;cap production deploy BRANCH=v20110903&quot; or whatever and that branch is deployed. With chef I have to set an attribute on a node or edit then upload a data bag, then run the chef-client.

This is even more important for rolling back, since that&#039;s usually a high-pressure situation, where &quot;cap production deploy:rollback&quot; instantly fixes it. I don&#039;t want to be dicking around with JSON and having to upload stuff while my server is on fire.

I guess it would be nice to be able to type a command like &quot;knife deploy omfg its on fire roll back roll back!&quot; 

I&#039;m not trying to diss chef here, I use it a lot and I&#039;m going to ditch cap for chef for deployments, but I need to come up with a solution for this (common?) use-case.</description>
		<content:encoded><![CDATA[<p>I guess the thing I&#8217;m missing from Chef right now is I guess what I would call &#8220;on-demand&#8221; execution.</p>
<p>With Capistrano I do &#8220;cap production deploy BRANCH=v20110903&#8243; or whatever and that branch is deployed. With chef I have to set an attribute on a node or edit then upload a data bag, then run the chef-client.</p>
<p>This is even more important for rolling back, since that&#8217;s usually a high-pressure situation, where &#8220;cap production deploy:rollback&#8221; instantly fixes it. I don&#8217;t want to be dicking around with JSON and having to upload stuff while my server is on fire.</p>
<p>I guess it would be nice to be able to type a command like &#8220;knife deploy omfg its on fire roll back roll back!&#8221; </p>
<p>I&#8217;m not trying to diss chef here, I use it a lot and I&#8217;m going to ditch cap for chef for deployments, but I need to come up with a solution for this (common?) use-case.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nathan L Smith</title>
		<link>http://techwhizbang.com/2010/04/cooking-with-chef/comment-page-1/#comment-236</link>
		<dc:creator>Nathan L Smith</dc:creator>
		<pubDate>Mon, 05 Sep 2011 18:53:44 +0000</pubDate>
		<guid isPermaLink="false">http://techwhizbang.com/?p=193#comment-236</guid>
		<description>* I emailed Nick to ask some questions about this article and he asked me to post it here *


Hi,

I just read your article
http://techwhizbang.com/2010/04/cooking-with-chef/ , which was good,
but I had a question and I thought you might be able to answer.

In the article you&#039;re talking about how easy it is to deploy with
Chef. I&#039;ve found this to be somewhat true, but the default deploy
resource basically makes is so your &quot;master&quot; or whatever is deployed
to the system whenever you run chef-client. So, if I&#039;m running
chef-client as a daemon and doing continuous deployment that&#039;s cool,
but I&#039;m still not getting it for periodic deploys of a certain branch
or for rolling back.

I mean, a collegue asked me, &quot;how do I deploy the app&quot;, and I told
him, &quot;well, you don&#039;t really deploy the app, you bring the node into a
state of convergence.&quot;, then he said, &quot;What?&quot;

I&#039;m deploying with the deploy resource and apps data bag, and I&#039;m
thinking of making a knife plugin where I can do `knife deploy
production myapp` that sets an attribute for the action of the deploy
resource or something, so I was wondering how you handle rolling back
(as I understand it, the way the defaults work I have to edit a
cookbook if I want to roll back, which is not cool.)

Also, you said, &quot;Take deployment and rollback even a step further with
a tool like Hudson or TeamCity. Configure a job for them to run and
wire up the Chef deployment script. The “easy button” deployment and
rollback.&quot; Could you explain how you do this?

* He replied: *

Hi Nathan,

For some reason your name sounds familiar. Thanks for the inquiry and the complement. I think Chef is a good choice for deployment if you are already using it for automating your setups. It is probably way too much trouble in terms of setup and understanding for just the deploy resource. Although you could just use chef-solo to sidestep the complicated steps of maintaining and managing the full Chef server stack. I&#039;m assuming you&#039;re intending on using it to its fullest extent. I&#039;ve used the deploy resource a couple different ways. The first way I used it was to create a recipe that does deploying/rollbacks for each target environment. Imagine a cookbook with the following recipes:

--- deploy_some_app_cookbook
  - development.rb
  - qa.rb
  - staging.rb
  - production.rb

All of these recipes share the same code except for a couple things captured in attributes. The recipes have attributes for the target tag or branch and potentially if you&#039;e deploying or rolling back:
default[:deploy_apps][:vcs_branch_or_tag] = &quot;Tag v0.0.1&quot;
default[:deploy_apps][:rollback] = false

So when you use these recipes you can reference the attributes in the deploy resource. This way you aren&#039;t always deploying master or trunk. Update the recipes and attributes across Chef accordingly as things for your project(s) change.

Another approach is to use data bags. You can access data bags similarly in your recipes. By the way, the deploy resource is extensible to just about any application, not just Rails apps. I&#039;ve molded it to deploy WAR files, background applications, and all types of services. 

You were concerned about rollback, but Chef does 2 types of deployments - timestamped or commit revisions. When you execute a rollback, Chef places a file on your server that keeps track of the last 10 or so deploys in the exact order they were performed along with all of the artifacts necessary to perform the rollback. So when you do a rollback you don&#039;t have to worry about specifying a revision number, tag, or anything of that sort. Just &quot;rollback&quot; and Chef will automatically change the symlink it uses to point to the previous deploy. 

In terms of using Team City or Jenkins as an &quot;easy button&quot;. Both of the CI servers will take an arbitrary shell script, executable, rake task, maven task, ant task, or whatever else you can dream up. You would normally use the command line to do a deploy with Chef, so my suggestion was to make it one step easier. Create a job that will execute a shell script that wraps the Chef commands used for deployment and rollback.

I think once you get Chef fully up and running and begin using it this will be easier and also become very clear. Hope this helps.</description>
		<content:encoded><![CDATA[<p>* I emailed Nick to ask some questions about this article and he asked me to post it here *</p>
<p>Hi,</p>
<p>I just read your article<br />
<a href="http://techwhizbang.com/2010/04/cooking-with-chef/" rel="nofollow">http://techwhizbang.com/2010/04/cooking-with-chef/</a> , which was good,<br />
but I had a question and I thought you might be able to answer.</p>
<p>In the article you&#8217;re talking about how easy it is to deploy with<br />
Chef. I&#8217;ve found this to be somewhat true, but the default deploy<br />
resource basically makes is so your &#8220;master&#8221; or whatever is deployed<br />
to the system whenever you run chef-client. So, if I&#8217;m running<br />
chef-client as a daemon and doing continuous deployment that&#8217;s cool,<br />
but I&#8217;m still not getting it for periodic deploys of a certain branch<br />
or for rolling back.</p>
<p>I mean, a collegue asked me, &#8220;how do I deploy the app&#8221;, and I told<br />
him, &#8220;well, you don&#8217;t really deploy the app, you bring the node into a<br />
state of convergence.&#8221;, then he said, &#8220;What?&#8221;</p>
<p>I&#8217;m deploying with the deploy resource and apps data bag, and I&#8217;m<br />
thinking of making a knife plugin where I can do `knife deploy<br />
production myapp` that sets an attribute for the action of the deploy<br />
resource or something, so I was wondering how you handle rolling back<br />
(as I understand it, the way the defaults work I have to edit a<br />
cookbook if I want to roll back, which is not cool.)</p>
<p>Also, you said, &#8220;Take deployment and rollback even a step further with<br />
a tool like Hudson or TeamCity. Configure a job for them to run and<br />
wire up the Chef deployment script. The “easy button” deployment and<br />
rollback.&#8221; Could you explain how you do this?</p>
<p>* He replied: *</p>
<p>Hi Nathan,</p>
<p>For some reason your name sounds familiar. Thanks for the inquiry and the complement. I think Chef is a good choice for deployment if you are already using it for automating your setups. It is probably way too much trouble in terms of setup and understanding for just the deploy resource. Although you could just use chef-solo to sidestep the complicated steps of maintaining and managing the full Chef server stack. I&#8217;m assuming you&#8217;re intending on using it to its fullest extent. I&#8217;ve used the deploy resource a couple different ways. The first way I used it was to create a recipe that does deploying/rollbacks for each target environment. Imagine a cookbook with the following recipes:</p>
<p>&#8212; deploy_some_app_cookbook<br />
  &#8211; development.rb<br />
  &#8211; qa.rb<br />
  &#8211; staging.rb<br />
  &#8211; production.rb</p>
<p>All of these recipes share the same code except for a couple things captured in attributes. The recipes have attributes for the target tag or branch and potentially if you&#8217;e deploying or rolling back:<br />
default[:deploy_apps][:vcs_branch_or_tag] = &#8220;Tag v0.0.1&#8243;<br />
default[:deploy_apps][:rollback] = false</p>
<p>So when you use these recipes you can reference the attributes in the deploy resource. This way you aren&#8217;t always deploying master or trunk. Update the recipes and attributes across Chef accordingly as things for your project(s) change.</p>
<p>Another approach is to use data bags. You can access data bags similarly in your recipes. By the way, the deploy resource is extensible to just about any application, not just Rails apps. I&#8217;ve molded it to deploy WAR files, background applications, and all types of services. </p>
<p>You were concerned about rollback, but Chef does 2 types of deployments &#8211; timestamped or commit revisions. When you execute a rollback, Chef places a file on your server that keeps track of the last 10 or so deploys in the exact order they were performed along with all of the artifacts necessary to perform the rollback. So when you do a rollback you don&#8217;t have to worry about specifying a revision number, tag, or anything of that sort. Just &#8220;rollback&#8221; and Chef will automatically change the symlink it uses to point to the previous deploy. </p>
<p>In terms of using Team City or Jenkins as an &#8220;easy button&#8221;. Both of the CI servers will take an arbitrary shell script, executable, rake task, maven task, ant task, or whatever else you can dream up. You would normally use the command line to do a deploy with Chef, so my suggestion was to make it one step easier. Create a job that will execute a shell script that wraps the Chef commands used for deployment and rollback.</p>
<p>I think once you get Chef fully up and running and begin using it this will be easier and also become very clear. Hope this helps.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic page generated in 0.852 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-20 09:41:32 -->

