diff options
Diffstat (limited to 'docsite')
-rw-r--r-- | docsite/rst/playbooks_checkmode.rst | 20 | ||||
-rw-r--r-- | docsite/rst/playbooks_variables.rst | 4 |
2 files changed, 22 insertions, 2 deletions
diff --git a/docsite/rst/playbooks_checkmode.rst b/docsite/rst/playbooks_checkmode.rst index 77bae8df4d..18d7b0cd60 100644 --- a/docsite/rst/playbooks_checkmode.rst +++ b/docsite/rst/playbooks_checkmode.rst @@ -38,7 +38,25 @@ Example:: As a reminder, a task with a `when` clause evaluated to false, will still be skipped even if it has a `always_run` clause evaluated to -true. +true. + +Also if you want to skip, or ignore errors on some tasks in check mode +you can use a boolean magic variable `ansible_check_mode` (added in version 2.1) +which will be set to `True` during check mode. + +Example:: + + tasks: + + - name: this task will be skipped in check mode + git: repo=ssh://git@github.com/mylogin/hello.git dest=/home/mylogin/hello + when: not ansible_check_mode + + - name: this task will ignore errors in check mode + git: repo=ssh://git@github.com/mylogin/hello.git dest=/home/mylogin/hello + ignore_errors: "{{ ansible_check_mode }}" + + .. _diff_mode: diff --git a/docsite/rst/playbooks_variables.rst b/docsite/rst/playbooks_variables.rst index bcdcaad331..89d379c3c4 100644 --- a/docsite/rst/playbooks_variables.rst +++ b/docsite/rst/playbooks_variables.rst @@ -674,7 +674,9 @@ Don't worry about any of this unless you think you need it. You'll know when yo Also available, ``inventory_dir`` is the pathname of the directory holding Ansible's inventory host file, ``inventory_file`` is the pathname and the filename pointing to the Ansible's inventory host file. -And finally, ``role_path`` will return the current role's pathname (since 1.8). This will only work inside a role. +We then have ``role_path`` which will return the current role's pathname (since 1.8). This will only work inside a role. + +And finally, ``ansible_check_mode`` (added in version 2.1), a boolean magic variable which will be set to ``True`` if you run Ansible with ``--check``. .. _variable_file_separation_details: |