PageRenderTime 16ms CodeModel.GetById 11ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/docsite/rst/playbooks_checkmode.rst

https://github.com/ajanthanm/ansible
ReStructuredText | 55 lines | 35 code | 20 blank | 0 comment | 0 complexity | 89c224b5bdd3a9b1c0fcf3ad2055fcff MD5 | raw file
 1Check Mode ("Dry Run")
 2======================
 3
 4.. versionadded:: 1.1
 5
 6.. contents:: Topics
 7
 8When ansible-playbook is executed with ``--check`` it will not make any changes on remote systems.  Instead, any module
 9instrumented to support 'check mode' (which contains most of the primary core modules, but it is not required that all modules do
10this) will report what changes they would have made rather than making them.  Other modules that do not support check mode will also take no action, but just will not report what changes they might have made.
11
12Check mode is just a simulation, and if you have steps that use conditionals that depend on the results of prior commands,
13it may be less useful for you.  However it is great for one-node-at-time basic configuration management use cases.
14
15Example::
16
17    ansible-playbook foo.yml --check
18
19.. _forcing_to_run_in_check_mode:
20
21Running a task in check mode
22````````````````````````````
23
24.. versionadded:: 1.3
25
26Sometimes you may want to have a task to be executed even in check
27mode. To achieve this, use the `always_run` clause on the task. Its
28value is a Jinja2 expression, just like the `when` clause. In simple
29cases a boolean YAML value would be sufficient as a value.
30
31Example::
32
33    tasks:
34
35      - name: this task is run even in check mode
36        command: /something/to/run --even-in-check-mode
37        always_run: yes
38
39As a reminder, a task with a `when` clause evaluated to false, will
40still be skipped even if it has a `always_run` clause evaluated to
41true.
42
43.. _diff_mode:
44
45Showing Differences with ``--diff``
46```````````````````````````````````
47
48.. versionadded:: 1.1
49
50The ``--diff`` option to ansible-playbook works great with ``--check`` (detailed above) but can also be used by itself.  When this flag is supplied, if any templated files on the remote system are changed, and the ansible-playbook CLI will report back
51the textual changes made to the file (or, if used with ``--check``, the changes that would have been made).  Since the diff
52feature produces a large amount of output, it is best used when checking a single host at a time, like so::
53
54    ansible-playbook foo.yml --check --diff --limit foo.example.com
55