mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
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`
This commit is contained in:
@@ -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:
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user