Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for instance to start before attempting to attach a volume #497

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions tests/integration/targets/ec2_vol/aliases
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
slow

cloud/aws
ec2_vol_info
59 changes: 37 additions & 22 deletions tests/integration/targets/ec2_vol/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,36 @@
az: '{{ availability_zone }}'
register: testing_subnet

- name: create an ec2 instance
ec2_instance:
name: "{{ instance_name }}"
vpc_subnet_id: "{{ testing_subnet.subnet.id }}"
instance_type: t3.nano
image_id: "{{ ec2_ami_id }}"
tags:
ResourcePrefix: "{{ resource_prefix }}"
register: test_instance

- name: check task return attributes
assert:
that:
- test_instance.changed

- name: create another ec2 instance
ec2_instance:
name: "{{ instance_name }}-2"
vpc_subnet_id: "{{ testing_subnet.subnet.id }}"
instance_type: t3.nano
image_id: "{{ ec2_ami_id }}"
tags:
ResourcePrefix: "{{ resource_prefix }}"
register: test_instance_2

- name: check task return attributes
assert:
that:
- test_instance_2.changed

# # ==== ec2_vol tests ===============================================

- name: create a volume (validate module defaults)
Expand Down Expand Up @@ -134,20 +164,12 @@
- volume3.changed
- "volume3.volume.snapshot_id == vol1_snapshot.snapshot_id"

- name: create an ec2 instance
- name: Wait for instance to start
ec2_instance:
name: "{{ instance_name }}"
vpc_subnet_id: "{{ testing_subnet.subnet.id }}"
instance_type: t3.nano
state: running
image_id: "{{ ec2_ami_id }}"
tags:
ResourcePrefix: "{{ resource_prefix }}"
register: test_instance

- name: check task return attributes
assert:
that:
- test_instance.changed
wait: True

- name: attach existing volume to an instance
ec2_vol:
Expand Down Expand Up @@ -668,20 +690,12 @@
delete_on_termination: no
register: vol_attach_result

- name: create another ec2 instance
- name: Wait for instance to start
ec2_instance:
name: "{{ instance_name }}-2"
vpc_subnet_id: "{{ testing_subnet.subnet.id }}"
instance_type: t3.nano
state: running
image_id: "{{ ec2_ami_id }}"
tags:
ResourcePrefix: "{{ resource_prefix }}"
register: test_instance_2

- name: check task return attributes
assert:
that:
- test_instance_2.changed
wait: True

- name: attach existing volume to second instance
ec2_vol:
Expand Down Expand Up @@ -721,6 +735,7 @@
instance_ids:
- "{{ item }}"
state: terminated
wait: True
with_items:
- "{{ test_instance.instance_ids[0] }}"
- "{{ test_instance_2.instance_ids[0] }}"
Expand Down