Feature/aws helper function for tags (#23387)

* Add new helper function for comparing AWS tag key pair dicts. Also modify boto3_tag_list_to_ansible_dict function to be more generic when looking for key names because AWS sometimes uses 'Key', sometimes 'TagKey' and who knows what the future holds! Fixed modules to work with changes.

* Review changes

* Add some more doc to GUIDELINES for tags and fix var name for snaked values in ec2_group_facts
This commit is contained in:
Rob 2017-05-11 16:39:51 +10:00 committed by John R Barker
commit fd1debb869
6 changed files with 76 additions and 26 deletions

View file

@ -153,16 +153,12 @@ def main():
except ClientError as e:
module.fail_json(msg=e.message, exception=traceback.format_exc())
# Turn the boto3 result in to ansible_friendly_snaked_names
# Modify boto3 tags list to be ansible friendly dict and then camel_case
snaked_security_groups = []
for security_group in security_groups['SecurityGroups']:
security_group['Tags'] = boto3_tag_list_to_ansible_dict(security_group['Tags'])
snaked_security_groups.append(camel_dict_to_snake_dict(security_group))
# Turn the boto3 result in to ansible friendly tag dictionary
for security_group in snaked_security_groups:
if 'tags' in security_group:
security_group['tags'] = boto3_tag_list_to_ansible_dict(security_group['tags'])
module.exit_json(security_groups=snaked_security_groups)