Update facts module to present ansible_friendly tags dictionary on returned nat gateways (#33294)
This commit is contained in:
parent
817a5efff9
commit
54466fa809
1 changed files with 12 additions and 2 deletions
|
@ -89,7 +89,7 @@ except ImportError:
|
|||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.ec2 import (ec2_argument_spec, get_aws_connection_info, boto3_conn,
|
||||
camel_dict_to_snake_dict, ansible_dict_to_boto3_filter_list, HAS_BOTO3)
|
||||
camel_dict_to_snake_dict, ansible_dict_to_boto3_filter_list, boto3_tag_list_to_ansible_dict, HAS_BOTO3)
|
||||
|
||||
|
||||
def date_handler(obj):
|
||||
|
@ -98,6 +98,7 @@ def date_handler(obj):
|
|||
|
||||
def get_nat_gateways(client, module, nat_gateway_id=None):
|
||||
params = dict()
|
||||
nat_gateways = list()
|
||||
|
||||
params['Filter'] = ansible_dict_to_boto3_filter_list(module.params.get('filters'))
|
||||
params['NatGatewayIds'] = module.params.get('nat_gateway_ids')
|
||||
|
@ -107,7 +108,16 @@ def get_nat_gateways(client, module, nat_gateway_id=None):
|
|||
except Exception as e:
|
||||
module.fail_json(msg=str(e.message))
|
||||
|
||||
return [camel_dict_to_snake_dict(gateway) for gateway in result['NatGateways']]
|
||||
for gateway in result['NatGateways']:
|
||||
# Turn the boto3 result into ansible_friendly_snaked_names
|
||||
converted_gateway = camel_dict_to_snake_dict(gateway)
|
||||
if 'tags' in converted_gateway:
|
||||
# Turn the boto3 result into ansible friendly tag dictionary
|
||||
converted_gateway['tags'] = boto3_tag_list_to_ansible_dict(converted_gateway['tags'])
|
||||
|
||||
nat_gateways.append(converted_gateway)
|
||||
|
||||
return nat_gateways
|
||||
|
||||
|
||||
def main():
|
||||
|
|
Loading…
Reference in a new issue