我有以下清单文件
[vm_group]
xyz001.hq.company.com
xyz002.hq.company.com
[vm_group:vars]
ansible_connection=winrm
ansible_winrm_transport=ntlm
ansible_port=5986
ansible_winrm_server_cert_validation=ignore
我有一个称为CLIENT_LIST的环境变量
echo $CLIENT_LIST
xyz001.hq.company.com,xyz002.hq.company.com
我该怎么做
[vm_group]
${CLIENT_LIST}
,以便可以动态设置库存组。我尝试按照上面显示的方式进行操作,但未选择环境变量值。您对动态列表还有其他建议吗?但是,环境变量将是我的首选。
您的问题有两个答案:多重播放或动态广告资源插件;静态清单文件中没有变量替换]
对于多剧版本,将使用add_host:
:
add_host:
对于动态库存版本,世界就是您的牡蛎:- hosts: localhost
connection: local
tasks:
- add_host:
name: '{{ item }}'
groups:
- vm_group
with_items: '{{ lookup("env", "CLIENT_LIST").split(",") }}'
- hosts: vm_group
# and you're of to the races