<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Chef Tutorial Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/chef-tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/chef-tutorial/</link>
	<description>A Platform for Software Engineers</description>
	<lastBuildDate>Tue, 13 Jul 2021 14:46:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>How to Implement Chef roles using Chef server ?</title>
		<link>https://www.scmgalaxy.com/tutorials/implement-chef-roles-using-chef-server/</link>
					<comments>https://www.scmgalaxy.com/tutorials/implement-chef-roles-using-chef-server/#respond</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Thu, 24 Sep 2015 14:57:08 +0000</pubDate>
				<category><![CDATA[Chef]]></category>
		<category><![CDATA[Chef Guide]]></category>
		<category><![CDATA[Chef roles]]></category>
		<category><![CDATA[Chef server]]></category>
		<category><![CDATA[Chef Tutorial]]></category>
		<category><![CDATA[create Role in Chef]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[How to Implement Chef roles]]></category>
		<category><![CDATA[Implement]]></category>
		<category><![CDATA[Process]]></category>
		<category><![CDATA[Roles in Chef]]></category>
		<category><![CDATA[Steps]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2015/09/24/implement-chef-roles-using-chef-server/</guid>

					<description><![CDATA[<p>What is Role? A role is a way to define certain patterns and processes that exist across nodes in an [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/implement-chef-roles-using-chef-server/">How to Implement Chef roles using Chef server ?</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img fetchpriority="high" decoding="async" class="size-full wp-image-3345 aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2015/09/chef-roles-using-chef-serve.png" alt="implement-chef-roles-using-chef-server" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2015/09/chef-roles-using-chef-serve.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2015/09/chef-roles-using-chef-serve-300x200.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></p>
<p><strong>What is Role?</strong></p>
<p>A role is a way to define certain patterns and processes that exist across nodes in an organization as belonging to a single job function. Each role consists of zero (or more) attributes and a run-list. Each node can have zero (or more) roles assigned to it. When a role is run against a node, the configuration details of that node are compared against the attributes of the role, and then the contents of that role’s run-list are applied to the node’s configuration details. When a chef-client runs, it merges its own attributes and run-lists with those contained within each assigned role.</p>
<p><strong>How to use Roles in Chef?</strong></p>
<ol>
<li>Create a Role and add the cookbooks into it.</li>
<li>Assign the role into each node or bootstrap new nodes using roles</li>
<li>The the run list</li>
</ol>
<p><strong>How to create Role?</strong></p>
<p><strong>Method 1: In Chef Server directly</strong></p>
<pre><code>&gt; knife role create client1</code></pre>
<p>&amp;</p>
<p>Add the run list e.g. &#8220;recipe[nginx]&#8221; under &#8220;run_list&#8221;</p>
<p>Save &amp; exit</p>
<p>The role will be created in Chef Server.</p>
<p>Example</p>
<pre><code>{ "name": "client1", "description": "", "json_class": "Chef::Role", "default_attributes": { }, "override_attributes": { }, "chef_type": "role", "run_list": [ "recipe[nginx]", "recipe[phpapp::web]" ], "env_run_lists": { } } </code></pre>
<p><strong>Let&#8217;s download the role from the Chef server so we have it locally in a Chef repository.</strong></p>
<p>&gt; knife role show client1 -d -Fjson &gt; roles/client1.json</p>
<p><strong>Now, Lets bootstrap the node using knife with roles</strong></p>
<pre>&gt; knife bootstrap --run-list "role[client1]" --sudo hostname</pre>
<p><strong>How to edit the roles in chef Server?</strong></p>
<pre>&gt; knife role edit client1</pre>
<p><strong>Method 2: In local repo under chef-repo folder</strong></p>
<pre><code>&gt; vi webserver.rb</code></pre>
<p>example &#8211;</p>
<pre><code>name "web_server" description "Role for web servers" run_list(   "role[base]",   "recipe{web_server]" ) </code></pre>
<p>&amp; Then upload to chef server using following commands.</p>
<pre>&gt; knife role from file path/to/role/file</pre>
<p><strong>How Assigning Roles to Nodes?</strong></p>
<pre><code>&gt; knife node list</code></pre>
<pre><code>&gt; knife node edit node_name</code></pre>
<p>This will bring up the node&#8217;s definition file, which will allow us to add a role to its run_list:</p>
<pre><code>{ "name": "client1", "chef_environment": "_default", "normal": { "tags": [  ] 	}, "run_list": [ 	"recipe[nginx]" ] } </code></pre>
<p>For instance, we can replace our recipe with our role in this file:</p>
<pre><code>{ "name": "client1", "chef_environment": "_default", "normal": { "tags": [ ] }, "run_list": [ "role[web_server]" ] } </code></pre>
<p><strong>How to bootstrap node using role?</strong></p>
<pre><code>&gt; knife bootstrap {{address}} --ssh-user {{user}} --ssh-password '{{password}}' --sudo --use-sudo-password --node-name node1 --run-list 'role[production]'</code></pre>
<pre><code>&gt; knife bootstrap --run-list "role[phpapp-web]" --sudo hostname</code></pre>
<p><strong>How to run roles against nodes?</strong></p>
<p>You can run chef-client on multiple nodes via knife ssh command like, To query for all nodes that have the webserver role and then use SSH to run the command sudo chef-client, enter:</p>
<pre><code>&gt; knife ssh "role:webserver" "sudo chef-client"</code></pre>
<p>To find the uptime of all of web servers running Ubuntu on the Amazon EC2 platform, enter:</p>
<pre><code>&gt; knife ssh "role:web" "uptime" -x ubuntu -a ec2.public_hostname</code></pre>
<p><strong>Reference</strong></p>
<p><a href="http://docs.chef.io/roles.html" target="_blank" rel="noopener">http://docs.chef.io/roles.html</a></p>
<p><a href="https://docs.chef.io/knife_ssh.html" target="_blank" rel="noopener">https://docs.chef.io/knife_ssh.html</a></p>
<p><a href="https://docs.chef.io/knife_role.html" target="_blank" rel="noopener">https://docs.chef.io/knife_role.html</a></p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/implement-chef-roles-using-chef-server/">How to Implement Chef roles using Chef server ?</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/implement-chef-roles-using-chef-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Chef &#8211; Documenting Cookbooks automatically</title>
		<link>https://www.scmgalaxy.com/tutorials/chef-documenting-cookbooks-automatically/</link>
					<comments>https://www.scmgalaxy.com/tutorials/chef-documenting-cookbooks-automatically/#respond</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Tue, 18 Aug 2015 16:20:57 +0000</pubDate>
				<category><![CDATA[Chef]]></category>
		<category><![CDATA[Auto]]></category>
		<category><![CDATA[Automate]]></category>
		<category><![CDATA[Automatically]]></category>
		<category><![CDATA[Automation]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Chef cookbook]]></category>
		<category><![CDATA[Chef cookbook documentation]]></category>
		<category><![CDATA[Chef Guide]]></category>
		<category><![CDATA[Chef Tutorial]]></category>
		<category><![CDATA[Cookbooks]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Documenting Cookbooks]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2015/08/18/chef-documenting-cookbooks-automatically/</guid>

					<description><![CDATA[<p>Problems Area &#8211; Our infrastructure has many cookbooks that aim to be reusable, primarily through encapsulating behaviour in LWRPs. This [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/chef-documenting-cookbooks-automatically/">Chef &#8211; Documenting Cookbooks automatically</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" class="alignnone size-full wp-image-3444 aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2015/08/chef-documenting-cookbooks.png" alt="chef-documenting-cookbooks" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2015/08/chef-documenting-cookbooks.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2015/08/chef-documenting-cookbooks-300x200.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></p>
<p><strong>Problems Area &#8211;</strong></p>
<p>Our infrastructure has many cookbooks that aim to be reusable, primarily through encapsulating behaviour in LWRPs. This led to an explosion of LWRPs and sometimes the documentation didn&#8217;t keep up or did just not exist.</p>
<p><strong>Solution 1: Follow Best Practices </strong></p>
<p>This command will create a README.rdoc by default, and I prefer <a href="https://www.collectiveray.com/markdown-cheat-sheet">Markdown</a>, so I specify the -r md option.</p>
<pre>&gt; knife cookbook create smartmontools -r md</pre>
<p><strong>Solution 2: Automate using plugins</strong></p>
<p>README.md which should be generated automatcially must contain information about the recipes, attributes, platform compatibility and cookbook requirements (i.e. depends, recommends, suggests etc).</p>
<p>Mathias Lafeldt wrote a knife plugin that generates an initial README.md from the metadata.rb file in a a cookbook.</p>
<p>Link &#8211;</p>
<ul>
<li><a href="https://github.com/mlafeldt/knife-cookbook-readme">https://github.com/mlafeldt/knife-cookbook-readme</a></li>
<li><a href="http://mlafeldt.github.io/knife-cookbook-readme/">http://mlafeldt.github.io/knife-cookbook-readme/</a></li>
</ul>
<p>Extension of Mathias Lafeldt was done here with regenerate README.md from the cookbook source code</p>
<ul>
<li><a href="https://github.com/realityforge/knife-cookbook-doc">https://github.com/realityforge/knife-cookbook-doc</a></li>
</ul>
<p><strong>Please refer these useful blogs as well which is referenced in order to write this article&#8230;</strong></p>
<ul>
<li><a href="http://realityforge.org/code/2013/04/01/documenting-cookbooks.html">http://realityforge.org/code/2013/04/01/documenting-cookbooks.html</a></li>
</ul>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/chef-documenting-cookbooks-automatically/">Chef &#8211; Documenting Cookbooks automatically</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/chef-documenting-cookbooks-automatically/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
