ec2_launch_template: Add default_version and latest_version to output, matching the documentation (#61279)

- Add tests for default/latest version manipulation
This commit is contained in:
Mark Chappell 2019-12-18 21:53:57 +01:00 committed by ansibot
parent 791e9dabe3
commit c40832af48
4 changed files with 69 additions and 0 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- ec2_launch_template - Update output to include latest_version and default_version, matching the documentation

View file

@ -556,6 +556,10 @@ def format_module_output(module):
int(v['version_number']) == int(template['latest_version_number']) int(v['version_number']) == int(template['latest_version_number'])
) )
][0] ][0]
if "version_number" in output['default_template']:
output['default_version'] = output['default_template']['version_number']
if "version_number" in output['latest_template']:
output['latest_version'] = output['latest_template']['version_number']
return output return output

View file

@ -17,6 +17,7 @@
block: block:
- include_tasks: cpu_options.yml - include_tasks: cpu_options.yml
- include_tasks: iam_instance_role.yml - include_tasks: iam_instance_role.yml
- include_tasks: versions.yml
always: always:
- debug: - debug:

View file

@ -0,0 +1,62 @@
- block:
- name: create simple instance template
ec2_launch_template:
name: "{{ resource_prefix }}-simple"
image_id: "{{ ec2_ami_image[aws_region] }}"
tags:
TestId: "{{ resource_prefix }}"
instance_type: c4.large
register: lt
- name: instance with cpu_options created with the right options
assert:
that:
- lt is success
- lt is changed
- lt.default_version == 1
- lt.latest_version == 1
- name: update simple instance template
ec2_launch_template:
name: "{{ resource_prefix }}-simple"
default_version: 1
image_id: "{{ ec2_ami_image[aws_region] }}"
tags:
TestId: "{{ resource_prefix }}"
instance_type: m5.large
register: lt
- name: instance with cpu_options created with the right options
assert:
that:
- lt is success
- lt is changed
- lt.default_version == 1
- lt.latest_version == 2
- name: update simple instance template
ec2_launch_template:
name: "{{ resource_prefix }}-simple"
image_id: "{{ ec2_ami_image[aws_region] }}"
tags:
TestId: "{{ resource_prefix }}"
instance_type: t3.medium
register: lt
- name: instance with cpu_options created with the right options
assert:
that:
- lt is success
- lt is changed
- lt.default_version == 3
- lt.latest_version == 3
always:
- name: delete the template
ec2_launch_template:
name: "{{ resource_prefix }}-simple"
state: absent
register: del_lt
retries: 10
until: del_lt is not failed
ignore_errors: true