[ec2_ami] Ensure name or image_id is provided for state=present (#38972)

Add integration tests for backward compatibility and ensuring name or image_id is provided
This commit is contained in:
Sloane Hertel
2018-04-18 19:28:25 -04:00
committed by Will Thames
parent cdb79b0e3a
commit e2aa1155ba
2 changed files with 30 additions and 2 deletions

View File

@@ -87,6 +87,30 @@
# ============================================================
- name: test clean failure if not providing image_id or name with state=present
ec2_ami:
ec2_region: '{{ec2_region}}'
ec2_access_key: '{{ec2_access_key}}'
ec2_secret_key: '{{ec2_secret_key}}'
security_token: '{{security_token}}'
instance_id: '{{ setup_instance.instance_ids[0] }}'
state: present
description: '{{ ec2_ami_description }}'
tags:
Name: '{{ ec2_ami_name }}_ami'
wait: yes
root_device_name: /dev/xvda
register: result
ignore_errors: yes
- name: assert error message is helpful
assert:
that:
- result.failed
- "result.msg == 'one of the following is required: name, image_id'"
# ============================================================
- name: create an image from the instance
ec2_ami:
ec2_region: '{{ec2_region}}'
@@ -295,7 +319,6 @@
security_token: '{{security_token}}'
state: present
image_id: '{{ result.image_id }}'
name: '{{ ec2_ami_name }}_ami'
description: '{{ ec2_ami_description }}'
tags:
Name: '{{ ec2_ami_name }}_ami'