Changeset - 7387caca37f3
[Not reviewed]
docs/usage.rst
Show inline comments
 
@@ -2065,6 +2065,40 @@ Genie*. So let's fix that one.
 
          ok (it has to be executable by the root user).
 

	
 

	
 
Dealing with failures
 
---------------------
 

	
 
While the roles have been designed to be fairly robust, it should be taken into
 
account that certain handlers are used to bring the system into consistent
 
state. These handlers are mostly the ones dealing with service restarts, but
 
there are also a couple of handlers that take care of transforming certain data
 
into the required formats, import of files etc.
 

	
 
This means that failure to successfully execute such handlers could result in
 
inconsistent state on the server. Think of service configuration files being
 
updated, yet the service itself is not restarted and therefore continues to run
 
with the old configuration.
 

	
 
Handler execution failure can depend on a couple of things, including the loss
 
of SSH connectivity to managed machine, or some kind of unusual time-out during
 
handler execution.
 

	
 
To help handle this situation, Majic Ansible Roles all come with a special way
 
to invoke the handlers explicitly. Each role will include handlers as tasks,
 
provided that a special variable (``handlers``) is passed in to playbook run. To
 
make the run shorter, the handlers in such a run are also tagged with
 
``handlers``. This doubling of environment variable + tagging stems from current
 
limitations of Ansible (it is not possible to specify that certain task should
 
be run only if a tag is specified, therefore an additional variable has to be
 
used).
 

	
 
Handlers alone can be invoked specifically with command similar to::
 

	
 
  ansible-playbook -t handlers -e handlers=true playbook.yml
 

	
 
The ``handlers`` variable is treated as boolean, and by default it is not set.
 

	
 

	
 
Where to go next?
 
-----------------
 

	
roles/backup_client/tasks/main.yml
Show inline comments
 
@@ -77,4 +77,10 @@
 

	
 
- name: Deploy crontab entry for running backups
 
  cron: name=backup cron_file=backup hour=2 minute=0 job="/usr/bin/duply main backup"
 
        state=present user=root
 
\ No newline at end of file
 
        state=present user=root
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "handlers | default(False) | bool() == True"
 
  tags:
 
    - handlers
 
\ No newline at end of file
roles/backup_server/tasks/main.yml
Show inline comments
 
@@ -94,3 +94,9 @@
 
  template: src="ferm_backup.conf.j2" dest="/etc/ferm/conf.d/40-backup.conf" owner=root group=root mode=640
 
  notify:
 
    - Restart ferm
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "handlers | default(False) | bool() == True"
 
  tags:
 
    - handlers
 
\ No newline at end of file
roles/bootstrap/tasks/main.yml
Show inline comments
 
@@ -16,4 +16,10 @@
 
  copy: src=ansible_sudo dest=/etc/sudoers.d/ansible mode=640 owner=root group=root
 

	
 
- name: Revoke rights for Ansible user to log-in as root to server via ssh
 
  authorized_key: user=root key="{{ ansible_key }}" state=absent
 
\ No newline at end of file
 
  authorized_key: user=root key="{{ ansible_key }}" state=absent
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "handlers | default(False) | bool() == True"
 
  tags:
 
    - handlers
 
\ No newline at end of file
roles/common/tasks/main.yml
Show inline comments
 
@@ -97,3 +97,9 @@
 

	
 
- name: Enable ferm service
 
  service: name=ferm state=started
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "handlers | default(False) | bool() == True"
 
  tags:
 
    - handlers
 
\ No newline at end of file
roles/database/handlers/main.yml
Show inline comments
 
new file 100644
 
---
 
\ No newline at end of file
roles/database/tasks/main.yml
Show inline comments
 
@@ -9,4 +9,10 @@
 

	
 
- name: Enable backup
 
  include: backup.yml
 
  when: enable_backup
 
\ No newline at end of file
 
  when: enable_backup
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "handlers | default(False) | bool() == True"
 
  tags:
 
    - handlers
 
\ No newline at end of file
roles/database_server/tasks/main.yml
Show inline comments
 
@@ -26,3 +26,9 @@
 
  copy: src="utf8.cnf" dest="/etc/mysql/conf.d/utf8.cnf"
 
        owner=root group=root mode=644
 
  notify: Restart MariaDB
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "handlers | default(False) | bool() == True"
 
  tags:
 
    - handlers
 
\ No newline at end of file
roles/ldap_client/handlers/main.yml
Show inline comments
 
new file 100644
 
---
 
\ No newline at end of file
roles/ldap_client/tasks/main.yml
Show inline comments
 
@@ -5,3 +5,9 @@
 

	
 
- name: Deploy LDAP client configuration file
 
  template: src=ldap.conf.j2 dest=/etc/ldap/ldap.conf owner=root group=root mode=644
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "handlers | default(False) | bool() == True"
 
  tags:
 
    - handlers
roles/ldap_server/tasks/main.yml
Show inline comments
 
@@ -171,4 +171,10 @@
 

	
 
- name: Enable backup
 
  include: backup.yml
 
  when: enable_backup
 
\ No newline at end of file
 
  when: enable_backup
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "handlers | default(False) | bool() == True"
 
  tags:
 
    - handlers
 
\ No newline at end of file
roles/mail_forwarder/tasks/main.yml
Show inline comments
 
@@ -31,3 +31,9 @@
 

	
 
- name: Install SWAKS
 
  apt: name="swaks" state=installed
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "handlers | default(False) | bool() == True"
 
  tags:
 
    - handlers
roles/mail_server/tasks/main.yml
Show inline comments
 
@@ -148,3 +148,9 @@
 
  copy: src="ferm_mail.conf" dest="/etc/ferm/conf.d/20-mail.conf" owner=root group=root mode=640
 
  notify:
 
    - Restart ferm
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "handlers | default(False) | bool() == True"
 
  tags:
 
    - handlers
roles/php_website/handlers/main.yml
Show inline comments
 
new file 100644
 
---
 
\ No newline at end of file
roles/php_website/tasks/main.yml
Show inline comments
 
@@ -55,3 +55,9 @@
 
        state=link
 
  notify:
 
    - Restart nginx
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "handlers | default(False) | bool() == True"
 
  tags:
 
    - handlers
roles/preseed/handlers/main.yml
Show inline comments
 
new file 100644
 
---
roles/preseed/tasks/main.yml
Show inline comments
 
@@ -7,4 +7,10 @@
 
  template: src="preseed-jessie.cfg.j2" dest="{{ preseed_directory }}/{{ item }}.cfg"
 
            mode=640
 
  with_items: groups['all']
 
  when: item != "localhost"
 
\ No newline at end of file
 
  when: item != "localhost"
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "handlers | default(False) | bool() == True"
 
  tags:
 
    - handlers
roles/web_server/tasks/main.yml
Show inline comments
 
@@ -118,4 +118,10 @@
 
    - /etc/php5/cli/conf.d/
 
    - /etc/php5/fpm/conf.d/
 
  notify:
 
    - Restart php5-fpm
 
\ No newline at end of file
 
    - Restart php5-fpm
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "handlers | default(False) | bool() == True"
 
  tags:
 
    - handlers
roles/wsgi_website/tasks/main.yml
Show inline comments
 
@@ -104,3 +104,9 @@
 
        state=link
 
  notify:
 
    - Restart nginx
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "handlers | default(False) | bool() == True"
 
  tags:
 
    - handlers
roles/xmpp_server/tasks/main.yml
Show inline comments
 
@@ -62,3 +62,9 @@
 
  copy: src="ferm_xmpp.conf" dest="/etc/ferm/conf.d/30-xmpp.conf" owner=root group=root mode=640
 
  notify:
 
    - Restart ferm
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "handlers | default(False) | bool() == True"
 
  tags:
 
    - handlers
0 comments (0 inline, 0 general)