<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>DevOpsCasts</title>
  <id>http://devops.mashion.net</id>
  <updated>2011-08-04</updated>
  <author>
    <name>Mat Schaffer</name>
  </author>
  <entry>
    <title>2012 Hiatus</title>
    <link rel="alternate" href="http://devops.mashion.net/2012/01/09/2012-hiatus/"/>
    <id>http://devops.mashion.net/2012/01/09/2012-hiatus/</id>
    <published>2012-01-09</published>
    <updated>2012-01-09</updated>
    <author>
      <name>Mat Schaffer</name>
    </author>
    <summary type="html">&lt;p&gt;Hello again, everyone. As you may have noticed it&amp;rsquo;s been awhile since I&amp;rsquo;ve done any videos. I have a number of big events going on this year, including having a new son that will be taking up my time for awhile. As such I&amp;rsquo;m hanging my microphone up until sometime around fall 2012&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Hello again, everyone. As you may have noticed it&amp;rsquo;s been awhile since I&amp;rsquo;ve done any videos. I have a number of big events going on this year, including having a new son that will be taking up my time for awhile. As such I&amp;rsquo;m hanging my microphone up until sometime around fall 2012.&lt;/p&gt;

&lt;p&gt;In the mean time if you or anyone you know is interested in screencasting devops topics, I&amp;rsquo;d be happy to help out with production and post them here. Feel free to email me at &lt;a href="mailto:mat@mashion.net"&gt;mat@mashion.net&lt;/a&gt; if you&amp;rsquo;re interested.&lt;/p&gt;

&lt;p&gt;Thanks for watching and see you later this year!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Chef Server Usage</title>
    <link rel="alternate" href="http://devops.mashion.net/2011/09/21/chef-server-usage/"/>
    <id>http://devops.mashion.net/2011/09/21/chef-server-usage/</id>
    <published>2011-09-21</published>
    <updated>2011-09-21</updated>
    <author>
      <name>Mat Schaffer</name>
    </author>
    <summary type="html">&lt;p&gt;Welcome back! Sorry for delay in getting this episode out. I&amp;rsquo;m currently on vacation overseas so it&amp;rsquo;s taken a bit more time to prepare everything.&lt;/p&gt;

&lt;p&gt;In todays episode we&amp;rsquo;ll go over how to upload cookbooks to your Chef Server as well as connect and provision a node. This episode is a continuation of our &lt;a href="/2011/08/19/chef-server-installation"&gt;last episode&lt;/a&gt; so you&amp;rsquo;ll want to follow along with that before trying out this one.&lt;/p&gt;

&lt;iframe width="425" height="349" src="http://www.youtube.com/embed/gcapNn45dU8" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;

</summary>
    <content type="html">&lt;p&gt;Welcome back! Sorry for delay in getting this episode out. I&amp;rsquo;m currently on vacation overseas so it&amp;rsquo;s taken a bit more time to prepare everything.&lt;/p&gt;

&lt;p&gt;In todays episode we&amp;rsquo;ll go over how to upload cookbooks to your Chef Server as well as connect and provision a node. This episode is a continuation of our &lt;a href="/2011/08/19/chef-server-installation"&gt;last episode&lt;/a&gt; so you&amp;rsquo;ll want to follow along with that before trying out this one.&lt;/p&gt;

&lt;iframe width="425" height="349" src="http://www.youtube.com/embed/gcapNn45dU8" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;


&lt;h1&gt;Prep&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Chef server VM at &amp;ldquo;Pre Part 2&amp;rdquo; snapshot&lt;/li&gt;
&lt;li&gt;Move ~/.chef to ~/.chef.orig&lt;/li&gt;
&lt;li&gt;Copy ~/.chef.part1 to ~/.chef&lt;/li&gt;
&lt;li&gt;open slides&lt;/li&gt;
&lt;/ol&gt;


&lt;h1&gt;Script&lt;/h1&gt;

&lt;p&gt;(slide start)&lt;/p&gt;

&lt;p&gt;Hi, I&amp;rsquo;m Mat Schaffer and welcome to DevOpsCasts where we go over topics that help tear down the wall between development and operations.&lt;/p&gt;

&lt;p&gt;(change)&lt;/p&gt;

&lt;p&gt;Previously on DevOpsCasts we talked about Chef Server. If you followed along you should now have a functioning Chef Server that we&amp;rsquo;ll build on in this episode.&lt;/p&gt;

&lt;p&gt;(change)&lt;/p&gt;

&lt;p&gt;Now we&amp;rsquo;re in Part 2 where we&amp;rsquo;ll talk about how to upload cookbooks to your Chef Server and attach application nodes so that they can run your cookbooks and provision themselves on demand. So let&amp;rsquo;s get to it.&lt;/p&gt;

&lt;p&gt;(terminal)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife client list
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;First, run a quick knife client list to make sure you can talk to your chef server. If you have any trouble getting a list back, you may need to debug a bit. One common problem that we saw last time was clock skew, so make sure your laptop and server are in sync with a time server.&lt;/p&gt;

&lt;p&gt;(overlap: sudo ntpdate pool.ntp.org)&lt;/p&gt;

&lt;p&gt;Remember we used the ntpdate command to fix the the clock.&lt;/p&gt;

&lt;p&gt;(terminal)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ vi ~/.chef/knife.rb
# show chef server URL
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you still can&amp;rsquo;t get a list, check your knife.rb. If you&amp;rsquo;re running Chef on a VM, double check that the server URL is correct. Some VMs will rotate IP addresses between boots.&lt;/p&gt;

&lt;p&gt;(overlay: mat@mashion.net)&lt;/p&gt;

&lt;p&gt;If you&amp;rsquo;re still having trouble, feel free to email me or comment on the show notes.&lt;/p&gt;

&lt;p&gt;(browser: https://github.com/opscode/chef-repo)&lt;/p&gt;

&lt;p&gt;(terminal)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ git clone https://github.com/opscode/chef-repo.git devopscasts
$ cd devopscasts
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;First we&amp;rsquo;ll need space to keep our cookbooks. When using chef server we&amp;rsquo;ll use the Opscode chef-repo as a base. This allows us to use some built-in knife commands to manage our cookbooks and their dependencies.&lt;/p&gt;

&lt;p&gt;(browser: opscode mysql cookbook page)&lt;/p&gt;

&lt;p&gt;In this episode we&amp;rsquo;ll be installing a mysql server. We&amp;rsquo;ll use the off-the-shelf mysql cookbook this time instead of writing our own. This is a much more complex cookbook than the nginx cookbook we wrote in episode 1 so it&amp;rsquo;ll serve as a good base for upcoming screencasts on the more advanced features of chef.&lt;/p&gt;

&lt;p&gt;(terminal)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife cookbook site install mysql -o `pwd`/cookbooks
$ ls cookbooks
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Knife comes with a built in tool for downloading these cookbooks. The command to run here is knife cookbook site install mysql and we specify the dash-O option with the full path to the cookbooks folder. This will download the mysql cookbook from opscode as well as the cookbooks it depends on. In this case there&amp;rsquo;s only one cookbook dependency, openssl. The mysql cookbook uses the openssl cookbook to generate random secure passwords for the mysql server.&lt;/p&gt;

&lt;p&gt;(terminal)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ vi ~/.chef/knife.rb
  cookbook_path [ '/Users/mat/devopscasts/cookbooks' ]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To avoid setting the cookbook path every time we run a command, we can change the cookbook path listed in knife.rb.&lt;/p&gt;

&lt;p&gt;We can use these cookbooks as-is, so next we&amp;rsquo;ll upload them to the chef server using the knife cookbook upload command.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife cookbook upload mysql -d
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here we specify the dash-D option so that the openssl dependency will also be uploaded.&lt;/p&gt;

&lt;p&gt;Now that we&amp;rsquo;ve uploaded the cookbooks we&amp;rsquo;ll attach a node to this chef server that we can run them on. I have another VM ready here but it hasn&amp;rsquo;t been prepared yet.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ssh ubuntu@192.168.139.132
$ sudo hostname mysql
$ sudo vi /etc/hosts
    192.168.139.132 mysql mysql.devops.mashion.net
$ hostname -f
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Like we did with our Chef server, we&amp;rsquo;ll set the hostname first. Chef uses host names as the unique identifier for each node so it&amp;rsquo;s important to set this early on. While you can change the host name later it&amp;rsquo;s somewhat involed, so better to have it set right from the beginning.&lt;/p&gt;

&lt;p&gt;The last gotcha before we bootstrap our host is that we&amp;rsquo;ll also need the validation key from our chef server so we can upload it to our new node. This key is used by the node to ensure it&amp;rsquo;s talking to the expected chef server.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ^D
$ ssh ubuntu@192.168.139.130
$ sudo cat /etc/chef/validation.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We&amp;rsquo;ll do this simply by copying the text and pasting it into a file in our local chef directory.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ^D
$ vi ~/.chef/validation.pem
$ vi ~/.chef/knife.rb
  validation_key '/Users/mat/.chef/validation.pem'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then we fix our knife.rb to reference the file we&amp;rsquo;ve just created&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife bootstrap -x ubuntu -P ubuntu -d ubuntu10.04-gems --sudo -r 'recipe[mysql::server]' 192.168.139.132
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now to prepare the node for running Chef server recipes we&amp;rsquo;ll use the knife bootstrap command. This command is provided with Chef. It&amp;rsquo;s a little less automatic than the knife prepare command that comes with the knife solo gem, but it works in a way that fits a bit more closely with Chef Server.&lt;/p&gt;

&lt;p&gt;The first arguments are my username and password followed by the dash-D option which tells the bootstrap command what distro I&amp;rsquo;m using and how I&amp;rsquo;d like to install chef. In this case it&amp;rsquo;s ubuntu using rubygems to install chef. The sudo argument tells knife to preface any commands with sudo since the ubuntu user doesn&amp;rsquo;t have root privileges.&lt;/p&gt;

&lt;p&gt;The bootstrap command will install the components necessary to run Chef, configure the node to talk to the same server in our local knife config and set up a node configuration that includes the mysql server recipe.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife node list
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Once this is done we can run knife node list and see the node we just set up in the list.&lt;/p&gt;

&lt;p&gt;Now let&amp;rsquo;s try connecting to our new mysql server.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ssh ubuntu@192.168.139.132
$ mysql -u root
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As you can see, we need a password to connect. That password was generated randomly and stored safely in Chef&amp;rsquo;s node database.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ^D
$ knife node show mysql -m
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To access it we use the knife node command with the dash-M option to show normal attribute data. This will show us the node data that was created during a recipe run but skip all the system information that was discovered by ohai.&lt;/p&gt;

&lt;p&gt;So here&amp;rsquo;s our password which I&amp;rsquo;ll copy so we can connected to our server.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ssh ubuntu@192.168.139.132
$ mysql -u root -p
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And now we&amp;rsquo;re in. Normally you won&amp;rsquo;t need to copy and paste this around since you can access that data from inside the chef recipes. We&amp;rsquo;ll talk more about how to do that in later episodes.&lt;/p&gt;

&lt;p&gt;Let&amp;rsquo;s say we want to make a change a configuration setting on mysql, for example the max allowed packet size. Since our configuration is controlled by chef now, we&amp;rsquo;ll look in our mysql cookbook to see how it&amp;rsquo;s getting set up.&lt;/p&gt;

&lt;p&gt;(redcar, cookbooks/mysql)&lt;/p&gt;

&lt;p&gt;In the mysql cookbook directory there&amp;rsquo;s a templates/default folder that contains the my.cnf.erb that gets used to generate the mysql configuration on the server.&lt;/p&gt;

&lt;p&gt;(redcar, cookbooks/mysql/templates/default/my.cnf.erb)
Show line 141&lt;/p&gt;

&lt;p&gt;We can see here that the max allowed packet size gets set from the mysql tunable max allowed packet node attribute.&lt;/p&gt;

&lt;p&gt;(redcar, cookbooks/mysql/attributes)&lt;/p&gt;

&lt;p&gt;The default values for node attributes are read from the attributes file that matches the recipe we ran on this node. In this case server.rb.&lt;/p&gt;

&lt;p&gt;(redcar, cookbooks/mysql/attributes/server.rb)
Show line 45&lt;/p&gt;

&lt;p&gt;If we scroll down to find the max packet size, we can see the default here is 16MB. Now we could change it here, but that would increase the size for any node we used this cookbook on. I&amp;rsquo;d rather have this parameter default to 16MB but be 32MB on our new mysql node.&lt;/p&gt;

&lt;p&gt;(terminal)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife node edit mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To do that we can use the knife node edit command. This will open the node configuration file in our preferred editor. For me this is vim.&lt;/p&gt;

&lt;p&gt;(overlay: export EDITOR=vim)&lt;/p&gt;

&lt;p&gt;To set your editor place a line like this in your bashrc or local user profile.&lt;/p&gt;

&lt;p&gt;(vim)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;"tunable": {
  "max_allowed_packet": "32MB"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now in the mysql section, we can add the tunable max allowed packet attribute, save and quit the editor and the node configuration will be fixed the next time chef runs. Now we could use the knife ssh command to explicitly invoke the chef client on our node. But that&amp;rsquo;s not nearly as much fun as having our node continuously update itself.&lt;/p&gt;

&lt;p&gt;To set up our node to continuously update itself we&amp;rsquo;ll need to install the chef client. Of course, there&amp;rsquo;s a cookbook for this.&lt;/p&gt;

&lt;p&gt;(terminal)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife cookbook site install chef-client
$ knife cookbook upload chef-client -d
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We&amp;rsquo;ll use knife again to download it from opscode and upload it to our own chef server.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife node edit mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then we&amp;rsquo;ll use the knife node edit command to add the chef-client recipe to the node&amp;rsquo;s run list.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Add chef-client to run list
# Add attributes
  "chef_client": {
    "interval": "5"
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now by default the chef client checks in once every half hour. For this demo we&amp;rsquo;ll set it to check in every 5 seconds. So we can see the effects of our work more quickly.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife ssh -m 192.168.139.132 -x ubuntu -P ubuntu sudo chef-client
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And finally we&amp;rsquo;ll use the knife ssh command to run the chef-client manually. The knife ssh command can also be used search for nodes and execute commands on all node of a given type, but we&amp;rsquo;d have to take a bit more time to properly set up DNS and SSH to allow for that. So today we&amp;rsquo;ll just specify the host and authentication information manually.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife ssh -m 192.168.139.132 -x ubuntu -P ubuntu cat /etc/mysql/my.cnf | grep max
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We can use knife ssh again to show that our max packet size has indeed been increased to 32MB.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife node edit mysql
$ # Change max to 64MB
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now we can edit the node again and change it to 64 MB. If we wait 5 or so seconds, the chef client will come around again, find the updated configuration and update the max allowed packet size.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife ssh -m 192.168.139.132 -x ubuntu -P ubuntu cat /etc/mysql/my.cnf | grep max
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Of course, this gets even more exciting as you add more nodes to your Chef server. But to really make use of it we&amp;rsquo;ll have to cover a bit about how recipes, roles and attributes work together to coordinate nodes across your environment. So we&amp;rsquo;ll save those topics for next time.&lt;/p&gt;

&lt;p&gt;(keynote)&lt;/p&gt;

&lt;p&gt;For our next episode I&amp;rsquo;m planning to take a break from Chef and talk about some monitoring packages that you can use to help make sure your environment is operating correctly. Of course if you have any feedback, feel free to leave a comment on the show notes.&lt;/p&gt;

&lt;p&gt;Thanks for watching!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Chef Server Installation</title>
    <link rel="alternate" href="http://devops.mashion.net/2011/08/19/chef-server-installation/"/>
    <id>http://devops.mashion.net/2011/08/19/chef-server-installation/</id>
    <published>2011-08-19</published>
    <updated>2011-08-19</updated>
    <author>
      <name>Mat Schaffer</name>
    </author>
    <summary type="html">&lt;p&gt;Welcome back! This time we&amp;rsquo;ll start in on Chef Server. It&amp;rsquo;s a big topic, so we&amp;rsquo;ll do this in two parts, in this first part we&amp;rsquo;ll cover the installation then cover how to use it in the next episode.&lt;/p&gt;

&lt;iframe width="425" height="349" src="http://www.youtube.com/embed/g_s8UFFowXI" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;

</summary>
    <content type="html">&lt;p&gt;Welcome back! This time we&amp;rsquo;ll start in on Chef Server. It&amp;rsquo;s a big topic, so we&amp;rsquo;ll do this in two parts, in this first part we&amp;rsquo;ll cover the installation then cover how to use it in the next episode.&lt;/p&gt;

&lt;iframe width="425" height="349" src="http://www.youtube.com/embed/g_s8UFFowXI" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;


&lt;h1&gt;Prep&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Make serverdemo kitchen&lt;/li&gt;
&lt;li&gt;Prep VMWare VM, &amp;ldquo;Chef Server&amp;rdquo;, upload keys, knife solo prepare&lt;/li&gt;
&lt;li&gt;open slides&lt;/li&gt;
&lt;li&gt;Move ~/.chef to ~/.chef.orig&lt;/li&gt;
&lt;/ol&gt;


&lt;h1&gt;Script&lt;/h1&gt;

&lt;p&gt;(slide start)&lt;/p&gt;

&lt;p&gt;Hi, I&amp;rsquo;m Mat Schaffer and welcome to DevOpsCasts where we go over topics that live in that nebulous space between development and operations.&lt;/p&gt;

&lt;p&gt;(change)&lt;/p&gt;

&lt;p&gt;Today we&amp;rsquo;ll start in on Chef Server. As I mentioned last time, Chef Server is a larger, more scalable approach to using Chef.&lt;/p&gt;

&lt;p&gt;(change)&lt;/p&gt;

&lt;p&gt;Since Chef Server is a somewhat large topic, we&amp;rsquo;ll be covering it in two parts. Today we&amp;rsquo;ll do an overview of Chef Server and I&amp;rsquo;ll show you how to install it.&lt;/p&gt;

&lt;p&gt;(change)&lt;/p&gt;

&lt;p&gt;Chef Server introduces another server to your architecture.&lt;/p&gt;

&lt;p&gt;(change)&lt;/p&gt;

&lt;p&gt;This is your Chef Server. And it serves as a central repository for cookbooks, recipes and other configuration information.&lt;/p&gt;

&lt;p&gt;(change)&lt;/p&gt;

&lt;p&gt;And your application servers will now have the chef-client daemon running on them.&lt;/p&gt;

&lt;p&gt;(change)&lt;/p&gt;

&lt;p&gt;Like last time, you&amp;rsquo;ll develop your cookbooks on your local machine. But when we&amp;rsquo;re finished, we&amp;rsquo;ll use knife to upload them to the Chef server.&lt;/p&gt;

&lt;p&gt;(change)&lt;/p&gt;

&lt;p&gt;Since the chef-server and chef-client processes are in constant contract, the application servers will then pick up on the new cookbook and run through them in the same way we saw with chef solo.&lt;/p&gt;

&lt;p&gt;(change)&lt;/p&gt;

&lt;p&gt;Chef Server is especially useful if you have a large number of servers. With Chef Server you don&amp;rsquo;t have to wait for each machine to run the recipes before moving on to the next one and tranfering cookbooks to the app servers is done for you.&lt;/p&gt;

&lt;p&gt;(change)&lt;/p&gt;

&lt;p&gt;It&amp;rsquo;s also good if you have inter-dependent services. This is because Chef Server stores not only just cookbooks, but also serves as a system of record for configuration information. You can even search your infrastructure for nodes that serve certain roles or configuration. For example, your application recipe could search for any available database node and use that rather than hard-coding the database information in the recipe.&lt;/p&gt;

&lt;p&gt;(change)&lt;/p&gt;

&lt;p&gt;And finally it&amp;rsquo;s useful in situations where you have multiple deployment
engineers. With Chef Solo you have to be careful to coordinate the
provisioning so that two people don&amp;rsquo;t try to run cookbooks at the same
time. Since Chef Server runs cookbooks asynchronously, many people can
upload cookbooks as they work on them and the chef client daemon will
pick them up on the next run.&lt;/p&gt;

&lt;p&gt;(virtualbox: ChefServer)&lt;/p&gt;

&lt;p&gt;We&amp;rsquo;ll be running Chef Server on this VM I have handy. I&amp;rsquo;ve already installed my ssh keys and prepare the box to run chef by using the &amp;ldquo;prepare&amp;rdquo; command from knife solo.&lt;/p&gt;

&lt;p&gt;(overlay: knife prepare ubuntu@192.168.139.130)&lt;/p&gt;

&lt;p&gt;I did this by running &amp;ldquo;knife prepare&amp;rdquo; and passing in the username and host of the VM. One thing to note is that I&amp;rsquo;ve also given this VM a bit more memory. Chef Server can be somewhat memory intensive as your cluster grows so I recommend giving it at least 1 gigabyte of memory for testing and at least 2 for production work.&lt;/p&gt;

&lt;p&gt;There are a number of ways to install Chef Sever including options that use OS-specific packages. Today we&amp;rsquo;ll use the &amp;ldquo;bootstrap&amp;rdquo; method which uses Chef Solo to build the Chef Server.&lt;/p&gt;

&lt;p&gt;(terminal: ssh ubuntu@192.168.139.130)&lt;/p&gt;

&lt;p&gt;The first thing our server will need is a proper host name. To set it on a running system we can use the hostname command and make a matching entry in /etc/hosts. To persist it across reboots on ubuntu we also need to set the hostname in /etc/hostname.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sudo hostname chef.devops.mashion.net
$ sudo vi /etc/hosts
    -127.0.0.1 ubuntu*
    +192.168.139.130 chef.devops.mashion.net chef
$ sudo bash -c 'hostname &amp;gt; /etc/hostname'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you got it set right, you should see the full hostname when you run &lt;code&gt;hostname -f&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ hostname -f
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now since we&amp;rsquo;re using chef solo we&amp;rsquo;ll need a node config&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ vi chef.json
    {
      "run_list": [ "recipe[chef-server::rubygems-install]" ],
      "chef_server": {
        "server_url": "http://localhost:4000",
        "webui_enabled": true
      }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The run list will include the chef-server rubygems-install recipe. And we&amp;rsquo;ll set two attributes that tell chef the expected server url and that we want the chef web UI to be installed and available.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sudo chef-solo -c /etc/chef/solo.rb -j ~/chef.json -r http://s3.amazonaws.com/chef-solo/bootstrap-latest.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And now we&amp;rsquo;ll run chef solo using that config and pulling our cookbooks from the S3. Note that this will take some time since it installs a lot of packages.&lt;/p&gt;

&lt;p&gt;You may have noticed that I&amp;rsquo;m using VMWare Fusion today. The reason for this is that VirtualBox on Mac OS Lion seems to over-consume resources when running large apt-get installations. One way I&amp;rsquo;ve found to work around this is the cputhrottle tool for Mac OS. If you run into similar issues check the show notes for some information.&lt;/p&gt;

&lt;p&gt;(cputhrottle info)&lt;/p&gt;

&lt;p&gt;Download from &lt;a href="http://www.willnolan.com/cputhrottle/cputhrottle.html"&gt;http://www.willnolan.com/cputhrottle/cputhrottle.html&lt;/a&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Grab the PID of the VM called "Chef Server"
$ VMPID=`ps ux | grep '[C]hef Server' | awk '{print $2}'`
# Limit it to 80 percent of total CPU
$ /path/to/cputhrottle $VMPID 80
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(Configuring knife)&lt;/p&gt;

&lt;p&gt;Now that Chef is installed we&amp;rsquo;ll configure the root user&amp;rsquo;s knife utility. We&amp;rsquo;ll use the local knife tool to create certificates that we can use on our own laptop.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sudo su -
$ knife configure -i --defaults -r .
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To verify that it was configured correctly, we&amp;rsquo;ll run knife client list. The &amp;ldquo;ubuntu&amp;rdquo; entry here tells us that it was configured correctly and it can talk to the Chef server:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife client list
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To create a knife client entry for myself I&amp;rsquo;ll use the knife client create
command. The options here tell Chef to create and admin account with default
settings called &amp;lsquo;mat&amp;rsquo;. And to place the private auth certificate into /tmp/mat.pem&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife client create -a -n -f /tmp/mat.pem mat
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(close ssh)&lt;/p&gt;

&lt;p&gt;Now back on my computer I&amp;rsquo;ll scp that key over to my .chef folder and configure my knife client.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mkdir .chef
$ scp ubuntu@192.168.139.130:/tmp/mat.pem .chef/
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To configure our local client we&amp;rsquo;ll use knife configure. The options here specify &amp;lsquo;mat&amp;rsquo; as our chef user name. This matches the client we created back on the server. The path to the certificate we copied over. The URL to the chef server, which defaults to port 4000. And finally defaults for the rest.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife configure -u mat -k .chef/mat.pem -s http://192.168.139.130:4000 --defaults -r .
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To test that we have it configured correctly we run knife client list as we did before.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife client list
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When running Chef Server on VMs it&amp;rsquo;s easy to run into clock synchronization problems. If you encounter an authentication error that mentions synchronizing your clock, go back to the server and run ntpdate to fix it.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ssh ubuntu@192.168.139.130
$ sudo ntpdate pool.ntp.org
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The happens because the authenication mechanism in Chef only allows for 15 minutes of difference between the clocks on the two systems.&lt;/p&gt;

&lt;p&gt;Now that our clocks are in sync we should be able to run knife client list back on our laptop without any problems.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife client list
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(browser)&lt;/p&gt;

&lt;p&gt;One more thing I&amp;rsquo;ll mention before we finish is that we&amp;rsquo;ve also installed the Chef web UI. If we go to our chef server on port 4040, we&amp;rsquo;ll get a nice Web UI for all of the functions we talked about here. The default password is in the sidebar. Just enter it here, give it a new password and you can then browse around your chef configuration this way too.&lt;/p&gt;

&lt;p&gt;(client tab)&lt;/p&gt;

&lt;p&gt;If we look at the Clients tab we can see the &amp;ldquo;mat&amp;rdquo; and &amp;ldquo;ubuntu&amp;rdquo; clients that we&amp;rsquo;ve created.&lt;/p&gt;

&lt;p&gt;(slides)&lt;/p&gt;

&lt;p&gt;And that&amp;rsquo;s it for today. Next episode we&amp;rsquo;ll go over how to hook up the chef-client daemon to this chef server and upload cookbooks so they get run on our app servers. Thanks for watching and see you next time!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Chef Solo Basics</title>
    <link rel="alternate" href="http://devops.mashion.net/2011/08/04/chef-solo-basics/"/>
    <id>http://devops.mashion.net/2011/08/04/chef-solo-basics/</id>
    <published>2011-08-04</published>
    <updated>2011-08-04</updated>
    <author>
      <name>Mat Schaffer</name>
    </author>
    <summary type="html">&lt;p&gt;Welcome to our first episode! In this episode we&amp;rsquo;ll cover the basics you&amp;rsquo;ll need to get started with Chef Solo.&lt;/p&gt;

&lt;iframe width="425" height="349" src="http://www.youtube.com/embed/1G6bd4b91RU" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;


&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; I forgot to add the link overlays so here&amp;rsquo;s my &lt;a href="http://matschaffer.com/2011/06/minimal-ubuntu-virtualbox/"&gt;blog post&lt;/a&gt; on setting up an Ubuntu VM and a &lt;a href="https://s3.amazonaws.com/mashion/Ubuntu64Base.ova"&gt;pre-made image&lt;/a&gt; that should work for testing. The username/password is ubuntu/ubuntu&amp;#x2e;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Welcome to our first episode! In this episode we&amp;rsquo;ll cover the basics you&amp;rsquo;ll need to get started with Chef Solo.&lt;/p&gt;

&lt;iframe width="425" height="349" src="http://www.youtube.com/embed/1G6bd4b91RU" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;


&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; I forgot to add the link overlays so here&amp;rsquo;s my &lt;a href="http://matschaffer.com/2011/06/minimal-ubuntu-virtualbox/"&gt;blog post&lt;/a&gt; on setting up an Ubuntu VM and a &lt;a href="https://s3.amazonaws.com/mashion/Ubuntu64Base.ova"&gt;pre-made image&lt;/a&gt; that should work for testing. The username/password is ubuntu/ubuntu&amp;#x2e;&lt;/p&gt;

&lt;h1&gt;Prep&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Prep virtualbox VM: get IP and upload keys, snapshot, then shutdown&lt;/li&gt;
&lt;li&gt;Remove ~/.chef/knife.rb&lt;/li&gt;
&lt;li&gt;Switch to empty gemset&lt;/li&gt;
&lt;li&gt;start redcar&lt;/li&gt;
&lt;li&gt;open chrome to github.com/opscode/cookbooks&lt;/li&gt;
&lt;li&gt;open slides&lt;/li&gt;
&lt;/ol&gt;


&lt;h1&gt;Script&lt;/h1&gt;

&lt;p&gt;(slide start)&lt;/p&gt;

&lt;p&gt;Hi, I&amp;rsquo;m Mat Schaffer and this is the DevOps Screencast.  This is the first
episode of the screencast, so while I haven&amp;rsquo;t nailed down the format yet, I
plan to cover a range of topics including infrastructure automation,
systems-level concepts and unix utility tutorials.&lt;/p&gt;

&lt;p&gt;(slide change)&lt;/p&gt;

&lt;p&gt;In this episode we&amp;rsquo;ll be looking at the basics of using Chef Solo.&lt;/p&gt;

&lt;p&gt;Chef is an server configuration framework written in Ruby. Using chef, we can
configure various software packages automatically. The recipes we build can
then be reused across many machines to ensure uniformity across all your
servers.&lt;/p&gt;

&lt;p&gt;Chef works in two modes, chef server and chef solo. Today we&amp;rsquo;ll talk about Chef
solo and we&amp;rsquo;ll cover Chef server in future screencasts.&lt;/p&gt;

&lt;p&gt;(slide change)&lt;/p&gt;

&lt;p&gt;In chef solo, there&amp;rsquo;s no separate chef server. You only have your development
machine and your application server. You develop your cookbooks and recipes
locally on your development machine.&lt;/p&gt;

&lt;p&gt;(change)&lt;/p&gt;

&lt;p&gt;You then copy these cookbooks and any other configuration information up to
your server using SCP or Rsync.&lt;/p&gt;

&lt;p&gt;(change)&lt;/p&gt;

&lt;p&gt;Then you invoke the chef-solo command on the server. The Chef-solo command will
then run through all the recipes you&amp;rsquo;ve specified in your node configuration
file.&lt;/p&gt;

&lt;p&gt;As you can see, this is somewhat manual. But there are a handful of tools that
you can use to make building and running your recipes a little easier.&lt;/p&gt;

&lt;p&gt;(slide change)&lt;/p&gt;

&lt;p&gt;Today we&amp;rsquo;ll use knife-solo. Knife-solo is a plugin for Knife, the main command
line utility that drives Chef.&lt;/p&gt;

&lt;p&gt;(change)&lt;/p&gt;

&lt;p&gt;I just recently released knife-solo, you may encounter some bugs. If you do,
please let me know. There are also other tools that help with this job that you
might want to try out like spatula, soloist or littlechef. Writing your own is
also fairly straight forward.&lt;/p&gt;

&lt;p&gt;(terminal)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ gem install knife-solo
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Knife solo is based on chef&amp;rsquo;s own knife helper tool. It gives you a few extra
commands that make working with chef solo a bit easier. If this is the first
time you&amp;rsquo;re using chef, the install make take a bit of time since it will also
install the chef gem. You&amp;rsquo;ll need to generate a configuration file.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife configure -r . --defaults
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The options I specified here just set up some defaults. Since we&amp;rsquo;re only using
chef solo we don&amp;rsquo;t need this configuration, but knife is a bit noisy if the
file doesn&amp;rsquo;t exist. Now I can use the knife kitchen command to make a place to
hold my recipes.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife kitchen solodemo $ cd solodemo $ tree
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will create the standard layout for a chef repository. We&amp;rsquo;ll go over these
in more detail in future screen casts. For today, we&amp;rsquo;ll focus on the cookbooks
and nodes directories.&lt;/p&gt;

&lt;p&gt;(chrome: github.com/opscode/cookbooks)&lt;/p&gt;

&lt;p&gt;Often you can find cookbooks for various packages online. Opscode, the company
that created chef maintains a cookbook repository on github. 37signals and
other companies are beginning to do the same. While these cookbooks don&amp;rsquo;t
always work for your particular environment they at least provide good examples
and starting points.&lt;/p&gt;

&lt;p&gt;(terminal)&lt;/p&gt;

&lt;p&gt;Today we&amp;rsquo;ll keep things simple and just install a nginx server. We could use
the opcode cookbook, but we&amp;rsquo;ll make one from scratch to get some practice
working with cookbooks.&lt;/p&gt;

&lt;p&gt;To create a cookbook, use the knife cookbook command.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife cookbook create nginx -o cookbooks
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We specify the name of the cookbook, nginx. And use the -o option to tell knife
to store it in the cookbooks directory. Each cookbook contains a default
recipe. We&amp;rsquo;ll use this recipe to install and start the nginx server.&lt;/p&gt;

&lt;p&gt;(redcar: cookbooks/nginx/recipes/default.rb)&lt;/p&gt;

&lt;p&gt;Chef uses a Ruby DSL to define recipes. But before we start coding it we&amp;rsquo;ll
have a look at what we want to do.&lt;/p&gt;

&lt;p&gt;(virtualbox, start it)&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;ve prepared a minimal Ubuntu system running on VirtualBox that we&amp;rsquo;ll use to
work through this installation. If you need pointers on creating your own I
have a blog post that goes over the process. Or you can download it from the
link you see here.&lt;/p&gt;

&lt;p&gt;(terminal)&lt;/p&gt;

&lt;p&gt;Now before we can run any recipes on our VM, we have to install chef solo on
it.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife prepare ubuntu@ip
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To do that we run knife prepare. This is a knife-solo command that will install
ruby and chef so that we can run chef solo. It also generates an empty node
configuration.&lt;/p&gt;

&lt;p&gt;(redcar: nodes/ip.json)&lt;/p&gt;

&lt;p&gt;This file is what tells chef which recipes should run on a given host. To
include the nginx recipe we just wrote, we add &lt;code&gt;recipe[nginx]&lt;/code&gt; to the run list.&lt;/p&gt;

&lt;p&gt;(terminal)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife cook ubuntu@ip
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now to install nginx on our VM using chef solo we run the knife cook command.
This will copy our cookbooks over to the VM and run chef solo using the node
configuration that matches the IP of the box.&lt;/p&gt;

&lt;p&gt;Now of course this didn&amp;rsquo;t do anything because we haven&amp;rsquo;t written the recipe. We
first want to install nginx, so we&amp;rsquo;ll take a look at the machine and find out
what the package name is.&lt;/p&gt;

&lt;p&gt;(virtualbox: logged in)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ apt-cache search nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As you can see it&amp;rsquo;s just &amp;ldquo;nginx&amp;rdquo;, so we&amp;rsquo;ll add a package statement to our
recipe for that and cook again.&lt;/p&gt;

&lt;p&gt;(redcar: default.rb)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;package 'nginx'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(terminal)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife cook ubuntu@ip
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(chrome: ip)&lt;/p&gt;

&lt;p&gt;Now nginx is installed, but it&amp;rsquo;s not yet running.&lt;/p&gt;

&lt;p&gt;(virtualbox)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ls /etc/init.d/
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As we can see here, the nginx package installs a standard init script. We can
tell chef to use that by defining a service that supports the &amp;lsquo;status&amp;rsquo; command.
This tells chef to use the init script rather than trying to inspect the
process table directly. Then we cook again.&lt;/p&gt;

&lt;p&gt;(redcar: default.rb)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;service 'nginx' do supports [:status] end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(terminal)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife cook ubuntu@ip
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(chrome: ip)&lt;/p&gt;

&lt;p&gt;As we can see, it&amp;rsquo;s still not running. All we&amp;rsquo;ve done here is defined a service
that chef now knows about. To start it, we add the :start action and cook
again.&lt;/p&gt;

&lt;p&gt;(redcar: default.rb)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;service 'nginx' do
  supports [:status]
  action :start
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(terminal)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife cook ubuntu@ip
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And now if we open a browser to the VM&amp;rsquo;s IP. We&amp;rsquo;ll get a nice welcome message.&lt;/p&gt;

&lt;p&gt;Now to demonstrate that we can reuse this recipe, we&amp;rsquo;ll roll back the VM and
run the whole thing in one sweep.&lt;/p&gt;

&lt;p&gt;(virtualbox: rollback)&lt;/p&gt;

&lt;p&gt;(terminal)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ knife prepare ubuntu@ip $ knife cook ubuntu@ip
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(chrome: ip)&lt;/p&gt;

&lt;p&gt;Now if we open that IP again, we have Nginx just as we did before with the same
configuration.&lt;/p&gt;

&lt;p&gt;And that&amp;rsquo;s it! We&amp;rsquo;ll go over more of the details in upcoming sceencasts, but
hopefully this is enough to get you started exploring chef for your own
servers. Thanks for watching!&lt;/p&gt;
</content>
  </entry>
</feed>
