我在同一个账号下有两个私有网络,每个私有网络都有多个具有内网IP的宿主机。
我有一台主机的标签mobile等于true,另一台主机的标签Environment等于ci,这两台主机都有相同的内网IP,但它们驻留在不同的VPC中。
当我使用Ansible运行以下标签搜索时:
- name: "install security service"
hosts: "tag_Environment_{{ env }}:&tag_Service_{{ service }}_true"使用参数env="ci"和service="mobile",我得到了其中一个主机,即使每个主机都没有这两个标签。
由于它们具有相同的IP,因此搜索似乎正在合并结果,从而返回一个只有一个标签的主机。
发布于 2017-07-24 18:24:01
是的,ec2.py inventory脚本使用vpc_destination_variable参数命名主机。
对于VPC,在ec2.ini中通常设置为private_ip_address,因此您的清单中只能有一台具有相同IP的主机。
要克服这种情况,您可以尝试使用instance_filters在将主机保存到清单之前对其进行过滤。
来自ec2.ini的示例:
# Retrieve only instances with (key=value) env=staging tag
# instance_filters = tag:env=staging
# Retrieve only instances with role=webservers OR role=dbservers tag
# instance_filters = tag:role=webservers,tag:role=dbservers
# Retrieve only t1.micro instances OR instances with tag env=staging
# instance_filters = instance-type=t1.micro,tag:env=staging
# You can use wildcards in filter values also. Below will list instances which
# tag Name value matches webservers1*
# (ex. webservers15, webservers1a, webservers123 etc)
# instance_filters = tag:Name=webservers1*https://stackoverflow.com/questions/45266894
复制相似问题