{"id":416,"date":"2013-11-03T11:34:28","date_gmt":"2013-11-03T16:34:28","guid":{"rendered":"http:\/\/www.virtualroadside.com\/blog\/?p=416"},"modified":"2013-11-03T11:34:28","modified_gmt":"2013-11-03T16:34:28","slug":"versioned-chef-environments","status":"publish","type":"post","link":"https:\/\/www.virtualroadside.com\/blog\/index.php\/2013\/11\/03\/versioned-chef-environments\/","title":{"rendered":"Versioned chef environments"},"content":{"rendered":"<p>I was just recently introduced to <a href=\"http:\/\/www.opscode.com\/chef\/\">chef<\/a>, and it has turned out to be a pretty useful tool for automating infrastructure. One feature that I&#8217;m using in our environment is chef environments. A bunch of developers are all updating this file, and their cookbooks depend on attributes in it*.\u00c2\u00a0 I keep getting bit by various user errors that all could be solved if a cookbook could state &#8216;make sure you have at least this version of the environment&#8217;.<\/p>\n<p>I&#8217;m sure there&#8217;s a good reason for it, but chef does not currently support versioning environments. To work around this problem, I created a cookbook with a library function that can check a node attribute and compare the version information there to determine if the environment is out of date. It&#8217;s a bit of a hack for now, but it gets the job done.<\/p>\n<p>I thought someone else might find this useful, so I uploaded the code to <a href=\"https:\/\/github.com\/virtuald\/environment-version\">github<\/a> and to the <a href=\"http:\/\/community.opscode.com\/cookbooks\/environment-version\">opscode community site<\/a>. If you have a need for versioned environments in chef, this might work for you too. Let me know if you find it useful!<\/p>\n<p>*Yes, this could be considered an anti-pattern, but for our use case using environments to override attributes makes perfect sense, and allows us to not have to fork every community cookbook that we want to use.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was just recently introduced to chef, and it has turned out to be a pretty useful tool for automating infrastructure. One feature that I&#8217;m using in our environment is chef environments. A bunch of developers are all updating this file, and their cookbooks depend on attributes in it*.\u00c2\u00a0 I keep getting bit by various [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/416"}],"collection":[{"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=416"}],"version-history":[{"count":2,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/416\/revisions"}],"predecessor-version":[{"id":418,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/416\/revisions\/418"}],"wp:attachment":[{"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}