Download:
child 22:41738f738ed3
parent 20:92a12df47b17
21:40558d07f6d0
Anton Shestakov <av6@dwimlabs.net>, Tue, 09 Aug 2016 16:01:05 +0800
playbook: instead of restarting things in post_tasks, just include handlers

1 файлов изменено, 12 вставок(+), 13 удалений(-) [+]
playbook-example.yml file | annotate | diff | comparison | revisions
--- a/playbook-example.yml Tue Aug 09 16:00:33 2016 +0800
+++ b/playbook-example.yml Tue Aug 09 16:01:05 2016 +0800
@@ -17,12 +17,9 @@
dest: /etc/hosts
line: '127.0.0.1 {{ hostname }} hg.{{ hostname }}'
- # NOTE: this role depends on nginx and supervisor packages being installed,
- # and also it uses two handlers:
- # - reload supervisor
- # - restart nginx
- # This role doesn't have the handlers, so this playbook restarts the
- # services in post_tasks instead.
+ # NOTE: hgweb role depends on Nginx and Supervisor being installed. It's
+ # recommended to install them in separate nginx and supervisor roles, not
+ # in pre_tasks like in this example playbook.
- name: Install Nginx
apt:
update_cache: yes
@@ -44,14 +41,16 @@
# tags: [supervisor]
- role: hgweb
tags: [hgweb]
- post_tasks:
- - name: Restart Nginx
+ handlers:
+ # NOTE: hgweb role notifies two handlers:
+ # - reload supervisor
+ # - restart nginx
+ # Naturally, the handlers are not defined in the role itself, so this
+ # example playbook includes them here.
+ - name: reload supervisor
+ shell: supervisorctl update
+ - name: restart nginx
service:
name: nginx
state: restarted
- - name: Restart Supervisor
- service:
- name: supervisor
- state: restarted
- sleep: 1
...