It is quite possible that you may need to get package updates through a proxy, or even get some package
updates through a proxy and access other packages not through a proxy. Ansible makes it easy for you
to configure your environment by using the 'environment' keyword. Here is an example::
- hosts: all
user: root
tasks:
- apt: name=cobbler state=installed
environment:
http_proxy: http://proxy.example.com:8080
The environment can also be stored in a variable, and accessed like so::
- hosts: all
user: root
# here we make a variable named "env" that is a dictionary
vars:
env:
http_proxy=http://proxy.example.com:8080
tasks:
- apt: name=cobbler state=installed
environment: $env
While just proxy settings were shown above, any number of settings can be supplied.
Getting values from files
`````````````````````````
@ -874,6 +917,35 @@ Therefore, if you want to set a default value for something you wish to override
place to set such a default is in a group variable. The 'group_vars/all' file makes an excellent place to put global
variables that are true across your entire site, since everything has higher priority than these values.
Check Mode ("Dry Run") --check
```````````````````````````````
..versionadded:: 1.1
When ansible-playbook is executed with --check it will not make any changes on remote systems. Instead, any module
instrumented to support 'check mode' (which contains the primary core modules, but it is not required that all modules do
this) will report what changes they would have made. Other modules that do not support check mode will also take no
action, but just will not report what changes they might have made.
Check mode is just a simulation, and if you have steps that use conditionals that depend on the results of prior commands,
it may be less useful for you. However it is great for one-node-at-time basic configuration management use cases.
Example::
ansible-playbook foo.yml --check
Showing Differences with --diff
```````````````````````````````
..versionadded:: 1.1
The --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
the textual changes made to the file (or, if used with --check, the changes that would have been made). Since the diff
feature produces a large amount of output, it is best used when checking a single host at a time, like so::