<?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 Guide Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/chef-guide/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/chef-guide/</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>week1 &#8211; Overview of Chef.pdf</title>
		<link>https://www.scmgalaxy.com/tutorials/week1-overview-of-chef-pdf/</link>
					<comments>https://www.scmgalaxy.com/tutorials/week1-overview-of-chef-pdf/#respond</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Tue, 09 Jan 2018 12:33:58 +0000</pubDate>
				<category><![CDATA[Chef]]></category>
		<category><![CDATA[About Chef]]></category>
		<category><![CDATA[Chef Guide]]></category>
		<category><![CDATA[Chef Introduction]]></category>
		<category><![CDATA[Chef Overview]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/?p=4736</guid>

					<description><![CDATA[<p>week1 &#8211; Overview of Chef.pdf week1 &#8211; Overview of Chef.pdf</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/week1-overview-of-chef-pdf/">week1 &#8211; Overview of Chef.pdf</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>week1 &#8211; Overview of Chef.pdf</p>
<p><strong><a href="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2018/01/week1-Overview-of-Chef.pdf.pdf">week1 &#8211; Overview of Chef.pdf</a></strong></p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/week1-overview-of-chef-pdf/">week1 &#8211; Overview of Chef.pdf</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/week1-overview-of-chef-pdf/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Logging in Chef Explained</title>
		<link>https://www.scmgalaxy.com/tutorials/logging-in-chef-explained/</link>
					<comments>https://www.scmgalaxy.com/tutorials/logging-in-chef-explained/#comments</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Wed, 26 Jul 2017 12:22:56 +0000</pubDate>
				<category><![CDATA[Chef]]></category>
		<category><![CDATA[Chef Guide]]></category>
		<category><![CDATA[Chef recipe]]></category>
		<category><![CDATA[Chef Tutorials]]></category>
		<category><![CDATA[Logging in Chef]]></category>
		<category><![CDATA[Logs]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2017/07/26/logging-in-chef-explained/</guid>

					<description><![CDATA[<p>Chef Server All logs generated by the Chef server can be found in /var/log/opscode. Each service enabled on the system [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/logging-in-chef-explained/">Logging in Chef Explained</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-2845 aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/07/logging-in-chef-explained.png" alt="logging-in-chef-explained" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/07/logging-in-chef-explained.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/07/logging-in-chef-explained-300x200.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></p>
<p><strong>Chef Server</strong><br />
All logs generated by the Chef server can be found in /var/log/opscode. Each service enabled on the system also has a sub-directory in which service-specific logs are located, typically found in /var/log/opscode/service_name.</p>
<p>The Chef server has built-in support for easily tailing the logs that are generated. To view all the logs being generated on the Chef server, enter the following command:<br />
&gt; chef-server-ctl tail</p>
<p><strong>To view logs for a specific service:</strong><br />
&gt; chef-server-ctl tail SERVICENAME<br />
where SERVICENAME should be replaced with name of the service for which log files will be viewed. SERVICENAME represents the name of any service that is listed after running the &#8220;&gt; chef-server-ctl service-list&#8221; subcommand.</p>
<p><strong>Another way to view log files is to use the system utility tail:</strong><br />
&gt; tail -50f /var/log/chef-server/opscode-chef/current<br />
&gt; tail -50f /var/log/opscode/opscode-chef/current</p>
<p><strong>Supervisor Logs</strong><br />
Supervisor logs are created and managed directly by the service supervisor, and are automatically rotated when a the current log file reaches 1,000,000 bytes. 10 log files are kept. The latest supervisor log is always located in /var/log/chef-server/service_name/current and rotated logs have a filename starting with @ followed by a precise tai64n timestamp based on when the file was rotated.</p>
<p>Supervisor logs are available for the following services:</p>
<ol>
<li>bifrost</li>
<li>bookshelf</li>
<li>nginx</li>
<li>opscode-erchef</li>
<li>opscode-expander</li>
<li>opscode-expander-reindexer</li>
<li>opscode-solr4</li>
<li>postgresql</li>
<li>rabbitmq</li>
<li>redis</li>
</ol>
<h3>nginx</h3>
<p>The nginx service creates both supervisor and administrator logs. The administrator logs contain both access and error logs for each virtual host utilized by the Chef server. Each of the following logs require external log rotation.</p>
<table border="1">
<colgroup>
<col width="13%" />
<col width="88%" /> </colgroup>
<thead valign="bottom">
<tr>
<th>Logs</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr>
<td>/var/log/opscode/nginx/access.log</td>
<td>The Web UI and API HTTP access logs.</td>
</tr>
<tr>
<td>/var/log/opscode/nginx/error.log</td>
<td>The Web UI and API HTTP error logs.</td>
</tr>
<tr>
<td>/var/log/opscode/nginx/internal-account.access.log</td>
<td>The opscode-account internal load-balancer access logs.</td>
</tr>
<tr>
<td>/var/log/opscode/nginx/internal-account.error.log</td>
<td>The opscode-account internal load-balancer error logs.</td>
</tr>
<tr>
<td>/var/log/opscode/nginx/internal-authz.access.log</td>
<td>The opscode-authz internal load-balancer access logs.</td>
</tr>
<tr>
<td>/var/log/opscode/nginx/internal-authz.error.log</td>
<td>The opscode-authz internal load-balancer error logs.</td>
</tr>
<tr>
<td>/var/log/opscode/nginx/internal-chef.access.log</td>
<td>The opscode-chef and opscode-erchef internal load-balancer access logs.</td>
</tr>
<tr>
<td>/var/log/opscode/nginx/internal-chef.error.log</td>
<td>The opscode-chef and opscode-erchef internal load-balancer error logs.</td>
</tr>
<tr>
<td>/var/log/opscode/nginx/nagios.access.log</td>
<td>The nagios access logs.</td>
</tr>
<tr>
<td>/var/log/opscode/nginx/nagios.error.log</td>
<td>The nagios error logs.</td>
</tr>
<tr>
<td>/var/log/opscode/nginx/rewrite-port-80.log</td>
<td>The rewrite logs for traffic that uses HTTP instead of HTTPS.</td>
</tr>
</tbody>
</table>
<p>To follow the logs for the service:</p>
<div>
<div>
<pre> $ chef-server-ctl tail nginx</pre>
</div>
</div>
<p><strong>Chef Client</strong></p>
<p>Client.rb3 file might help you. Default value of log_location is STDOUT. You can give /path/to/log_location in place of this. You can locate this client.rb file in C:\chef\client.rb or /etc/chef/client.rb directories.</p>
<p>Use the verbose logging that is built into the chef-client:<br />
-l LEVEL, &#8211;log_level LEVEL<br />
The level of logging to be stored in a log file.<br />
-L LOGLOCATION, &#8211;logfile c<br />
The location of the log file. This is recommended when starting any executable as a daemon. Default value: STDOUT.</p>
<p><strong>Knife</strong><br />
Use the verbose logging that is built into knife:<br />
-V, &#8211;verbose<br />
Set for more verbose outputs. Use -VV for maximum verbosity.</p>
<p><strong>chef-solo</strong><br />
-l LEVEL, &#8211;log_level LEVEL<br />
The level of logging to be stored in a log file.</p>
<p>The Chef file and folder locations are different on Linux and Windows machines. This article explains the purpose of each file and the location.</p>
<h4>Summary</h4>
<table border="1" width="100%">
<tbody>
<tr>
<th></th>
<th>Linux</th>
<th>Windows</th>
</tr>
<tr>
<td>Cookbook location</td>
<td>/var/chef/cache/cookbooks</td>
<td> C:\chef\cache\cookbooks</td>
</tr>
<tr>
<td>Chef Client run log</td>
<td>/var/log/chef.log</td>
<td>First run only<br />
C:\chef\chef-client.log</td>
</tr>
<tr>
<td></td>
<td></td>
<td>Subsequent Chef client runs<br />
C:\chef\log\client.log</td>
</tr>
<tr>
<td>Error log</td>
<td>/var/chef/cache/chef-stacktrace.out</td>
<td>C:\chef\cache\chef-stacktrace.out</td>
</tr>
<tr>
<td>Ohai output</td>
<td>/var/chef/cache/failed-run-data.json</td>
<td>C:\chef\cache\failed-run-data.json</td>
</tr>
<tr>
<td>Recommended location for custom log files</td>
<td>/tmp/cheflog.log</td>
<td>C:\Logs\Chef\cheflog.log</td>
</tr>
<tr>
<td height="43">Chef Client configuration</td>
<td>/etc/chef/client.rb</td>
<td>C:\chef\client.rb</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h4>When you test your cookbook in Test Kitchen</h4>
<p>The .kitchen.yml file contains the username to execute the Chef cookbook. It is specified under <strong>platforms</strong>:, <strong>transport</strong>:, <strong>username</strong>:</p>
<p>Use that value in place of <strong>USER-NAME-FROM-KITCHEN-YML</strong> below.</p>
<table border="1" width="100%">
<tbody>
<tr>
<th></th>
<th>Linux</th>
<th>Windows</th>
</tr>
<tr>
<td>Cookbook location</td>
<td>/tmp/kitchen/cookbooks<br />
/tmp/kitchen/cache/cookbooks</td>
<td> C:\Users\USER-NAME-FROM-KITCHEN-YML\AppData\Local\Temp\kitchen\cookbooks</td>
</tr>
<tr>
<td>Error log</td>
<td>/tmp/kitchen/cache/chef-stacktrace.out</td>
<td>C:\Users\USER-NAME-FROM-KITCHEN-YML\AppData\Local\Temp\kitchen\cache\chef-stacktrace.out</td>
</tr>
<tr>
<td>Ohai output</td>
<td>/tmp/kitchen/cache/failed-run-data.json</td>
<td>C:\Users\USER-NAME-FROM-KITCHEN-YML\AppData\Local\Temp\kitchen\cache\failed-run-data.json</td>
</tr>
<tr>
<td>Data bags</td>
<td>/tmp/kitchen/data_bags</td>
<td>C:\Users\USER-NAME-FROM-KITCHEN-YML\AppData\Local\Temp\kitchen\data_bags</td>
</tr>
</tbody>
</table>
<p>&nbsp;<br />
<strong>Cookbook location </strong></p>
<p>When the Chef recipes are executed, all cookbooks are stored on the node. You can examine the code to make sure your latest changes are reflected on the machine.</p>
<p><strong>The log of the Chef client run</strong></p>
<p>The output of the Chef cookbook execution is in the chef.log or chef-client.log file</p>
<p><strong>On Windows</strong></p>
<p><strong>The log of the first Chef Client run and subsequent runs are stored in different log files.</strong> After the initial Chef Client run, the rest of the log entries are collected in the second file.</p>
<p><strong>Stacktrace</strong></p>
<p>Chef saves information on the hard drive when scripts are executed. If there is a failure, the stack trace of the last error is saved in the <strong>chef-stacktrace.out</strong> file.</p>
<p><strong>Ohai output</strong></p>
<p>All the information that Ohai collects on the instance, is saved in the <strong>failed-run-data.json</strong>file, even if there is no error. It is a great resource to get the server specific values.</p>
<p><strong>Reference</strong></p>
<p><a href="https://docs.chef.io/server_logs.html" target="_blank" rel="noopener">https://docs.chef.io/server_logs.html</a><br />
<a href="https://docs.chef.io/debug.html" target="_blank" rel="noopener">https://docs.chef.io/debug.html</a></p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/logging-in-chef-explained/">Logging in Chef Explained</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/logging-in-chef-explained/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Chef notifies and subscribes explained with examples</title>
		<link>https://www.scmgalaxy.com/tutorials/chef-notifies-and-subscribes-explained-with-examples/</link>
					<comments>https://www.scmgalaxy.com/tutorials/chef-notifies-and-subscribes-explained-with-examples/#respond</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Wed, 26 Jul 2017 10:27:56 +0000</pubDate>
				<category><![CDATA[Chef]]></category>
		<category><![CDATA[Chef Guide]]></category>
		<category><![CDATA[Chef notifies]]></category>
		<category><![CDATA[Chef subscribes]]></category>
		<category><![CDATA[Chef Tutorials]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Explanation]]></category>
		<category><![CDATA[Notification]]></category>
		<category><![CDATA[Subscription]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2017/07/26/chef-notifies-and-subscribes-explained-with-examples/</guid>

					<description><![CDATA[<p>&#160; Chef notifies and subscribes explained with examples A notification is a property on a resource that listens to other [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/chef-notifies-and-subscribes-explained-with-examples/">Chef notifies and subscribes explained with examples</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3><img decoding="async" class="alignnone size-full wp-image-2867 aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/07/chef-notifies-and-subscribe.png" alt="chef-notifies-and-subscribes-explained-with-examples" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/07/chef-notifies-and-subscribe.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/07/chef-notifies-and-subscribe-300x200.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></h3>
<p>&nbsp;</p>
<h3>Chef notifies and subscribes explained with examples</h3>
<div></div>
<div>A notification is a property on a resource that listens to other resources in the resource collection and then takes actions based on the notification type (notifies or subscribes).</div>
<div></div>
<p>&nbsp;</p>
<h3>Timers</h3>
<div>A timer specifies the point during the chef-client run at which a notification is run. The following timers are available:</div>
<div><strong>:before</strong></div>
<div>Specifies that the action on a notified resource should be run before processing the resource block in which the notification is located.</div>
<div></div>
<div><strong>:delayed</strong></div>
<div>Default. Specifies that a notification should be queued up, and then executed at the very end of the chef-client run.</div>
<div></div>
<div><strong>:immediate, :immediately</strong></div>
<div>Specifies that a notification should be run immediately, per resource notified.</div>
<div></div>
<p>&nbsp;</p>
<h3>Notifies</h3>
<div>A resource may notify another resource to take action when its state changes. Specify a &#8216;resource[name]&#8217;, the :action that resource should take, and then the :timer for that action. A resource may notify more than one resource; use a notifies statement for each resource to be notified.</div>
<div>The syntax for notifies is:</div>
<div>notifies :action, &#8216;resource[name]&#8217;, :timer</div>
<div></div>
<p>&nbsp;</p>
<div><strong>Example</strong></div>
<div>The following examples show how to use the notifies notification in a recipe.</div>
<div></div>
<p>&nbsp;</p>
<div><strong>Delay notifications</strong></div>
<div>template &#8216;/etc/nagios3/configures-nagios.conf&#8217; do</div>
<div>  # other parameters</div>
<div>  notifies :run, &#8216;execute[test-nagios-config]&#8217;, :delayed</div>
<div>end</div>
<div></div>
<p>&nbsp;</p>
<div><strong>Notify immediately</strong></div>
<div>By default, notifications are :delayed, that is they are queued up as they are triggered, and then executed at the very end of a chef-client run. To run an action immediately, use :immediately:</div>
<div>template &#8216;/etc/nagios3/configures-nagios.conf&#8217; do</div>
<div>  # other parameters</div>
<div>  notifies :run, &#8216;execute[test-nagios-config]&#8217;, :immediately</div>
<div>end</div>
<div></div>
<div>and then the chef-client would immediately run the following:</div>
<div>execute &#8216;test-nagios-config&#8217; do</div>
<div>  command &#8216;nagios3 &#8211;verify-config&#8217;</div>
<div>  action :nothing</div>
<div>end</div>
<div></div>
<p>&nbsp;</p>
<h3>Subscribes</h3>
<div>A resource may listen to another resource, and then take action if the state of the resource being listened to changes. Specify a &#8216;resource[name]&#8217;, the :action to be taken, and then the :timer for that action.</div>
<div></div>
<div>Note that subscribes does not apply the specified action to the resource that it listens to &#8211; for example:</div>
<div>file &#8216;/etc/nginx/ssl/example.crt&#8217; do</div>
<div>   mode &#8216;0600&#8217;</div>
<div>   owner &#8216;root&#8217;</div>
<div>end</div>
<div></div>
<div>service &#8216;nginx&#8217; do</div>
<div>   subscribes :reload, &#8216;file[/etc/nginx/ssl/example.crt]&#8217;, :immediately</div>
<div>end</div>
<div></div>
<div>In this case the subscribes property reloads the nginx service whenever its certificate file, located under /etc/nginx/ssl/example.crt, is updated. subscribes does not make any changes to the certificate file itself, it merely listens for a change to the file, and executes the :reload action for its resource (in this example nginx) when a change is detected.</div>
<div>The syntax for subscribes is:</div>
<div>subscribes :action, &#8216;resource[name]&#8217;, :timer</div>
<div></div>
<p>&nbsp;</p>
<div><strong>Examples</strong></div>
<div>The following examples show how to use the subscribes notification in a recipe.</div>
<div></div>
<div>Prevent restart and reconfigure if configuration is broken</div>
<div></div>
<div>Use the :nothing action (common to all resources) to prevent the test from starting automatically, and then use the subscribes notification to run a configuration test when a change to the template is detected:</div>
<div></div>
<div>execute &#8216;test-nagios-config&#8217; do</div>
<div>  command &#8216;nagios3 &#8211;verify-config&#8217;</div>
<div>  action :nothing</div>
<div>  subscribes :run, &#8216;template[/etc/nagios3/configures-nagios.conf]&#8217;, :immediately</div>
<div>end</div>
<div></div>
<div></div>
<p>&nbsp;</p>
<div><strong>Reference</strong></div>
<div><a href="https://docs.chef.io/resources.html#id4" target="_blank" rel="noopener">https://docs.chef.io/resources.html#id4</a></div>
<div></div>
<div><strong>Example</strong></div>
<div><a href="https://gist.github.com/nathanhoel/f5433a0d9cfe2e717c71" target="_blank" rel="noopener">https://gist.github.com/nathanhoel/f5433a0d9cfe2e717c71</a></div>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/chef-notifies-and-subscribes-explained-with-examples/">Chef notifies and subscribes explained with examples</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/chef-notifies-and-subscribes-explained-with-examples/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is the significance of the default directory under chef cookbook /templates?</title>
		<link>https://www.scmgalaxy.com/tutorials/what-is-the-significance-of-the-default-directory-under-chef-cookbook-templates/</link>
					<comments>https://www.scmgalaxy.com/tutorials/what-is-the-significance-of-the-default-directory-under-chef-cookbook-templates/#respond</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Wed, 26 Jul 2017 06:39:53 +0000</pubDate>
				<category><![CDATA[Chef]]></category>
		<category><![CDATA[Chef Client]]></category>
		<category><![CDATA[Chef cookbook]]></category>
		<category><![CDATA[Chef Guide]]></category>
		<category><![CDATA[Chef templates]]></category>
		<category><![CDATA[Chef Tutorials]]></category>
		<category><![CDATA[Default directory]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2017/07/26/what-is-the-significance-of-the-default-directory-under-chef-cookbook-templates/</guid>

					<description><![CDATA[<p>&#160; What is the significance of the default directory under chef cookbook /templates? A cookbook is frequently designed to work [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/what-is-the-significance-of-the-default-directory-under-chef-cookbook-templates/">What is the significance of the default directory under chef cookbook /templates?</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img decoding="async" class="size-full wp-image-2878 aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/07/chef-cookbook-templates.png" alt="" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/07/chef-cookbook-templates.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/07/chef-cookbook-templates-300x200.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></div>
<p>&nbsp;</p>
<div>What is the significance of the default directory under chef cookbook /templates?</div>
<div></div>
<div>A cookbook is frequently designed to work across many platforms and is often required to distribute a specific template to a specific platform. This is a New in Chef Client 12.0. A cookbook can be designed to support the distribution of templates across platforms, while ensuring that the correct template ends up on each system.</div>
<div></div>
<p>&nbsp;</p>
<div><strong>The pattern for template specificity depends on two things: the lookup path and the source. The first pattern that matches is used:</strong></div>
<div></div>
<div>/host-$fqdn/$source</div>
<div>/$platform-$platform_version/$source</div>
<div>/$platform/$source</div>
<div>/default/$source</div>
<div>/$source</div>
<div></div>
<p>&nbsp;</p>
<div><strong>Use an array with the source property to define an explicit lookup path. For example:</strong></div>
<div>template &#8216;/test&#8217; do</div>
<div>  source [&#8220;#{node.chef_environment}.erb&#8221;, &#8216;default.erb&#8217;]</div>
<div>end</div>
<div></div>
<p>&nbsp;</p>
<div><strong>The following example emulates the entire file specificity pattern by defining it as an explicit path:</strong></div>
<div>template &#8216;/test&#8217; do</div>
<div>  source %W{</div>
<div>    host-#{node[&#8216;fqdn&#8217;]}/test.erb</div>
<div>    #{node[&#8216;platform&#8217;]}-#{node[&#8216;platform_version&#8217;]}/test.erb</div>
<div>    #{node[&#8216;platform&#8217;]}/test.erb</div>
<div>    default/test.erb</div>
<div>  }</div>
<div>end</div>
<div></div>
<p>&nbsp;</p>
<div><strong>A cookbook may have a /templates directory structure like this:</strong></div>
<div>/templates/</div>
<div>  windows-6.2</div>
<div>  windows-6.1</div>
<div>  windows-6.0</div>
<div>  windows</div>
<div>  default</div>
<div></div>
<p>&nbsp;</p>
<div><strong>and a resource that looks something like the following:</strong></div>
<div>template &#8216;C:\path\to\file\text_file.txt&#8217; do</div>
<div>  source &#8216;text_file.txt&#8217;</div>
<div>  mode &#8216;0755&#8217;</div>
<div>  owner &#8216;root&#8217;</div>
<div>  group &#8216;root&#8217;</div>
<div>end</div>
<div></div>
<p>&nbsp;</p>
<div><strong>This resource would be matched in the same order as the /templates directory structure. For a node named host-node-desktop that is running Windows 7, the second item would be the matching item and the location:</strong></div>
<div>/templates</div>
<div>  windows-6.2/text_file.txt</div>
<div>  windows-6.1/text_file.txt</div>
<div>  windows-6.0/text_file.txt</div>
<div>  windows/text_file.txt</div>
<div>
<p>  default/text_file.txt</p>
<p><strong>Reference</strong><br />
<a href="https://docs.chef.io/resource_template.html" target="_blank" rel="noopener">https://docs.chef.io/resource_template.html</a></p>
</div>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/what-is-the-significance-of-the-default-directory-under-chef-cookbook-templates/">What is the significance of the default directory under chef cookbook /templates?</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/what-is-the-significance-of-the-default-directory-under-chef-cookbook-templates/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<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 loading="lazy" 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="auto, (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 loading="lazy" 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="auto, (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>
		<item>
		<title>Know about metadata.rb and metadata.json in Chef</title>
		<link>https://www.scmgalaxy.com/tutorials/know-about-metadata-rb-and-metadata-json-in-chef/</link>
					<comments>https://www.scmgalaxy.com/tutorials/know-about-metadata-rb-and-metadata-json-in-chef/#respond</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Tue, 18 Aug 2015 15:52:08 +0000</pubDate>
				<category><![CDATA[Chef]]></category>
		<category><![CDATA[Chef cookbooks]]></category>
		<category><![CDATA[Chef Guide]]></category>
		<category><![CDATA[Chef Tutorials]]></category>
		<category><![CDATA[Cookbooks]]></category>
		<category><![CDATA[Metadata]]></category>
		<category><![CDATA[Metadata in chef]]></category>
		<category><![CDATA[metadata.json]]></category>
		<category><![CDATA[metadata.rb]]></category>
		<category><![CDATA[What]]></category>
		<category><![CDATA[What is metadata.json]]></category>
		<category><![CDATA[What is metadata.rb]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2015/08/18/know-about-metadata-rb-and-metadata-json-in-chef/</guid>

					<description><![CDATA[<p>What is Metadata in chef? In order to understand cookbooks without evaluating them every files, we generate metadata about cookbooks [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/know-about-metadata-rb-and-metadata-json-in-chef/">Know about metadata.rb and metadata.json in Chef</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3446 aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2015/08/metadata-rb-and-metadata-js.png" alt="metadata-rb-and-metadata-json-in-chef" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2015/08/metadata-rb-and-metadata-js.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2015/08/metadata-rb-and-metadata-js-300x200.png 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></p>
<p><strong>What is Metadata in chef?</strong></p>
<p>In order to understand cookbooks without evaluating them every files, we generate metadata about cookbooks</p>
<p><strong>What is metadata.rb?</strong></p>
<p>Before unerstanding about metadata.json, we need to understand about metadata.rb.</p>
<p>Every cookbook requires a small amount of metadata. Metadata is stored in a file called metadata.rb that lives at the top of each cookbook’s directory. The contents of the metadata.rb file provides hints to the Chef server so that cookbooks are deployed to each node correctly.</p>
<p>A metadata.rb file is never interpreted directly. Rather, the metadata.rb file provides a simple location to store and edit data that is then compiled by the Chef server and stored as JSON data.</p>
<p>Metadata is compiled whenever &#8230;.</p>
<p>1. a cookbook is uploaded to the Chef server or</p>
<p>2. when the knife cookbook metadata subcommand is run. knife creates a metadata.rb file automatically whenever the knife cookbook create subcommand is run.</p>
<p><strong>metadata.json</strong></p>
<p>metadata.json is generated from metadata.rb. to generate or regenerate the Chef cookbook metadata, which creates a new &#8216;metadata.json&#8217; file from the &#8216;metadata.rb&#8217; file.</p>
<p>From the command line of your Chef development server, enter the following command:</p>
<p># knife cookbook metadata my-cookbook -o &lt;COOKBOOK_PATH&gt;</p>
<p>Example:  # knife cookbook metadata my-cookbook-name -o /opt/development/cookbooks/</p>
<p>A metadata.json file can be edited directly, should temporary changes be required. Any subsequent upload or action that generates metadata will cause the existing metadata.json file to be overwritten with the newly generated metadata. Therefore, any permanent change to metadata that is required should only be made in the metadata.rb file.</p>
<p><strong>What if metadata.rb and metadata.json both are present in cookbooks?</strong></p>
<p>If a cookbook contains both a metadata.rb and metadata.json at cookbook load time, the metadata.rb will be preferred. This should be swapped around to ensure that dynamically built metadata which has been compiled is read properly without error.</p>
<p>knife cookbook upload reads metadata.rb and ignores metadata.json. It generates the data from the .rb file, and uploads that. It does not create a metadata.json file, on disk or in the cookbook itself&#8211;this is just metadata in the cookbook object.</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/know-about-metadata-rb-and-metadata-json-in-chef/">Know about metadata.rb and metadata.json in Chef</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/know-about-metadata-rb-and-metadata-json-in-chef/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
