Permalink
Browse files

some improvments to the 2017-09-02-ansible-handlers-listen.md

  • Loading branch information...
resmo committed Sep 4, 2017
1 parent 1f09a11 commit e61674b3fbf30e62b3d75eafcf8b1773515a786f
@@ -62,9 +62,13 @@ handlers:
{{< / highlight >}}
Done! Our postfix playbook has all we want and we think to turn it into a generic postfix role for putting it on galaxy.
Done!
{{< highlight yaml "linenos=inline,hl_lines=7" >}}
Our postfix playbook has all we want and we think about to turn it into a generic postfix role and sharing it on galaxy.
The slack handler is nothing we want to put in a generic postfix role, right. Further having a notify for a handler located outside a role is not practical. Let's remove the slack notification from role change the playbook to use the postfix role.
{{< highlight yaml "linenos=inline" >}}
# file: role/postfix/tasks/main.yml
- name: configure postfix
template:
@@ -74,15 +78,15 @@ Done! Our postfix playbook has all we want and we think to turn it into a generi
- restart postfix
{{< / highlight >}}
{{< highlight yaml "linenos=inline,hl_lines=2" >}}
{{< highlight yaml "linenos=inline" >}}
# file: role/postfix/handlers/main.yml
- name: restart postfix
service:
name: postfix
state: restarted
{{< / highlight >}}
The slack handler is nothing we want to put in a generic postfix role, right. Further having a notify for a handler located outside a role is not practical. Let's remove the slack notification from role change the playbook to use the postfix role.
We remove the postfix task in our playbook and use the new created postfix role:
{{< highlight yaml "linenos=inline,hl_lines=3" >}}
...
@@ -98,7 +102,7 @@ handlers:
{{< / highlight >}}
But now, the slack handler won't get notified anymore. How we can solve that? How can we subscribe to a change of a task? Handler listen!
We are back to the problem that the slack handler won't get notified anymore. How we can solve that? How can we subscribe to a change of a task? Handler listen!
## Handler Listen
@@ -422,7 +422,7 @@ <h4 class="card-header">Top Tags</h4>
</ul>
</div>
<div class="site-meta text-muted">
Last updated: September 3, 2017 <a href="https://github.com/resmo/website/commit/d3cb0f1a4bcdf91ddbff0fc80d0abb23adc5994c">git:d3cb0f1a4bcdf91ddbff0fc80d0abb23adc5994c</a>
Last updated: September 4, 2017 <a href="https://github.com/resmo/website/commit/1f09a1102c8e41b4024e5e1239f179a37c4cdd34">git:1f09a1102c8e41b4024e5e1239f179a37c4cdd34</a>
</div>
</footer>
@@ -159,27 +159,31 @@ <h2 id="subscribe-to-changes">Subscribe to Changes</h2>
</pre></div>
<p>Done! Our postfix playbook has all we want and we think to turn it into a generic postfix role for putting it on galaxy.</p>
<p>Done!</p>
<p>Our postfix playbook has all we want and we think about to turn it into a generic postfix role and sharing it on galaxy.</p>
<p>The slack handler is nothing we want to put in a generic postfix role, right. Further having a notify for a handler located outside a role is not practical. Let&rsquo;s remove the slack notification from role change the playbook to use the postfix role.</p>
<div class="highlight" style="background: #f0f0f0"><pre style="line-height: 125%"><span></span><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">1 </span><span style="color: #60a0b0; font-style: italic"># file: role/postfix/tasks/main.yml</span>
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">2 </span>- name: configure postfix
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">3 </span> template:
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">4 </span> src: main.conf.j2
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">5 </span> dest: /etc/postfix/main.cnf
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">6 </span> notify:
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">7 </span><span style="background-color: #ffffcc"> - restart postfix
</span></pre></div>
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">7 </span> - restart postfix
</pre></div>
<div class="highlight" style="background: #f0f0f0"><pre style="line-height: 125%"><span></span><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">1 </span><span style="color: #60a0b0; font-style: italic"># file: role/postfix/handlers/main.yml</span>
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">2 </span><span style="background-color: #ffffcc">- name: restart postfix
</span><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">3 </span> service:
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">2 </span>- name: restart postfix
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">3 </span> service:
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">4 </span> name: postfix
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">5 </span> state: restarted
</pre></div>
<p>The slack handler is nothing we want to put in a generic postfix role, right. Further having a notify for a handler located outside a role is not practical. Let&rsquo;s remove the slack notification from role change the playbook to use the postfix role.</p>
<p>We remove the postfix task in our playbook and use the new created postfix role:</p>
<div class="highlight" style="background: #f0f0f0"><pre style="line-height: 125%"><span></span><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 1 </span><span style="color: #0e84b5; font-weight: bold">...</span>
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 2 </span>roles:
@@ -194,7 +198,7 @@ <h2 id="subscribe-to-changes">Subscribe to Changes</h2>
</pre></div>
<p>But now, the slack handler won&rsquo;t get notified anymore. How we can solve that? How can we subscribe to a change of a task? Handler listen!</p>
<p>We are back to the problem that the slack handler won&rsquo;t get notified anymore. How we can solve that? How can we subscribe to a change of a task? Handler listen!</p>
<h2 id="handler-listen">Handler Listen</h2>
@@ -340,7 +344,7 @@ <h4 class="card-header">Top Tags</h4>
</ul>
</div>
<div class="site-meta text-muted">
Last updated: September 3, 2017 <a href="https://github.com/resmo/website/commit/8588214be844b7e40d8a4cf6037ef1be18ce384b">git:8588214be844b7e40d8a4cf6037ef1be18ce384b</a>
Last updated: September 4, 2017 <a href="https://github.com/resmo/website/commit/05c557e8e5421b2e9cc4409cce4361b5725fa880">git:05c557e8e5421b2e9cc4409cce4361b5725fa880</a>
</div>
</footer>
View
@@ -287,7 +287,7 @@ <h4 class="card-header">Top Tags</h4>
</ul>
</div>
<div class="site-meta text-muted">
Last updated: September 3, 2017
Last updated: September 4, 2017
</div>
</footer>
@@ -233,7 +233,7 @@ <h4 class="card-header">Meta</h4>
</ul>
</div>
<div class="site-meta text-muted">
Last updated: September 3, 2017
Last updated: September 4, 2017
</div>
</footer>
View
@@ -121,7 +121,7 @@ <h3>Follow me at <a href="http://twitter.com/resmo79">@resmo79</a>.</h3>
</ul>
</div>
<div class="site-meta text-muted">
Last updated: September 3, 2017
Last updated: September 4, 2017
</div>
</footer>
View
@@ -4,12 +4,12 @@
<url>
<loc>https://www.renemoser.net/blog/2017/09/02/decoupling-ansible-handlers/</loc>
<lastmod>2017-09-03T00:21:33+02:00</lastmod>
<lastmod>2017-09-04T08:46:55+02:00</lastmod>
</url>
<url>
<loc>https://www.renemoser.net/blog/2017/08/19/manage-exoscale-dns-with-ansible/</loc>
<lastmod>2017-09-03T00:21:19+02:00</lastmod>
<lastmod>2017-09-04T08:33:15+02:00</lastmod>
</url>
<url>
@@ -105,7 +105,7 @@
<url>
<loc>https://www.renemoser.net/tags/ansible/</loc>
<lastmod>2017-09-03T00:21:33+02:00</lastmod>
<lastmod>2017-09-04T08:46:55+02:00</lastmod>
<priority>0</priority>
</url>
@@ -129,7 +129,7 @@
<url>
<loc>https://www.renemoser.net/blog/</loc>
<lastmod>2017-09-03T00:21:33+02:00</lastmod>
<lastmod>2017-09-04T08:46:55+02:00</lastmod>
<priority>0</priority>
</url>
@@ -147,7 +147,7 @@
<url>
<loc>https://www.renemoser.net/tags/cloud/</loc>
<lastmod>2017-09-03T00:21:19+02:00</lastmod>
<lastmod>2017-09-04T08:33:15+02:00</lastmod>
<priority>0</priority>
</url>
@@ -171,7 +171,7 @@
<url>
<loc>https://www.renemoser.net/tags/dns/</loc>
<lastmod>2017-09-03T00:21:19+02:00</lastmod>
<lastmod>2017-09-04T08:33:15+02:00</lastmod>
<priority>0</priority>
</url>
@@ -237,7 +237,7 @@
<url>
<loc>https://www.renemoser.net/tags/oss/</loc>
<lastmod>2017-09-03T00:21:19+02:00</lastmod>
<lastmod>2017-09-04T08:33:15+02:00</lastmod>
<priority>0</priority>
</url>
@@ -279,7 +279,7 @@
<url>
<loc>https://www.renemoser.net/</loc>
<lastmod>2017-09-03T00:21:33+02:00</lastmod>
<lastmod>2017-09-04T08:46:55+02:00</lastmod>
<priority>0</priority>
</url>
@@ -297,7 +297,7 @@
<url>
<loc>https://www.renemoser.net/categories/sysadmin/</loc>
<lastmod>2017-09-03T00:21:33+02:00</lastmod>
<lastmod>2017-09-04T08:46:55+02:00</lastmod>
<priority>0</priority>
</url>
@@ -232,7 +232,7 @@ <h4 class="card-header">Meta</h4>
</ul>
</div>
<div class="site-meta text-muted">
Last updated: September 3, 2017
Last updated: September 4, 2017
</div>
</footer>
@@ -171,7 +171,7 @@ <h4 class="card-header">Meta</h4>
</ul>
</div>
<div class="site-meta text-muted">
Last updated: September 3, 2017
Last updated: September 4, 2017
</div>
</footer>
View
@@ -200,7 +200,7 @@ <h4 class="card-header">Meta</h4>
</ul>
</div>
<div class="site-meta text-muted">
Last updated: September 3, 2017
Last updated: September 4, 2017
</div>
</footer>
View
@@ -232,7 +232,7 @@ <h4 class="card-header">Meta</h4>
</ul>
</div>
<div class="site-meta text-muted">
Last updated: September 3, 2017
Last updated: September 4, 2017
</div>
</footer>

0 comments on commit e61674b

Please sign in to comment.