【发布时间】:2017-12-21 06:35:29
【问题描述】:
以下内容:
store_controller:
hosts:
SERVER:
ansible_host: "{{ STORE_CTL }}"
mgmt_ip: "{{ ansible_host }}"
global_mgmt:
hosts:
SERVER:
ansible_host: "{{ NOMAD_SERVER }}"
mgmt_ip: "{{ ansible_host }}"
node_exporter: ##if comment the part from here to end, it's ok####
hosts:
"{{ item }}":
ansible_host: "{{ item }}"
mgmt_ip: "{{ ansible_host }}"
with_items:
- "172.7.7.1"
- "172.7.7.9"
- "172.7.7.12"
但是 Ansible 不允许我在这里使用 'with_items'。似乎 ansible 不支持主机上的迭代器。
如何在 node_exporter 组中为我的三个 IP 定义 hosts 数组?
【问题讨论】:
-
我只想在我的 .yml 文件中定义一些类似的主机。他们每个人都有一个 var 'mgmt_ip' 等于 'ansible_host'。
-
我已经在这个部分之前在同一个 .yml 文件中使用了“ansible_host”,就像这里一样(如果没有这个部分也没关系)。
-
我发现如果从node_exporter中去掉ansible_host: "{{ item }}" 就可以了....
-
虽然我还不知道具体原因,但感谢您的帮助。