These variables cannot be set directly by the user; Ansible will always override them to reflect internal state.
Boolean that indicates if we are in check mode or not
The full path of used Ansible configuration file
The names of the roles currently imported into the current play as dependencies of other plays
Boolean that indicates if we are in diff mode or not
Integer reflecting the number of maximum forks available to this run
List of sources used as inventory
Contents of the --limit
CLI option for the current execution of Ansible
A dictionary/map containing extended loop information when enabled via loop_control.extended
The name of the value provided to loop_control.loop_var
. Added in 2.8
The name of the value provided to loop_control.index_var
. Added in 2.9
When the current role is being executed by means of an include_role or import_role action, this variable contains a list of all parent roles, with the most recent role (in other words, the role that included/imported this role) being the first item in the list. When multiple inclusions occur, this list lists the last role (in other words, the role that included this role) as the first item in the list. It is also possible that a specific role exists more than once in this list.
For example: When role A includes role B, inside role B, ansible_parent_role_names
will equal to ['A']
. If role B then includes role C, the list becomes ['B', 'A']
.
When the current role is being executed by means of an include_role or import_role action, this variable contains a list of all parent roles, with the most recent role (in other words, the role that included/imported this role) being the first item in the list. Please refer to ansible_parent_role_names
for the order of items in this list.
List of active hosts in the current play run limited by the serial, aka ‘batch’. Failed/Unreachable hosts are not considered ‘active’.
List of hosts in the current play run, not limited by the serial. Failed/Unreachable hosts are excluded from this list.
List of all the hosts that were targeted by the play
The names of the roles currently imported into the current play. This list does not contain the role names that are implicitly included via dependencies.
The path to the python interpreter being used by Ansible on the controller
The names of the roles currently imported into the current play, or roles referenced as dependencies of the roles imported into the current play.
The fully qualified collection role name, in the format of namespace.collection.role_name
The name of the collection the task that is executing is a part of. In the format of namespace.collection
Contents of the --tags
CLI option, which specifies which tags will be included for the current run. Note that if --tags
is not passed, this variable will default to ["all"]
.
Current search path for action plugins and lookups, in other words, where we search for relative paths when you do template: src=myfile
Contents of the --skip-tags
CLI option, which specifies which tags will be skipped for the current run.
Current verbosity setting for Ansible
Dictionary/map that contains information about the current running version of ansible, it has the following keys: full, major, minor, revision and string.
List of groups the current host is part of
A dictionary/map with all the groups in inventory and each group has the list of hosts that belong to it
A dictionary/map with all the hosts in inventory and variables assigned to them
The inventory name for the ‘current’ host being iterated over in the play
The short version of inventory_hostname
The directory of the inventory source in which the inventory_hostname
was first defined
The file name of the inventory source in which the inventory_hostname
was first defined
Special variable that allows you to ‘omit’ an option in a task, for example - user: name=bob home={{ bobs_home|default(omit) }}
Deprecated, the same as ansible_play_batch
The name of the currently executed play. Added in 2.8
. (name
attribute of the play, not file name of the playbook.)
The path to the directory of the playbook that was passed to the ansible-playbook
command line.
The name of the role currently being executed.
Deprecated, the same as ansible_play_role_names
The path to the dir of the currently running role
These are variables that contain information pertinent to the current host (inventory_hostname
). They are only available if gathered first. See Discovering variables: facts and magic variables for more information.
Contains any facts gathered or cached for the inventory_hostname
Facts are normally gathered by the setup module automatically in a play, but any module can return facts.
Contains any ‘local facts’ gathered or cached for the inventory_hostname
. The keys available depend on the custom facts created. See the setup module and facts.d or local facts for more details.
Connection variables are normally used to set the specifics on how to execute actions on a target. Most of them correspond to connection plugins, but not all are specific to them; other plugins like shell, terminal and become are normally involved. Only the common ones are described as each connection/become/shell/etc plugin can define its own overrides and specific variables. See Controlling how Ansible behaves: precedence rules for how connection variables interact with configuration settings, command-line options, and playbook keywords.
The user Ansible ‘becomes’ after using privilege escalation. This must be available to the ‘login user’.
The connection plugin actually used for the task on the target host.
The ip/name of the target host to use instead of inventory_hostname
.
The path to the Python executable Ansible should use on the target host.
The user Ansible ‘logs in’ as.
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.11/reference_appendices/special_variables.html