重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1672|回复: 1
打印 上一主题 下一主题

[系统管理] ansible有哪些魔法变量

[复制链接]
跳转到指定楼层
楼主
发表于 2020-11-17 15:14:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 郑全 于 2020-11-17 15:17 编辑

Magic
These variables cannot be set directly by the user; Ansible will always override them to reflect internal state.

ansible_check_mode
Boolean that indicates if we are in check mode or not

ansible_dependent_role_names

The names of the roles currently imported into the current play as dependencies of other plays

ansible_diff_mode

Boolean that indicates if we are in diff mode or not

ansible_forks

Integer reflecting the number of maximum forks available to this run

ansible_inventory_sources

List of sources used as inventory

ansible_limit

Contents of the --limit CLI option for the current execution of Ansible

ansible_loop

A dictionary/map containing extended loop information when enabled via loop_control.extended

ansible_loop_var

The name of the value provided to loop_control.loop_var. Added in 2.8

ansible_index_var

The name of the value provided to loop_control.index_var. Added in 2.9

ansible_parent_role_names

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 (i.e. the role that included/imported this role) being the first item in the list. When multiple inclusions occur, this list lists the last role (i.e. 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'].

ansible_parent_role_paths

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 (i.e. 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.

ansible_play_batch

List of active hosts in the current play run limited by the serial, aka ‘batch’. Failed/Unreachable hosts are not considered ‘active’.

ansible_play_hosts

The same as ansible_play_batch

ansible_play_hosts_all

List of all the hosts that were targeted by the play

ansible_play_role_names

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.

ansible_playbook_python

The path to the python interpreter being used by Ansible on the controller

ansible_role_names

The names of the roles currently imported into the current play, or roles referenced as dependencies of the roles imported into the current play.

ansible_role_name

The fully qualified collection role name, in the format of namespace.collection.role_name

ansible_collection_name

The name of the collection the task that is executing is a part of. In the format of namespace.collection

ansible_run_tags

Contents of the --tags CLI option, which specifies which tags will be included for the current run.

ansible_search_path

Current search path for action plugins and lookups, i.e where we search for relative paths when you do template: src=myfile

ansible_skip_tags

Contents of the --skip_tags CLI option, which specifies which tags will be skipped for the current run.

ansible_verbosity

Current verbosity setting for Ansible

ansible_version

Dictionary/map that contains information about the current running version of ansible, it has the following keys: full, major, minor, revision and string.

group_names

List of groups the current host is part of

groups

A dictionary/map with all the groups in inventory and each group has the list of hosts that belong to it

hostvars

A dictionary/map with all the hosts in inventory and variables assigned to them

inventory_hostname

The inventory name for the ‘current’ host being iterated over in the play

inventory_hostname_short

The short version of inventory_hostname

inventory_dir

The directory of the inventory source in which the inventory_hostname was first defined

inventory_file

The file name of the inventory source in which the inventory_hostname was first defined

omit

Special variable that allows you to ‘omit’ an option in a task, i.e - user: name=bob home={{ bobs_home|default(omit) }}

play_hosts

Deprecated, the same as ansible_play_batch

ansible_play_name

The name of the currently executed play. Added in 2.8.

playbook_dir

The path to the directory of the playbook that was passed to the ansible-playbook command line.

role_name

The name of the role currently being executed.

role_names

Deprecated, the same as ansible_play_role_names

role_path

The path to the dir of the currently running role

Facts
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-11-28 21:23 , Processed in 0.097035 second(s), 19 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表