ansible/test/integration/targets/ec2_instance/tasks/block_devices.yml
Mark Chappell 145b79ef0e ec2_instance test cleanup (#63708)
* ec2_instance/ec2_instance_info : Fixup sanity test errors

* Move ec2_instance integration tests to use aws_defaults

* Search for the AMI instead of hardcoding an AMI

* Make our VPC CIDR variable

* Remove AZ assumptions - no guarantees about specific AZs being available

* Make sure we terminate instances when we're done with them.

* Add a 10 second pause for IAM roles to become available before using them

* Wait on instance changes by default

* Switch out t2 instances for t3 they're cheaper and have more CPU available

* Pull t3.nano instance info a little earlier

* rework vpc_name and vpc_cidr a little

* Mark ec2_instance tests unsupported for now, they take too long
2019-10-21 14:55:44 +02:00

80 lines
2.4 KiB
YAML

- block:
- name: New instance with an extra block device
ec2_instance:
name: "{{ resource_prefix }}-test-ebs-vols"
image_id: "{{ ec2_ami_image }}"
vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
volumes:
- device_name: /dev/sdb
ebs:
volume_size: 20
delete_on_termination: true
volume_type: standard
tags:
TestId: "{{ resource_prefix }}"
instance_type: "{{ ec2_instance_type }}"
wait: true
register: in_test_vpc
- name: Gather instance info
ec2_instance_info:
filters:
"tag:Name": "{{ resource_prefix }}-test-ebs-vols"
register: in_test_vpc_instance
- assert:
that:
- in_test_vpc is not failed
- in_test_vpc is changed
- in_test_vpc_instance.instances[0].block_device_mappings[0]
- in_test_vpc_instance.instances[0].block_device_mappings[1]
- in_test_vpc_instance.instances[0].block_device_mappings[1].device_name == '/dev/sdb'
- name: New instance with an extra block device(check mode)
ec2_instance:
name: "{{ resource_prefix }}-test-ebs-vols-checkmode"
image_id: "{{ ec2_ami_image }}"
vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
volumes:
- device_name: /dev/sdb
ebs:
volume_size: 20
delete_on_termination: true
volume_type: standard
tags:
TestId: "{{ resource_prefix }}"
instance_type: "{{ ec2_instance_type }}"
check_mode: yes
- name: "fact presented ec2 instance"
ec2_instance_info:
filters:
"tag:Name": "{{ resource_prefix }}-test-ebs-vols"
"instance-state-name": "running"
register: presented_instance_fact
- name: "fact checkmode ec2 instance"
ec2_instance_info:
filters:
"tag:Name": "{{ resource_prefix }}-test-ebs-vols-checkmode"
register: checkmode_instance_fact
- name: "Confirm whether the check mode is working normally."
assert:
that:
- "{{ presented_instance_fact.instances | length }} > 0"
- "{{ checkmode_instance_fact.instances | length }} == 0"
- name: Terminate instances
ec2_instance:
instance_ids: "{{ in_test_vpc.instance_ids }}"
state: absent
always:
- name: Terminate test-ebs-vols instances
ec2_instance:
filters:
"tag:Name": "{{ resource_prefix }}-test-ebs-vols"
state: absent
wait: false
ignore_errors: yes