summaryrefslogtreecommitdiff
path: root/docsite
diff options
context:
space:
mode:
authorStrahinja Kustudić <kustodian@gmail.com>2016-01-20 19:47:09 +0100
committerStrahinja Kustudić <kustodian@gmail.com>2016-04-08 00:26:02 +0200
commiteed6cf5dadc5e64353635506be82ba8e983cd20a (patch)
treec3128ecefbd8b0a4e845ff03f710f6a791d394ed /docsite
parent1942cd33dc3506b13b89bed871e43f7df7344a0d (diff)
downloadansible-eed6cf5dadc5e64353635506be82ba8e983cd20a.tar.gz
Adds 'ansible_check_mode' boolean magic variable
* Makes it possible to pass any options variable to VariableManager by changing `load_options_vars(options)` in `lib/ansible/utils/vars.py`
Diffstat (limited to 'docsite')
-rw-r--r--docsite/rst/playbooks_checkmode.rst20
-rw-r--r--docsite/rst/playbooks_variables.rst4
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: