Ansible 2.2 is our default: "always_run" goes away

This commit is contained in:
Jérémy Lecour 2017-03-24 15:27:16 +01:00 committed by Jérémy Lecour
parent d680ec831b
commit b8c43d2b12

View file

@ -186,21 +186,20 @@ The source file or template shouldn't to be prefixed for ordering (eg. `z-` or `
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. 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 : When an action depends on a variable registered by a previous action (that performs no change, like a grep, stat…) we should add a `check_mode: yes` (`always_run: yes` in Ansible <= 2.1). Example :
``` ```
- name: Check if Munin plugins exists - name: Check if Munin plugins exists
stat: stat:
path: /etc/munin/plugins/ path: /etc/munin/plugins/
register: munin_plugins_dir register: munin_plugins_dir
#check_mode: no (for migration to Ansible 2.2) check_mode: no
always_run: yes
- name: Get Munin plugin - name: Get Munin plugin
copy: copy:
src: munin/drbd-plugin src: munin/drbd-plugin
dest: /etc/munin/plugins/drbd dest: /etc/munin/plugins/drbd
mode: "755" mode: "0755"
when: munin_plugins_dir.stat.exists when: munin_plugins_dir.stat.exists
notify: restart munin-node notify: restart munin-node
``` ```