mirror of https://github.com/ansible/ansible.git
Fix ec2_instance eventual consistency when wait: false (#51885)
* Do not return 'instances' when wait is false * Added integration tests for wait: false * Added changelog fragment * Fix test suite to work with ec2_instance * Additional permissions * Enforce boto3 version * Fix broken tests * Improve error messages * fix linter issuespull/53390/head
parent
d0db99e023
commit
5c6b16edc3
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- "ec2_instance - Does not return ``instances`` when ``wait: false`` is specified"
|
@ -0,0 +1,64 @@
|
||||
- name: set connection information for all tasks
|
||||
set_fact:
|
||||
aws_connection_info: &aws_connection_info
|
||||
aws_access_key: "{{ aws_access_key }}"
|
||||
aws_secret_key: "{{ aws_secret_key }}"
|
||||
security_token: "{{ security_token }}"
|
||||
region: "{{ aws_region }}"
|
||||
no_log: true
|
||||
|
||||
- name: New instance and don't wait for it to complete
|
||||
ec2_instance:
|
||||
name: "{{ resource_prefix }}-test-no-wait"
|
||||
image_id: "{{ ec2_ami_image[aws_region] }}"
|
||||
vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
|
||||
tags:
|
||||
TestId: "{{ resource_prefix }}"
|
||||
wait: false
|
||||
instance_type: t2.micro
|
||||
<<: *aws_connection_info
|
||||
register: in_test_vpc
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- in_test_vpc is not failed
|
||||
- in_test_vpc is changed
|
||||
- in_test_vpc.instances is not defined
|
||||
- in_test_vpc.instance_ids is defined
|
||||
- in_test_vpc.instance_ids | length > 0
|
||||
|
||||
- name: New instance and don't wait for it to complete ( check mode )
|
||||
ec2_instance:
|
||||
name: "{{ resource_prefix }}-test-no-wait-checkmode"
|
||||
image_id: "{{ ec2_ami_image[aws_region] }}"
|
||||
vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
|
||||
tags:
|
||||
TestId: "{{ resource_prefix }}"
|
||||
wait: false
|
||||
instance_type: t2.micro
|
||||
<<: *aws_connection_info
|
||||
check_mode: yes
|
||||
|
||||
- name: Facts for ec2 test instance
|
||||
ec2_instance_facts:
|
||||
filters:
|
||||
"tag:Name": "{{ resource_prefix }}-test-no-wait"
|
||||
"instance-state-name": "running"
|
||||
<<: *aws_connection_info
|
||||
register: real_instance_fact
|
||||
until: real_instance_fact.instances | length > 0
|
||||
retries: 10
|
||||
|
||||
- name: Facts for checkmode ec2 test instance
|
||||
ec2_instance_facts:
|
||||
filters:
|
||||
"tag:Name": "{{ resource_prefix }}-test-no-wait-checkmode"
|
||||
"instance-state-name": "running"
|
||||
<<: *aws_connection_info
|
||||
register: checkmode_instance_fact
|
||||
|
||||
- name: "Confirm whether the check mode is working normally."
|
||||
assert:
|
||||
that:
|
||||
- "{{ real_instance_fact.instances | length }} > 0"
|
||||
- "{{ checkmode_instance_fact.instances | length }} == 0"
|
Loading…
Reference in New Issue