Conventions: add "check mode" section

This commit is contained in:
Jérémy Lecour 2017-01-31 11:53:38 +01:00 committed by Jérémy Lecour
parent 91a5928ffb
commit f0aaf767ec

View file

@ -182,6 +182,29 @@ copy:
The source file or template shouldn't to be prefixed for ordering (eg. `z-` or `zzz-`). It's the task's responsibility to choose how destination files must be ordered.
### check mode
Ansible can run playbooks in "check mode" with the `--check` argument of `ansible-playbook`. It won't do any changing action but will report what would be changed or not.
When an action depends on a variable registered by a previous action (that performs no change, like a grep, stat…) we should add a `always_run: yes` to the action. In Ansible 2.2, the behaviour has been replace by `check_mode: yes.` Exemple :
```
- name: Check if Munin plugins exists
stat:
path: /etc/munin/plugins/
register: munin_plugins_dir
#check_mode: no (for migration to Ansible 2.2)
always_run: yes
- name: Get Munin plugin
copy:
src: munin/drbd-plugin
dest: /etc/munin/plugins/drbd
mode: "755"
when: munin_plugins_dir.stat.exists
notify: restart munin-node
```
### packages installation
When making a role or a task the necessary packages must be installed explicitly.