【发布时间】:2017-09-13 18:52:29
【问题描述】:
我想检查是否有人知道我在 Ansible 中遇到的这个问题是否有解决方案。
我有一个如下所示的库存文件:-
[clusterA]
10.0.0.1
10.0.0.2
10.0.0.3
....
[clusterB]
10.1.0.1
10.1.0.2
10.1.0.3
....
[web-lb]
10.0.0.1
10.1.0.1
我不想在web-lb组中重复IP地址,而是想做这样的事情:-
[web-lb:children]
clusterA[0]
clusterB[0]
如果我们可以如上所述编写组,我不需要复制 IP 地址,我可以将组中的不同项目混合到另一个组中,例如
[webA-lb:children]
clusterA[1]
clusterA[5]
clusterB[3]
更新
下面的配置也不行
[webA-lb]
clusterA[1]
错误:
bbed5901ea74:~$ ansible -i hosts all --list-hosts
hosts (6):
10.1.0.1
10.1.0.2
10.1.0.3
10.0.0.1
10.0.0.2
10.0.0.3
bbed5901ea74:~$ vi hosts
bbed5901ea74:~$ ansible -i hosts all --list-hosts
ERROR! Attempted to read "hosts" as YAML: Syntax Error while loading YAML.
The error appears to have been in '/home/jenkins/hosts': line 2, column 1,
but may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
[clusterA]
10.0.0.1
^ here
Attempted to read "hosts" as ini file: host range must be begin:end or
begin:end:step
【问题讨论】: