我有以下清单文件:
[web]
10.0.1.0
[db]
10.0.3.0
[frontend]
10.0.5.0
[X_all:children]
web
db
frontend
现在在我的剧本中:我正在尝试在名称行中的X_all组下打印主机名。
- name: "Copying the output of Registry run to local machine from {{ hostvars[item]['inventory_hostname'] }}"
become: true
become_user: "{{ login }}"
fetch:
src: /tmp/DeploymentRegistry.txt
dest: /tmp/DeploymentRegistry-{{ inventory_hostname }}.txt
flat: yes
with_items:
- "{{ groups['X_all'] }}"
是否甚至可以在名称行中添加主机名?
我尝试将{{ hostvars[item]['inventory_hostname'] }}
替换为inventory_hostname
,但也无法正常工作。