我正在尝试使用Python API
从所有可能的位置提取variables
在我的剧本中我有
---
hosts: abc.com
gather_facts: no
roles:
- my_roles
vars_files:
- var/var.yml
tasks:
.....
.....
文件结构-
test_play.yml
roles
- my_roles
-- defaults
vars
- var.yml
hosts
- DEV
-- hosts
-- group_vars
--- all.yml
我的代码--
host_file = path_to_host_file
play_path = path_to_playbook
inventory = InventoryManager(loader=DataLoader(), source=[host_file])
variable_manager = VariableManager(loader=DataLoader(), inventory=inventory)
pb = Playbook.load(play_path, variable_manager, DataLoader())
play = pb.get_plays()
# here I get one play, which is fine
all_vars = variable_manager.get_vars(play=plays[0])
在all_vars
中,我仅获取在inventory file, rules
中定义的变量。但是var.yml, group_vars/all.yml
中定义的变量缺失。如何得到它们
目前没有回答
相关问题 更多 >
编程相关推荐