forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ec2_instance eventual consistency when wait: false (ansible#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 issues
- Loading branch information
1 parent
d0db99e
commit 5c6b16e
Showing
10 changed files
with
145 additions
and
21 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
changelogs/fragments/51885-ec2_instance-fix-eventual-consistency.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bugfixes: | ||
- "ec2_instance - Does not return ``instances`` when ``wait: false`` is specified" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
.../integration/targets/ec2_instance/playbooks/roles/ec2_instance/tasks/instance_no_wait.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters