Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursively remove empty values #61395

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/ansible/modules/cloud/amazon/ec2_launch_template.py
Expand Up @@ -388,12 +388,24 @@ def params_to_launch_data(module, template_params):
if module.params.get('iam_instance_profile'):
template_params['iam_instance_profile'] = determine_iam_role(module, module.params['iam_instance_profile'])
params = snake_dict_to_camel_dict(
dict((k, v) for k, v in template_params.items() if v is not None),
remove_none(template_params),
capitalize_first=True,
)
return params


def remove_none(obj):
if isinstance(obj, (list, tuple, set)):
return type(obj)(remove_none(x) for x in obj if x is not None)
elif isinstance(obj, dict):
return type(obj)(
(remove_none(k), remove_none(v))
for k, v in obj.items() if k is not None and v is not None
)
else:
return obj


def delete_template(module):
ec2 = module.client('ec2', retry_decorator=AWSRetry.jittered_backoff())
template, template_versions = existing_templates(module)
Expand Down