Ansible EC2 动态清单 - 包含连字符的标签
Ansible EC2 dynamic inventory - tag containing a hyphen
我正在尝试 运行 在标记为 Name = foo-bar
的主机上执行临时 ansible
命令(注意连字符)。当我 运行:
ansible tag_Name_foo_bar -i ec2.py -m ping
我得到:No hosts matched
但是,有这样的主机。如果我 运行 针对标有不包含连字符的名称的主机执行相同的命令,它工作正常,例如对于标有 Name = foobar
的主机,以下工作:
ansible tag_Name_foobar -i ec2.py -m ping
H
你的ansible版本是多少?这个对我有用。根据Example: AWS EC2 External Inventory Script
标签
Each instance can have a variety of key/value pairs associated with it
called Tags. The most common tag key is ‘Name’, though anything is
possible. Each key/value pair is its own group of instances, again
with special characters converted to underscores, in the format
tag_KEY_VALUE e.g. tag_Name_Web can be used as is
tag_Name_redis-master-001 becomes tag_Name_redis_master_001
tag_aws_cloudformation_logical-id_WebServerGroup becomes
tag_aws_cloudformation_logical_id_WebServerGroup
可能ansible的ec2缓存没有刷新。尝试:
ec2.py --refresh-cache
然后再次 运行 你的 ansible 命令。当我将我的实例标签名称更改为 foo_bar
时,ot 工作正常。
我正在尝试 运行 在标记为 Name = foo-bar
的主机上执行临时 ansible
命令(注意连字符)。当我 运行:
ansible tag_Name_foo_bar -i ec2.py -m ping
我得到:No hosts matched
但是,有这样的主机。如果我 运行 针对标有不包含连字符的名称的主机执行相同的命令,它工作正常,例如对于标有 Name = foobar
的主机,以下工作:
ansible tag_Name_foobar -i ec2.py -m ping
H
你的ansible版本是多少?这个对我有用。根据Example: AWS EC2 External Inventory Script
标签
Each instance can have a variety of key/value pairs associated with it called Tags. The most common tag key is ‘Name’, though anything is possible. Each key/value pair is its own group of instances, again with special characters converted to underscores, in the format tag_KEY_VALUE e.g. tag_Name_Web can be used as is tag_Name_redis-master-001 becomes tag_Name_redis_master_001 tag_aws_cloudformation_logical-id_WebServerGroup becomes tag_aws_cloudformation_logical_id_WebServerGroup
可能ansible的ec2缓存没有刷新。尝试:
ec2.py --refresh-cache
然后再次 运行 你的 ansible 命令。当我将我的实例标签名称更改为 foo_bar
时,ot 工作正常。