2016-12-12 59 views
1

過去幾天,在使用AWS雲模塊運行安全劇本或使用--refresh-cache直接運行ec2.py文件時,出現以下錯誤命令從我的本地機器:運行Ansible劇本時在Ec2.py中刷新ElastiCache錯誤

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憑證。

關於發生了什麼事情的任何想法?

回答

1

嘗試補丁在https://github.com/ansible/ansible/pull/20190


@@ -1194,13 +1194,14 @@ def add_elasticache_replication_group(self, replication_group, region): 
      if not self.all_elasticache_replication_groups and replication_group['Status'] != 'available': 
       return 

+  # Skip clusters we cannot address (e.g. private VPC subnet or clustered redis) 
+  if replication_group['NodeGroups'][0]['PrimaryEndpoint'] is None or \ 
+   replication_group['NodeGroups'][0]['PrimaryEndpoint']['Address'] is None: 
+   return 
+ 
      # Select the best destination address (PrimaryEndpoint) 
      dest = replication_group['NodeGroups'][0]['PrimaryEndpoint']['Address'] 

-  if not dest: 
-   # Skip clusters we cannot address (e.g. private VPC subnet) 
-   return 
- 
      # Add to index 
      self.index[dest] = [region, replication_group['ReplicationGroupId']] 
+0

出貨請:-) – Metallikanz