<?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 subscribes Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/chef-subscribes/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/chef-subscribes/</link>
	<description>A Platform for Software Engineers</description>
	<lastBuildDate>Sat, 27 Feb 2021 09:49:35 +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>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 fetchpriority="high" 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>
	</channel>
</rss>
