diff --git a/lib/ansible/modules/cloud/amazon/cloudformation_info.py b/lib/ansible/modules/cloud/amazon/cloudformation_info.py index ec06faa6803..f62b80235dd 100644 --- a/lib/ansible/modules/cloud/amazon/cloudformation_info.py +++ b/lib/ansible/modules/cloud/amazon/cloudformation_info.py @@ -297,7 +297,7 @@ def main(): stack_template=dict(required=False, default=False, type='bool'), stack_change_sets=dict(required=False, default=False, type='bool'), ) - module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=False) + module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=True) is_old_facts = module._name == 'cloudformation_facts' if is_old_facts: diff --git a/test/integration/targets/cloudformation/tasks/main.yml b/test/integration/targets/cloudformation/tasks/main.yml index 8d437511ef8..9e95f26ecb5 100644 --- a/test/integration/targets/cloudformation/tasks/main.yml +++ b/test/integration/targets/cloudformation/tasks/main.yml @@ -153,6 +153,24 @@ - "'stack_tags' in stack_info.cloudformation[stack_name]" - "stack_info.cloudformation[stack_name].stack_tags.Stack == stack_name" + - name: get stack details (checkmode) + cloudformation_info: + stack_name: "{{ stack_name }}" + register: stack_info + check_mode: yes + + - name: assert stack info + assert: + that: + - "'cloudformation' in stack_info" + - "stack_info.cloudformation | length == 1" + - "stack_name in stack_info.cloudformation" + - "'stack_description' in stack_info.cloudformation[stack_name]" + - "'stack_outputs' in stack_info.cloudformation[stack_name]" + - "'stack_parameters' in stack_info.cloudformation[stack_name]" + - "'stack_tags' in stack_info.cloudformation[stack_name]" + - "stack_info.cloudformation[stack_name].stack_tags.Stack == stack_name" + - name: get stack details (all_facts) cloudformation_info: stack_name: "{{ stack_name }}" @@ -168,6 +186,22 @@ - "'stack_resources' in stack_info.cloudformation[stack_name]" - "'stack_template' in stack_info.cloudformation[stack_name]" + - name: get stack details (all_facts) (checkmode) + cloudformation_info: + stack_name: "{{ stack_name }}" + all_facts: yes + register: stack_info + check_mode: yes + + - name: assert stack info + assert: + that: + - "'stack_events' in stack_info.cloudformation[stack_name]" + - "'stack_policy' in stack_info.cloudformation[stack_name]" + - "'stack_resource_list' in stack_info.cloudformation[stack_name]" + - "'stack_resources' in stack_info.cloudformation[stack_name]" + - "'stack_template' in stack_info.cloudformation[stack_name]" + # ==== Cloudformation tests (create changeset) ============================ # try to create a changeset by changing instance type @@ -204,6 +238,18 @@ that: - "'stack_change_sets' in stack_info.cloudformation[stack_name]" + - name: get stack details with changesets (checkmode) + cloudformation_info: + stack_name: "{{ stack_name }}" + stack_change_sets: True + register: stack_info + check_mode: yes + + - name: assert changesets in info + assert: + that: + - "'stack_change_sets' in stack_info.cloudformation[stack_name]" + # try to create an empty changeset by passing in unchanged template - name: create a changeset cloudformation: @@ -257,6 +303,17 @@ that: - "stack_info.cloudformation[stack_name].stack_description.enable_termination_protection" + - name: get stack details (checkmode) + cloudformation_info: + stack_name: "{{ stack_name }}" + register: stack_info + check_mode: yes + + - name: assert stack info + assert: + that: + - "stack_info.cloudformation[stack_name].stack_description.enable_termination_protection" + - name: set termination protection to false cloudformation: stack_name: "{{ stack_name }}" @@ -287,6 +344,17 @@ that: - "not stack_info.cloudformation[stack_name].stack_description.enable_termination_protection" + - name: get stack details (checkmode) + cloudformation_info: + stack_name: "{{ stack_name }}" + register: stack_info + check_mode: yes + + - name: assert stack info + assert: + that: + - "not stack_info.cloudformation[stack_name].stack_description.enable_termination_protection" + # ==== Cloudformation tests (delete stack tests) ========================== - name: delete cloudformation stack (check mode) @@ -351,6 +419,17 @@ that: - "not stack_info.cloudformation" + - name: get stack details (checkmode) + cloudformation_info: + stack_name: "{{ stack_name }}" + register: stack_info + check_mode: yes + + - name: assert stack info + assert: + that: + - "not stack_info.cloudformation" + # ==== Cleanup ============================================================ always: