{"id":1664,"date":"2013-03-13T14:44:22","date_gmt":"2013-03-13T19:44:22","guid":{"rendered":"http:\/\/www.kickflop.net\/blog\/?p=1664"},"modified":"2013-03-13T14:44:22","modified_gmt":"2013-03-13T19:44:22","slug":"bootstrapping-new-chef-nodes-without-knife-bootstrap","status":"publish","type":"post","link":"https:\/\/www.kickflop.net\/blog\/2013\/03\/13\/bootstrapping-new-chef-nodes-without-knife-bootstrap\/","title":{"rendered":"Bootstrapping new Chef nodes without knife bootstrap"},"content":{"rendered":"<p>There may be a time when you don&#8217;t want to (or cannot) make use of <code><a href=\"http:\/\/docs.opscode.com\/knife_bootstrap.html\">knife bootstrap<\/a><\/code> to set up a new Chef node or a whole fleet of hundreds of nodes. If that&#8217;s the case, and you already have a &#8220;hook&#8221; into the hosts you want to turn into Chef nodes (such as an existing CM tool), you have an option.<!--more--><\/p>\n<ol>\n<li>Install the proper Chef client <a href=\"http:\/\/www.opscode.com\/chef\/install\/\">package<\/a> for the OS<\/li>\n<li><code>mkdir \/etc\/chef<\/code><\/li>\n<li>Drop your &#8220;<a href=\"http:\/\/docs.opscode.com\/essentials_chef_client_validator.html\">validator<\/a>&#8220;, typically <code>validation.pem<\/code> in <code>\/etc\/chef<\/code><\/li>\n<li>Drop a basic <code>client.rb<\/code> in <code>\/etc\/chef<\/code><\/li>\n<li>Drop a JSON file somewhere that includes the node attributes you want to set for the new node<\/li>\n<li>Run <code>chef-client -E some-environment -j \/your\/json\/file<\/code><\/li>\n<li>When you&#8217;re happy, <code>rm -f \/etc\/chef\/validation.pem<\/code><\/li>\n<\/ol>\n<p>What&#8217;s interesting here (bug?) is that, when running <code>chef-client<\/code>, specifying <code>-E some-environment<\/code> will assign <code>some-environment<\/code> to the node and persist that setting on the Chef server. Trying to use <code>-o 'role[myrole]'<\/code> to prime <em>and persist<\/em> a run list for the node will not work (hence the JSON hack).<\/p>\n<p>You should end up with a new client and node defined on your Chef server and the node should have the environment and run list set the way you specified.<\/p>\n<h3>Example files<\/h3>\n<pre>\r\n# \/etc\/chef\/client.rb\r\nlog_level        :auto\r\nlog_location     STDOUT\r\nchef_server_url  \"https:\/\/your-chef-server.example.com\"\r\nvalidation_client_name \"chef-validator\"\r\n<\/pre>\n<pre>\r\n# \/tmp\/boot.json\r\n{\r\n  \"run_list\": [\"role[myrole]\", \"recipe[foo::bar]\"]\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>There may be a time when you don&#8217;t want to (or cannot) make use of knife bootstrap to set up&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51,35,11,48],"tags":[],"class_list":["post-1664","post","type-post","status-publish","format-standard","hentry","category-devops","category-linux","category-sysadmin","category-unixlinux"],"_links":{"self":[{"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/posts\/1664","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/comments?post=1664"}],"version-history":[{"count":4,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/posts\/1664\/revisions"}],"predecessor-version":[{"id":1668,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/posts\/1664\/revisions\/1668"}],"wp:attachment":[{"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/media?parent=1664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/categories?post=1664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/tags?post=1664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}