我想检查是否有人知道我在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