|
|
@ -23,22 +23,22 @@ This playbook, ``verify-apache.yml``, contains a single play with a handler.
|
|
|
|
max_clients: 200
|
|
|
|
max_clients: 200
|
|
|
|
remote_user: root
|
|
|
|
remote_user: root
|
|
|
|
tasks:
|
|
|
|
tasks:
|
|
|
|
- name: Ensure apache is at the latest version
|
|
|
|
- name: Ensure apache is at the latest version
|
|
|
|
ansible.builtin.yum:
|
|
|
|
ansible.builtin.yum:
|
|
|
|
name: httpd
|
|
|
|
name: httpd
|
|
|
|
state: latest
|
|
|
|
state: latest
|
|
|
|
|
|
|
|
|
|
|
|
- name: Write the apache config file
|
|
|
|
|
|
|
|
ansible.builtin.template:
|
|
|
|
|
|
|
|
src: /srv/httpd.j2
|
|
|
|
|
|
|
|
dest: /etc/httpd.conf
|
|
|
|
|
|
|
|
notify:
|
|
|
|
|
|
|
|
- Restart apache
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Ensure apache is running
|
|
|
|
- name: Write the apache config file
|
|
|
|
ansible.builtin.service:
|
|
|
|
ansible.builtin.template:
|
|
|
|
name: httpd
|
|
|
|
src: /srv/httpd.j2
|
|
|
|
state: started
|
|
|
|
dest: /etc/httpd.conf
|
|
|
|
|
|
|
|
notify:
|
|
|
|
|
|
|
|
- Restart apache
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Ensure apache is running
|
|
|
|
|
|
|
|
ansible.builtin.service:
|
|
|
|
|
|
|
|
name: httpd
|
|
|
|
|
|
|
|
state: started
|
|
|
|
|
|
|
|
|
|
|
|
handlers:
|
|
|
|
handlers:
|
|
|
|
- name: Restart apache
|
|
|
|
- name: Restart apache
|
|
|
@ -46,7 +46,7 @@ This playbook, ``verify-apache.yml``, contains a single play with a handler.
|
|
|
|
name: httpd
|
|
|
|
name: httpd
|
|
|
|
state: restarted
|
|
|
|
state: restarted
|
|
|
|
|
|
|
|
|
|
|
|
In this example playbook, the second task notifies the handler. A single task can notify more than one handler.
|
|
|
|
In this example playbook, the second task notifies the handler. A single task can notify more than one handler:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
|
|
|
@ -59,16 +59,16 @@ In this example playbook, the second task notifies the handler. A single task ca
|
|
|
|
- Restart memcached
|
|
|
|
- Restart memcached
|
|
|
|
- Restart apache
|
|
|
|
- Restart apache
|
|
|
|
|
|
|
|
|
|
|
|
handlers:
|
|
|
|
handlers:
|
|
|
|
- name: Restart memcached
|
|
|
|
- name: Restart memcached
|
|
|
|
ansible.builtin.service:
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: memcached
|
|
|
|
name: memcached
|
|
|
|
state: restarted
|
|
|
|
state: restarted
|
|
|
|
|
|
|
|
|
|
|
|
- name: Restart apache
|
|
|
|
- name: Restart apache
|
|
|
|
ansible.builtin.service:
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: apache
|
|
|
|
name: apache
|
|
|
|
state: restarted
|
|
|
|
state: restarted
|
|
|
|
|
|
|
|
|
|
|
|
Controlling when handlers run
|
|
|
|
Controlling when handlers run
|
|
|
|
-----------------------------
|
|
|
|
-----------------------------
|
|
|
@ -120,6 +120,7 @@ Handlers can also "listen" to generic topics, and tasks can notify those topics
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handlers:
|
|
|
|
handlers:
|
|
|
|
- name: Restart memcached
|
|
|
|
- name: Restart memcached
|
|
|
|
ansible.builtin.service:
|
|
|
|
ansible.builtin.service:
|
|
|
|