{"id":300,"date":"2013-09-03T09:41:16","date_gmt":"2013-09-03T09:41:16","guid":{"rendered":"http:\/\/andypalmer.com\/?p=300"},"modified":"2013-09-03T09:41:16","modified_gmt":"2013-09-03T09:41:16","slug":"opscode-chef-and-the-single-responsibility-principle","status":"publish","type":"post","link":"https:\/\/andypalmer.com\/2013\/09\/opscode-chef-and-the-single-responsibility-principle\/","title":{"rendered":"Opscode Chef and the Single Responsibility Principle"},"content":{"rendered":"
My current project is managing the software and distribution of a hardware appliance. We send out physical machines to our customers and we really need to know that they are all identical. While I’ve been writing new recipes, I’ve started using a pattern that ensures good separation of responsibilities while making the recipes themselves easy to read. <\/p>\n In my pattern, the I’ve found that this style results in much tidier recipes. <\/p>\n","protected":false},"excerpt":{"rendered":" My current project is managing the software and distribution of a hardware appliance. We send out physical machines to our customers and we really need to know that they are all identical. I’ve set up a build system that uses PXE to boot the Ubuntu installer, which is preseeded with a very basic install of […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/posts\/300"}],"collection":[{"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/comments?post=300"}],"version-history":[{"count":2,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/posts\/300\/revisions"}],"predecessor-version":[{"id":302,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/posts\/300\/revisions\/302"}],"wp:attachment":[{"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/media?parent=300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/categories?post=300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andypalmer.com\/wp-json\/wp\/v2\/tags?post=300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
\nI’ve set up a build system that uses PXE to boot the Ubuntu installer, which is preseeded with a very<\/strong> basic install of linux. We then use chef (actually chef-solo) to configure the remainder of the software. (I’ll write a bit more about the reasons behind this later)<\/p>\ndefault.rb<\/code> file in the recipe consists only of includes<\/strong>. The default recipe is used to make sure that something useful happens.
\nFor example, I created a recipe to install and configure the Hamachi VPN client. This consists of two recipes; install.rb<\/code> (which downloads and installs the appropriate package and dependencies) and
connect.rb<\/code> (which authenticates with Hamachi and joins the appropriate network). The default.rb includes<\/em> these two recipes.<\/p>\n