在过去的几天里,我在使用 AWS 云模块运行 ansible playbook 或从本地机器使用 --refresh-cache 命令直接运行 ec2.py 文件时收到以下错误:
ap:~ ap$ /ansible/inventory/ec2.py --refresh-cache
Traceback (most recent call last):
File "/ansible/inventory/ec2.py", line 1510, in <module>
Ec2Inventory()
File "/ansible/inventory/ec2.py", line 186, in __init__
self.do_api_calls_update_cache()
File "/ansible/inventory/ec2.py", line 492, in do_api_calls_update_cache
self.get_elasticache_replication_groups_by_region(region)
File "/ansible/inventory/ec2.py", line 722, in get_elasticache_replication_groups_by_region
self.add_elasticache_replication_group(replication_group, region)
File "/ansible/inventory/ec2.py", line 1198, in add_elasticache_replication_group
dest = replication_group['NodeGroups'][0]['PrimaryEndpoint']['Address']
TypeError: 'NoneType' object has no attribute '__getitem__'
从 AWS 账户中的 Ec2 实例运行时,此问题似乎消失了。
我有最新的 EC2.py 和 EC2.ini 文件,Ansible 版本是 2.2.0.0,安装了 boto3,并且我在运行 playbook 之前设置了有效的 AWS 凭证。
关于发生了什么的任何想法?