04.04.2020 Views

Mastering Ansible

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 1

4. Rest of the variables defined in inventory

5. Facts discovered about a system

6. Role defaults

This list is a useful starting point, however things are a bit more nuanced, as we

will explore.

Extra-vars

Extra-vars, as supplied on the command line, certainly overrides anything else.

Regardless of where else a variable might be defined, even if it's explicitly set in a

play with set_fact, the value provided on the command line will be the value used.

Connection variables

Next up are connection variables, the behavioral variables outlined earlier. These

are variables that influence how Ansible will connect to and execute tasks on a

system. These are variables like ansible_ssh_user, ansible_ssh_host, and others

as described in the earlier section regarding behavioral inventory parameters. The

Ansible documentation states that these come from the inventory, however, they can

be overridden by tasks such as set_fact. A set_fact module on a variable such

as ansible_ssh_user will override the value that came from the inventory source.

There is a precedence order within the inventory as well. Host-specific definitions

will override group definitions, and child group definitions will override parent of

group definitions. This allows for having a value that applies to most things in a

group and overrides it on specific hosts that would be different. When a host belongs

to multiple groups and each group defines the same variable with different values,

the behavior is less defined and strongly discouraged.

Most everything else

The "most everything else" block is a big grouping of sources. These include:

• Command line switches

• Play variables

• Task variables

• Role variables (not defaults)

[ 29 ]

www.allitebooks.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!