summaryrefslogtreecommitdiff
path: root/test/integration/targets/ec2_instance
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/ec2_instance')
-rw-r--r--test/integration/targets/ec2_instance/aliases3
-rw-r--r--test/integration/targets/ec2_instance/inventory17
-rw-r--r--test/integration/targets/ec2_instance/main.yml43
-rw-r--r--test/integration/targets/ec2_instance/meta/main.yml4
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/defaults/main.yml14
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/files/assume-role-policy.json13
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/meta/main.yml3
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/tasks/block_devices.yml82
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/tasks/checkmode_tests.yml172
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/tasks/cpu_options.yml86
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/tasks/default_vpc_tests.yml57
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/tasks/ebs_optimized.yml41
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/tasks/env_cleanup.yml93
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/tasks/env_setup.yml79
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/tasks/external_resource_attach.yml129
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/tasks/find_ami.yml15
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/tasks/iam_instance_role.yml127
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/tasks/instance_no_wait.yml68
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/tasks/main.yml48
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/tasks/tags_and_vpc_settings.yml158
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/tasks/termination_protection.yml184
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/tasks/version_fail.yml29
-rw-r--r--test/integration/targets/ec2_instance/roles/ec2_instance/tasks/version_fail_wrapper.yml30
-rwxr-xr-xtest/integration/targets/ec2_instance/runme.sh12
24 files changed, 0 insertions, 1507 deletions
diff --git a/test/integration/targets/ec2_instance/aliases b/test/integration/targets/ec2_instance/aliases
deleted file mode 100644
index 62cb1d2c5b..0000000000
--- a/test/integration/targets/ec2_instance/aliases
+++ /dev/null
@@ -1,3 +0,0 @@
-cloud/aws
-shippable/aws/group3
-ec2_instance_info
diff --git a/test/integration/targets/ec2_instance/inventory b/test/integration/targets/ec2_instance/inventory
deleted file mode 100644
index 44b46ec88f..0000000000
--- a/test/integration/targets/ec2_instance/inventory
+++ /dev/null
@@ -1,17 +0,0 @@
-[tests]
-# Sorted fastest to slowest
-version_fail_wrapper
-ebs_optimized
-block_devices
-cpu_options
-default_vpc_tests
-external_resource_attach
-instance_no_wait
-iam_instance_role
-termination_protection
-tags_and_vpc_settings
-checkmode_tests
-
-[all:vars]
-ansible_connection=local
-ansible_python_interpreter="{{ ansible_playbook_python }}"
diff --git a/test/integration/targets/ec2_instance/main.yml b/test/integration/targets/ec2_instance/main.yml
deleted file mode 100644
index 7695f7bcb9..0000000000
--- a/test/integration/targets/ec2_instance/main.yml
+++ /dev/null
@@ -1,43 +0,0 @@
----
-# Beware: most of our tests here are run in parallel.
-# To add new tests you'll need to add a new host to the inventory and a matching
-# '{{ inventory_hostname }}'.yml file in roles/ec2_instance/tasks/
-
-
-# Prepare the VPC and figure out which AMI to use
-- hosts: all
- gather_facts: no
- tasks:
- - module_defaults:
- group/aws:
- aws_access_key: "{{ aws_access_key }}"
- aws_secret_key: "{{ aws_secret_key }}"
- security_token: "{{ security_token | default(omit) }}"
- region: "{{ aws_region }}"
- vars:
- # We can't just use "run_once" because the facts don't propagate when
- # running an 'include' that was run_once
- setup_run_once: yes
- block:
- - include_role:
- name: 'ec2_instance'
- tasks_from: find_ami.yml
- - include_role:
- name: 'ec2_instance'
- tasks_from: env_setup.yml
- rescue:
- - include_role:
- name: 'ec2_instance'
- tasks_from: env_cleanup.yml
- run_once: yes
- - fail:
- msg: 'Environment preparation failed'
- run_once: yes
-
-# VPC should get cleaned up once all hosts have run
-- hosts: all
- gather_facts: no
- strategy: free
- #serial: 10
- roles:
- - ec2_instance
diff --git a/test/integration/targets/ec2_instance/meta/main.yml b/test/integration/targets/ec2_instance/meta/main.yml
deleted file mode 100644
index 38b31be072..0000000000
--- a/test/integration/targets/ec2_instance/meta/main.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-dependencies:
- - prepare_tests
- - setup_ec2
- - setup_remote_tmp_dir
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/defaults/main.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/defaults/main.yml
deleted file mode 100644
index 8e70ab6933..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/defaults/main.yml
+++ /dev/null
@@ -1,14 +0,0 @@
----
-# defaults file for ec2_instance
-ec2_instance_owner: 'integration-run-{{ resource_prefix }}'
-ec2_instance_type: 't3.micro'
-ec2_instance_tag_TestId: '{{ resource_prefix }}-{{ inventory_hostname }}'
-ec2_ami_name: 'amzn2-ami-hvm-2.*-x86_64-gp2'
-
-vpc_name: '{{ resource_prefix }}-vpc'
-vpc_seed: '{{ resource_prefix }}'
-vpc_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.0.0/16'
-subnet_a_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.32.0/24'
-subnet_a_startswith: '10.{{ 256 | random(seed=vpc_seed) }}.32.'
-subnet_b_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.33.0/24'
-subnet_b_startswith: '10.{{ 256 | random(seed=vpc_seed) }}.33.'
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/files/assume-role-policy.json b/test/integration/targets/ec2_instance/roles/ec2_instance/files/assume-role-policy.json
deleted file mode 100644
index 72413abdd3..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/files/assume-role-policy.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Version": "2008-10-17",
- "Statement": [
- {
- "Sid": "",
- "Effect": "Allow",
- "Principal": {
- "Service": "ec2.amazonaws.com"
- },
- "Action": "sts:AssumeRole"
- }
- ]
-}
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/meta/main.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/meta/main.yml
deleted file mode 100644
index 1f64f1169a..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-dependencies:
- - prepare_tests
- - setup_ec2
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/block_devices.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/block_devices.yml
deleted file mode 100644
index 0a8ab63f08..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/block_devices.yml
+++ /dev/null
@@ -1,82 +0,0 @@
-- block:
- - name: "New instance with an extra block device"
- ec2_instance:
- state: present
- 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: "{{ ec2_instance_tag_TestId }}"
- instance_type: "{{ ec2_instance_type }}"
- wait: true
- register: block_device_instances
-
- - name: "Gather instance info"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-test-ebs-vols"
- register: block_device_instances_info
-
- - assert:
- that:
- - block_device_instances is not failed
- - block_device_instances is changed
- - block_device_instances_info.instances[0].block_device_mappings[0]
- - block_device_instances_info.instances[0].block_device_mappings[1]
- - block_device_instances_info.instances[0].block_device_mappings[1].device_name == '/dev/sdb'
-
- - name: "New instance with an extra block device (check mode)"
- ec2_instance:
- state: present
- 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: "{{ ec2_instance_tag_TestId }}"
- 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:
- state: absent
- instance_ids: "{{ block_device_instances.instance_ids }}"
-
- always:
- - name: "Terminate block_devices instances"
- ec2_instance:
- state: absent
- filters:
- "tag:TestId": "{{ ec2_instance_tag_TestId }}"
- wait: yes
- ignore_errors: yes
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/checkmode_tests.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/checkmode_tests.yml
deleted file mode 100644
index b161eca636..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/checkmode_tests.yml
+++ /dev/null
@@ -1,172 +0,0 @@
-- block:
- - name: "Make basic instance"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-checkmode-comparison"
- image_id: "{{ ec2_ami_image }}"
- security_groups: "{{ sg.group_id }}"
- instance_type: "{{ ec2_instance_type }}"
- vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
- wait: false
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- register: basic_instance
-
- - name: "Make basic instance (check mode)"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-checkmode-comparison-checkmode"
- image_id: "{{ ec2_ami_image }}"
- security_groups: "{{ sg.group_id }}"
- instance_type: "{{ ec2_instance_type }}"
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- check_mode: yes
-
- - name: "fact presented ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-checkmode-comparison"
- register: presented_instance_fact
-
- - name: "fact checkmode ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-checkmode-comparison-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: "Stop instance (check mode)"
- ec2_instance:
- state: stopped
- name: "{{ resource_prefix }}-checkmode-comparison"
- vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- check_mode: yes
-
- - name: "fact ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-checkmode-comparison"
- register: confirm_checkmode_stopinstance_fact
-
- - name: "Verify that it was not stopped."
- assert:
- that:
- - '"{{ confirm_checkmode_stopinstance_fact.instances[0].state.name }}" != "stopped"'
-
- - name: "Stop instance."
- ec2_instance:
- state: stopped
- name: "{{ resource_prefix }}-checkmode-comparison"
- vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- register: instance_stop
- until: not instance_stop.failed
- retries: 10
-
- - name: "fact stopped ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-checkmode-comparison"
- register: confirm_stopinstance_fact
-
- - name: "Verify that it was stopped."
- assert:
- that:
- - '"{{ confirm_stopinstance_fact.instances[0].state.name }}" in ["stopped", "stopping"]'
-
- - name: "Running instance in check mode."
- ec2_instance:
- state: running
- name: "{{ resource_prefix }}-checkmode-comparison"
- vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- check_mode: yes
-
- - name: "fact ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-checkmode-comparison"
- register: confirm_checkmode_runninginstance_fact
-
- - name: "Verify that it was not running."
- assert:
- that:
- - '"{{ confirm_checkmode_runninginstance_fact.instances[0].state.name }}" != "running"'
-
- - name: "Running instance."
- ec2_instance:
- state: running
- name: "{{ resource_prefix }}-checkmode-comparison"
- vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
-
- - name: "fact ec2 instance."
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-checkmode-comparison"
- register: confirm_runninginstance_fact
-
- - name: "Verify that it was running."
- assert:
- that:
- - '"{{ confirm_runninginstance_fact.instances[0].state.name }}" == "running"'
-
- - name: "Terminate instance in check mode."
- ec2_instance:
- state: absent
- name: "{{ resource_prefix }}-checkmode-comparison"
- vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- check_mode: yes
-
- - name: "fact ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-checkmode-comparison"
- register: confirm_checkmode_terminatedinstance_fact
-
- - name: "Verify that it was not terminated,"
- assert:
- that:
- - '"{{ confirm_checkmode_terminatedinstance_fact.instances[0].state.name }}" != "terminated"'
-
- - name: "Terminate instance."
- ec2_instance:
- state: absent
- name: "{{ resource_prefix }}-checkmode-comparison"
- vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
-
- - name: "fact ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-checkmode-comparison"
- register: confirm_terminatedinstance_fact
-
- - name: "Verify that it was terminated,"
- assert:
- that:
- - '"{{ confirm_terminatedinstance_fact.instances[0].state.name }}" == "terminated"'
-
- always:
- - name: "Terminate checkmode instances"
- ec2_instance:
- state: absent
- filters:
- "tag:TestId": "{{ ec2_instance_tag_TestId }}"
- wait: yes
- ignore_errors: yes
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/cpu_options.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/cpu_options.yml
deleted file mode 100644
index 947011f75e..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/cpu_options.yml
+++ /dev/null
@@ -1,86 +0,0 @@
-- block:
- - name: "create t3.nano instance with cpu_options"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-t3nano-1-threads-per-core"
- image_id: "{{ ec2_ami_image }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
- instance_type: t3.nano
- cpu_options:
- core_count: 1
- threads_per_core: 1
- wait: false
- register: instance_creation
-
- - name: "instance with cpu_options created with the right options"
- assert:
- that:
- - instance_creation is success
- - instance_creation is changed
-
- - name: "modify cpu_options on existing instance (warning displayed)"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-t3nano-1-threads-per-core"
- image_id: "{{ ec2_ami_image }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
- instance_type: t3.nano
- cpu_options:
- core_count: 1
- threads_per_core: 2
- wait: false
- register: cpu_options_update
- ignore_errors: yes
-
- - name: "fact presented ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-test-t3nano-1-threads-per-core"
- register: presented_instance_fact
-
- - name: "modify cpu_options has no effect on existing instance"
- assert:
- that:
- - cpu_options_update is success
- - cpu_options_update is not changed
- - "{{ presented_instance_fact.instances | length }} > 0"
- - "'{{ presented_instance_fact.instances.0.state.name }}' in ['running','pending']"
- - "{{ presented_instance_fact.instances.0.cpu_options.core_count }} == 1"
- - "{{ presented_instance_fact.instances.0.cpu_options.threads_per_core }} == 1"
-
- - name: "create t3.nano instance with cpu_options(check mode)"
- ec2_instance:
- name: "{{ resource_prefix }}-test-t3nano-1-threads-per-core-checkmode"
- image_id: "{{ ec2_ami_image }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
- instance_type: t3.nano
- cpu_options:
- core_count: 1
- threads_per_core: 1
- check_mode: yes
-
- - name: "fact checkmode ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-test-t3nano-1-threads-per-core-checkmode"
- register: checkmode_instance_fact
-
- - name: "Confirm existence of instance id."
- assert:
- that:
- - "{{ checkmode_instance_fact.instances | length }} == 0"
-
- always:
- - name: "Terminate cpu_options instances"
- ec2_instance:
- state: absent
- filters:
- "tag:TestId": "{{ ec2_instance_tag_TestId }}"
- wait: yes
- ignore_errors: yes
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/default_vpc_tests.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/default_vpc_tests.yml
deleted file mode 100644
index a69dfe9f86..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/default_vpc_tests.yml
+++ /dev/null
@@ -1,57 +0,0 @@
-- block:
- - name: "Make instance in a default subnet of the VPC"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-default-vpc"
- image_id: "{{ ec2_ami_image }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- security_group: "default"
- instance_type: "{{ ec2_instance_type }}"
- wait: false
- register: in_default_vpc
-
- - name: "Make instance in a default subnet of the VPC(check mode)"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-default-vpc-checkmode"
- image_id: "{{ ec2_ami_image }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- security_group: "default"
- instance_type: "{{ ec2_instance_type }}"
- check_mode: yes
-
- - name: "fact presented ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-test-default-vpc"
- register: presented_instance_fact
-
- - name: "fact checkmode ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-test-default-vpc-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:
- state: absent
- instance_ids: "{{ in_default_vpc.instance_ids }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
-
- always:
- - name: "Terminate vpc_tests instances"
- ec2_instance:
- state: absent
- filters:
- "tag:TestId": "{{ ec2_instance_tag_TestId }}"
- wait: yes
- ignore_errors: yes
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/ebs_optimized.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/ebs_optimized.yml
deleted file mode 100644
index 5bfdc086e7..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/ebs_optimized.yml
+++ /dev/null
@@ -1,41 +0,0 @@
-- block:
- - name: "Make EBS optimized instance in the testing subnet of the test VPC"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-ebs-optimized-instance-in-vpc"
- image_id: "{{ ec2_ami_image }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- security_groups: "{{ sg.group_id }}"
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- ebs_optimized: true
- instance_type: t3.nano
- wait: false
- register: ebs_opt_in_vpc
-
- - name: "Get ec2 instance info"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-test-ebs-optimized-instance-in-vpc"
- register: ebs_opt_instance_info
-
- - name: "Assert instance is ebs_optimized"
- assert:
- that:
- - "{{ ebs_opt_instance_info.instances.0.ebs_optimized }}"
-
- - name: "Terminate instances"
- ec2_instance:
- state: absent
- instance_ids: "{{ ebs_opt_in_vpc.instance_ids }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
-
- always:
- - name: "Terminate ebs_optimzed instances"
- ec2_instance:
- state: absent
- filters:
- "tag:TestId": "{{ ec2_instance_tag_TestId }}"
- wait: yes
- ignore_errors: yes
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/env_cleanup.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/env_cleanup.yml
deleted file mode 100644
index 1b6c79e0d9..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/env_cleanup.yml
+++ /dev/null
@@ -1,93 +0,0 @@
-- name: "remove Instances"
- ec2_instance:
- state: absent
- filters:
- vpc-id: "{{ testing_vpc.vpc.id }}"
- wait: yes
- ignore_errors: yes
- retries: 10
-
-- name: "remove ENIs"
- ec2_eni_info:
- filters:
- vpc-id: "{{ testing_vpc.vpc.id }}"
- register: enis
-
-- name: "delete all ENIs"
- ec2_eni:
- state: absent
- eni_id: "{{ item.id }}"
- until: removed is not failed
- with_items: "{{ enis.network_interfaces }}"
- ignore_errors: yes
- retries: 10
-
-- name: "remove the security group"
- ec2_group:
- state: absent
- name: "{{ resource_prefix }}-sg"
- description: a security group for ansible tests
- vpc_id: "{{ testing_vpc.vpc.id }}"
- register: removed
- until: removed is not failed
- ignore_errors: yes
- retries: 10
-
-- name: "remove routing rules"
- ec2_vpc_route_table:
- state: absent
- vpc_id: "{{ testing_vpc.vpc.id }}"
- tags:
- created: "{{ resource_prefix }}-route"
- routes:
- - dest: 0.0.0.0/0
- gateway_id: "{{ igw.gateway_id }}"
- subnets:
- - "{{ testing_subnet_a.subnet.id }}"
- - "{{ testing_subnet_b.subnet.id }}"
- register: removed
- until: removed is not failed
- ignore_errors: yes
- retries: 10
-
-- name: "remove internet gateway"
- ec2_vpc_igw:
- state: absent
- vpc_id: "{{ testing_vpc.vpc.id }}"
- register: removed
- until: removed is not failed
- ignore_errors: yes
- retries: 10
-
-- name: "remove subnet A"
- ec2_vpc_subnet:
- state: absent
- vpc_id: "{{ testing_vpc.vpc.id }}"
- cidr: "{{ subnet_a_cidr }}"
- register: removed
- until: removed is not failed
- ignore_errors: yes
- retries: 10
-
-- name: "remove subnet B"
- ec2_vpc_subnet:
- state: absent
- vpc_id: "{{ testing_vpc.vpc.id }}"
- cidr: "{{ subnet_b_cidr }}"
- register: removed
- until: removed is not failed
- ignore_errors: yes
- retries: 10
-
-- name: "remove the VPC"
- ec2_vpc_net:
- state: absent
- name: "{{ vpc_name }}"
- cidr_block: "{{ vpc_cidr }}"
- tags:
- Name: Ansible Testing VPC
- tenancy: default
- register: removed
- until: removed is not failed
- ignore_errors: yes
- retries: 10
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/env_setup.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/env_setup.yml
deleted file mode 100644
index 6c76b7bf79..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/env_setup.yml
+++ /dev/null
@@ -1,79 +0,0 @@
-- run_once: '{{ setup_run_once | default("no") | bool }}'
- block:
- - name: "fetch AZ availability"
- aws_az_info:
- register: az_info
- - name: "Assert that we have multiple AZs available to us"
- assert:
- that: az_info.availability_zones | length >= 2
-
- - name: "pick AZs"
- set_fact:
- subnet_a_az: '{{ az_info.availability_zones[0].zone_name }}'
- subnet_b_az: '{{ az_info.availability_zones[1].zone_name }}'
-
- - name: "Create VPC for use in testing"
- ec2_vpc_net:
- state: present
- name: "{{ vpc_name }}"
- cidr_block: "{{ vpc_cidr }}"
- tags:
- Name: Ansible ec2_instance Testing VPC
- tenancy: default
- register: testing_vpc
-
- - name: "Create internet gateway for use in testing"
- ec2_vpc_igw:
- state: present
- vpc_id: "{{ testing_vpc.vpc.id }}"
- register: igw
-
- - name: "Create default subnet in zone A"
- ec2_vpc_subnet:
- state: present
- vpc_id: "{{ testing_vpc.vpc.id }}"
- cidr: "{{ subnet_a_cidr }}"
- az: "{{ subnet_a_az }}"
- resource_tags:
- Name: "{{ resource_prefix }}-subnet-a"
- register: testing_subnet_a
-
- - name: "Create secondary subnet in zone B"
- ec2_vpc_subnet:
- state: present
- vpc_id: "{{ testing_vpc.vpc.id }}"
- cidr: "{{ subnet_b_cidr }}"
- az: "{{ subnet_b_az }}"
- resource_tags:
- Name: "{{ resource_prefix }}-subnet-b"
- register: testing_subnet_b
-
- - name: "create routing rules"
- ec2_vpc_route_table:
- state: present
- vpc_id: "{{ testing_vpc.vpc.id }}"
- tags:
- created: "{{ resource_prefix }}-route"
- routes:
- - dest: 0.0.0.0/0
- gateway_id: "{{ igw.gateway_id }}"
- subnets:
- - "{{ testing_subnet_a.subnet.id }}"
- - "{{ testing_subnet_b.subnet.id }}"
-
- - name: "create a security group with the vpc"
- ec2_group:
- state: present
- name: "{{ resource_prefix }}-sg"
- description: a security group for ansible tests
- vpc_id: "{{ testing_vpc.vpc.id }}"
- rules:
- - proto: tcp
- from_port: 22
- to_port: 22
- cidr_ip: 0.0.0.0/0
- - proto: tcp
- from_port: 80
- to_port: 80
- cidr_ip: 0.0.0.0/0
- register: sg
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/external_resource_attach.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/external_resource_attach.yml
deleted file mode 100644
index 2625977f41..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/external_resource_attach.yml
+++ /dev/null
@@ -1,129 +0,0 @@
-- block:
- # Make custom ENIs and attach via the `network` parameter
- - ec2_eni:
- state: present
- delete_on_termination: true
- subnet_id: "{{ testing_subnet_b.subnet.id }}"
- security_groups:
- - "{{ sg.group_id }}"
- register: eni_a
-
- - ec2_eni:
- state: present
- delete_on_termination: true
- subnet_id: "{{ testing_subnet_b.subnet.id }}"
- security_groups:
- - "{{ sg.group_id }}"
- register: eni_b
-
- - ec2_eni:
- state: present
- delete_on_termination: true
- subnet_id: "{{ testing_subnet_b.subnet.id }}"
- security_groups:
- - "{{ sg.group_id }}"
- register: eni_c
-
- - ec2_key:
- name: "{{ resource_prefix }}_test_key"
-
- - name: "Make instance in the testing subnet created in the test VPC"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-eni-vpc"
- key_name: "{{ resource_prefix }}_test_key"
- network:
- interfaces:
- - id: "{{ eni_a.interface.id }}"
- image_id: "{{ ec2_ami_image }}"
- availability_zone: '{{ subnet_b_az }}'
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- instance_type: "{{ ec2_instance_type }}"
- wait: false
- register: in_test_vpc
-
- - name: "Gather {{ resource_prefix }}-test-eni-vpc info"
- ec2_instance_info:
- filters:
- "tag:Name": '{{ resource_prefix }}-test-eni-vpc'
- register: in_test_vpc_instance
-
- - assert:
- that:
- - 'in_test_vpc_instance.instances.0.key_name == "{{ resource_prefix }}_test_key"'
- - '(in_test_vpc_instance.instances.0.network_interfaces | length) == 1'
-
- - name: "Add a second interface"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-eni-vpc"
- network:
- interfaces:
- - id: "{{ eni_a.interface.id }}"
- - id: "{{ eni_b.interface.id }}"
- image_id: "{{ ec2_ami_image }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- instance_type: "{{ ec2_instance_type }}"
- wait: false
- register: add_interface
- until: add_interface is not failed
- ignore_errors: yes
- retries: 10
-
- - name: "Make instance in the testing subnet created in the test VPC(check mode)"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-eni-vpc-checkmode"
- key_name: "{{ resource_prefix }}_test_key"
- network:
- interfaces:
- - id: "{{ eni_c.interface.id }}"
- image_id: "{{ ec2_ami_image }}"
- availability_zone: '{{ subnet_b_az }}'
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- instance_type: "{{ ec2_instance_type }}"
- check_mode: yes
-
- - name: "fact presented ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-test-eni-vpc"
- register: presented_instance_fact
-
- - name: "fact checkmode ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-test-eni-vpc-checkmode"
- register: checkmode_instance_fact
-
- - name: "Confirm existence of instance id."
- assert:
- that:
- - "{{ presented_instance_fact.instances | length }} > 0"
- - "{{ checkmode_instance_fact.instances | length }} == 0"
-
- always:
- - name: "Terminate external_resource_attach instances"
- ec2_instance:
- state: absent
- filters:
- "tag:TestId": "{{ ec2_instance_tag_TestId }}"
- wait: yes
- ignore_errors: yes
-
- - ec2_key:
- state: absent
- name: "{{ resource_prefix }}_test_key"
- ignore_errors: yes
-
- - ec2_eni:
- state: absent
- eni_id: '{{ item.interface.id }}'
- ignore_errors: yes
- with_items:
- - '{{ eni_a }}'
- - '{{ eni_b }}'
- - '{{ eni_c }}'
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/find_ami.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/find_ami.yml
deleted file mode 100644
index 5c0e61f84c..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/find_ami.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-- run_once: '{{ setup_run_once | default("no") | bool }}'
- block:
- - name: "Find AMI to use"
- run_once: yes
- ec2_ami_info:
- owners: 'amazon'
- filters:
- name: '{{ ec2_ami_name }}'
- register: ec2_amis
- - name: "Set fact with latest AMI"
- run_once: yes
- vars:
- latest_ami: '{{ ec2_amis.images | sort(attribute="creation_date") | last }}'
- set_fact:
- ec2_ami_image: '{{ latest_ami.image_id }}'
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/iam_instance_role.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/iam_instance_role.yml
deleted file mode 100644
index 6e29b74674..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/iam_instance_role.yml
+++ /dev/null
@@ -1,127 +0,0 @@
-- block:
- - name: "Create IAM role for test"
- iam_role:
- state: present
- name: "ansible-test-sts-{{ resource_prefix }}-test-policy"
- assume_role_policy_document: "{{ lookup('file','assume-role-policy.json') }}"
- create_instance_profile: yes
- managed_policy:
- - AmazonEC2ContainerServiceRole
- register: iam_role
-
- - name: "Create second IAM role for test"
- iam_role:
- state: present
- name: "ansible-test-sts-{{ resource_prefix }}-test-policy-2"
- assume_role_policy_document: "{{ lookup('file','assume-role-policy.json') }}"
- create_instance_profile: yes
- managed_policy:
- - AmazonEC2ContainerServiceRole
- register: iam_role_2
-
- - name: "wait 10 seconds for roles to become available"
- wait_for:
- timeout: 10
- delegate_to: localhost
-
- - name: "Make instance with an instance_role"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-instance-role"
- image_id: "{{ ec2_ami_image }}"
- security_groups: "{{ sg.group_id }}"
- instance_type: "{{ ec2_instance_type }}"
- instance_role: "ansible-test-sts-{{ resource_prefix }}-test-policy"
- vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- register: instance_with_role
-
- - assert:
- that:
- - 'instance_with_role.instances[0].iam_instance_profile.arn == iam_role.arn.replace(":role/", ":instance-profile/")'
-
- - name: "Make instance with an instance_role(check mode)"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-instance-role-checkmode"
- image_id: "{{ ec2_ami_image }}"
- security_groups: "{{ sg.group_id }}"
- instance_type: "{{ ec2_instance_type }}"
- instance_role: "{{ iam_role.arn.replace(':role/', ':instance-profile/') }}"
- vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- check_mode: yes
-
- - name: "fact presented ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-test-instance-role"
- register: presented_instance_fact
-
- - name: "fact checkmode ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-test-instance-role-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: "Update instance with new instance_role"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-instance-role"
- image_id: "{{ ec2_ami_image }}"
- security_groups: "{{ sg.group_id }}"
- instance_type: "{{ ec2_instance_type }}"
- instance_role: "{{ iam_role_2.arn.replace(':role/', ':instance-profile/') }}"
- vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- register: instance_with_updated_role
-
- - name: "wait 10 seconds for role update to complete"
- wait_for:
- timeout: 10
- delegate_to: localhost
-
- - name: "fact checkmode ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-test-instance-role"
- register: updates_instance_info
-
- - assert:
- that:
- - 'updates_instance_info.instances[0].iam_instance_profile.arn == iam_role_2.arn.replace(":role/", ":instance-profile/")'
- - 'updates_instance_info.instances[0].instance_id == instance_with_role.instances[0].instance_id'
-
- always:
- - name: "Terminate iam_instance_role instances"
- ec2_instance:
- state: absent
- filters:
- "tag:TestId": "{{ ec2_instance_tag_TestId }}"
- wait: yes
- ignore_errors: yes
-
- - name: "Delete IAM role for test"
- iam_role:
- state: absent
- name: "{{ item }}"
- assume_role_policy_document: "{{ lookup('file','assume-role-policy.json') }}"
- create_instance_profile: yes
- managed_policy:
- - AmazonEC2ContainerServiceRole
- loop:
- - "ansible-test-sts-{{ resource_prefix }}-test-policy"
- - "ansible-test-sts-{{ resource_prefix }}-test-policy-2"
- register: removed
- until: removed is not failed
- ignore_errors: yes
- retries: 10
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/instance_no_wait.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/instance_no_wait.yml
deleted file mode 100644
index 418d7ef3e8..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/instance_no_wait.yml
+++ /dev/null
@@ -1,68 +0,0 @@
-- block:
- - name: "New instance and don't wait for it to complete"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-no-wait"
- image_id: "{{ ec2_ami_image }}"
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- wait: false
- instance_type: "{{ ec2_instance_type }}"
- 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:
- state: present
- name: "{{ resource_prefix }}-test-no-wait-checkmode"
- image_id: "{{ ec2_ami_image }}"
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- wait: false
- instance_type: "{{ ec2_instance_type }}"
- check_mode: yes
-
- - name: "Facts for ec2 test instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-test-no-wait"
- register: real_instance_fact
- until: real_instance_fact.instances | length > 0
- retries: 10
-
- - name: "Facts for checkmode ec2 test instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-test-no-wait-checkmode"
- 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"
-
- - name: "Terminate instances"
- ec2_instance:
- state: absent
- instance_ids: "{{ in_test_vpc.instance_ids }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
-
- always:
- - name: "Terminate instance_no_wait instances"
- ec2_instance:
- state: absent
- filters:
- "tag:TestId": "{{ ec2_instance_tag_TestId }}"
- wait: yes
- ignore_errors: yes
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/main.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/main.yml
deleted file mode 100644
index e10aebcefe..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/main.yml
+++ /dev/null
@@ -1,48 +0,0 @@
----
-# Beware: most of our tests here are run in parallel.
-# To add new tests you'll need to add a new host to the inventory and a matching
-# '{{ inventory_hostname }}'.yml file in roles/ec2_instance/tasks/
-#
-# Please make sure you tag your instances with
-# tags:
-# "tag:TestId": "{{ ec2_instance_tag_TestId }}"
-# And delete them based off that tag at the end of your specific set of tests
-#
-# ###############################################################################
-#
-# A Note about ec2 environment variable name preference:
-# - EC2_URL -> AWS_URL
-# - EC2_ACCESS_KEY -> AWS_ACCESS_KEY_ID -> AWS_ACCESS_KEY
-# - EC2_SECRET_KEY -> AWS_SECRET_ACCESS_KEY -> AWX_SECRET_KEY
-# - EC2_REGION -> AWS_REGION
-#
-
-- name: "Wrap up all tests and setup AWS credentials"
- module_defaults:
- group/aws:
- aws_access_key: "{{ aws_access_key }}"
- aws_secret_key: "{{ aws_secret_key }}"
- security_token: "{{ security_token | default(omit) }}"
- region: "{{ aws_region }}"
- block:
- - debug:
- msg: "{{ inventory_hostname }} start: {{ lookup('pipe','date') }}"
- - include_tasks: '{{ inventory_hostname }}.yml'
- - debug:
- msg: "{{ inventory_hostname }} finish: {{ lookup('pipe','date') }}"
-
- always:
- - set_fact:
- _role_complete: True
- - vars:
- completed_hosts: '{{ ansible_play_hosts_all | map("extract", hostvars, "_role_complete") | list | select("defined") | list | length }}'
- hosts_in_play: '{{ ansible_play_hosts_all | length }}'
- debug:
- msg: "{{ completed_hosts }} of {{ hosts_in_play }} complete"
- - include_tasks: env_cleanup.yml
- vars:
- completed_hosts: '{{ ansible_play_hosts_all | map("extract", hostvars, "_role_complete") | list | select("defined") | list | length }}'
- hosts_in_play: '{{ ansible_play_hosts_all | length }}'
- when:
- - aws_cleanup
- - completed_hosts == hosts_in_play
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/tags_and_vpc_settings.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/tags_and_vpc_settings.yml
deleted file mode 100644
index d38b53f76f..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/tags_and_vpc_settings.yml
+++ /dev/null
@@ -1,158 +0,0 @@
-- block:
- - name: "Make instance in the testing subnet created in the test VPC"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-basic-vpc-create"
- image_id: "{{ ec2_ami_image }}"
- user_data: |
- #cloud-config
- package_upgrade: true
- package_update: true
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- Something: else
- security_groups: "{{ sg.group_id }}"
- network:
- source_dest_check: false
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- instance_type: "{{ ec2_instance_type }}"
- wait: false
- register: in_test_vpc
-
- - name: "Make instance in the testing subnet created in the test VPC(check mode)"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-basic-vpc-create-checkmode"
- image_id: "{{ ec2_ami_image }}"
- user_data: |
- #cloud-config
- package_upgrade: true
- package_update: true
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- Something: else
- security_groups: "{{ sg.group_id }}"
- network:
- source_dest_check: false
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- instance_type: "{{ ec2_instance_type }}"
- check_mode: yes
-
- - name: "Try to re-make the instance, hopefully this shows changed=False"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-basic-vpc-create"
- image_id: "{{ ec2_ami_image }}"
- user_data: |
- #cloud-config
- package_upgrade: true
- package_update: true
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- Something: else
- security_groups: "{{ sg.group_id }}"
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- instance_type: "{{ ec2_instance_type }}"
- register: remake_in_test_vpc
- - name: "Remaking the same instance resulted in no changes"
- assert:
- that: not remake_in_test_vpc.changed
- - name: "check that instance IDs match anyway"
- assert:
- that: 'remake_in_test_vpc.instance_ids[0] == in_test_vpc.instance_ids[0]'
- - name: "check that source_dest_check was set to false"
- assert:
- that: 'not remake_in_test_vpc.instances[0].source_dest_check'
-
- - name: "fact presented ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-test-basic-vpc-create"
- register: presented_instance_fact
-
- - name: "fact checkmode ec2 instance"
- ec2_instance_info:
- filters:
- "tag:Name": "{{ resource_prefix }}-test-basic-vpc-create-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: "Alter it by adding tags"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-basic-vpc-create"
- image_id: "{{ ec2_ami_image }}"
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- Another: thing
- security_groups: "{{ sg.group_id }}"
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- instance_type: "{{ ec2_instance_type }}"
- register: add_another_tag
-
- - ec2_instance_info:
- instance_ids: "{{ add_another_tag.instance_ids }}"
- register: check_tags
- - name: "Remaking the same instance resulted in no changes"
- assert:
- that:
- - check_tags.instances[0].tags.Another == 'thing'
- - check_tags.instances[0].tags.Something == 'else'
-
- - name: "Purge a tag"
- ec2_instance:
- state: present
- name: "{{ resource_prefix }}-test-basic-vpc-create"
- image_id: "{{ ec2_ami_image }}"
- purge_tags: true
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- Another: thing
- security_groups: "{{ sg.group_id }}"
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- instance_type: "{{ ec2_instance_type }}"
-
- - ec2_instance_info:
- instance_ids: "{{ add_another_tag.instance_ids }}"
- register: check_tags
-
- - name: "Remaking the same instance resulted in no changes"
- assert:
- that:
- - "'Something' not in check_tags.instances[0].tags"
-
- - name: "check that subnet-default public IP rule was followed"
- assert:
- that:
- - check_tags.instances[0].public_dns_name == ""
- - check_tags.instances[0].private_ip_address.startswith(subnet_b_startswith)
- - check_tags.instances[0].subnet_id == testing_subnet_b.subnet.id
- - name: "check that tags were applied"
- assert:
- that:
- - check_tags.instances[0].tags.Name.startswith(resource_prefix)
- - "'{{ check_tags.instances[0].state.name }}' in ['pending', 'running']"
-
- - name: "Terminate instance"
- ec2_instance:
- state: absent
- filters:
- "tag:TestId": "{{ ec2_instance_tag_TestId }}"
- wait: false
- register: result
- - assert:
- that: result.changed
-
- always:
- - name: "Terminate tags_and_vpc_settings instances"
- ec2_instance:
- state: absent
- filters:
- "tag:TestId": "{{ ec2_instance_tag_TestId }}"
- wait: yes
- ignore_errors: yes
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/termination_protection.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/termination_protection.yml
deleted file mode 100644
index 418e3c398d..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/termination_protection.yml
+++ /dev/null
@@ -1,184 +0,0 @@
-- block:
-
- - name: Create instance with termination protection (check mode)
- ec2_instance:
- name: "{{ resource_prefix }}-termination-protection"
- image_id: "{{ ec2_ami_image }}"
- tags:
- TestId: "{{ resource_prefix }}"
- security_groups: "{{ sg.group_id }}"
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- termination_protection: true
- instance_type: "{{ ec2_instance_type }}"
- state: running
- wait: yes
- check_mode: yes
- register: create_instance_check_mode_results
-
- - name: Check the returned value for the earlier task
- assert:
- that:
- - "{{ create_instance_check_mode_results.changed }}"
- - "{{ create_instance_check_mode_results.spec.DisableApiTermination }}"
-
- - name: Create instance with termination protection
- ec2_instance:
- name: "{{ resource_prefix }}-termination-protection"
- image_id: "{{ ec2_ami_image }}"
- tags:
- TestId: "{{ resource_prefix }}"
- security_groups: "{{ sg.group_id }}"
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- termination_protection: true
- instance_type: "{{ ec2_instance_type }}"
- state: running
- wait: yes
- register: create_instance_results
-
- - name: Check return values of the create instance task
- assert:
- that:
- - "{{ create_instance_results.instances | length }} > 0"
- - "'{{ create_instance_results.instances.0.state.name }}' == 'running'"
- - "'{{ create_instance_results.spec.DisableApiTermination }}'"
-
- - name: Create instance with termination protection (check mode) (idempotent)
- ec2_instance:
- name: "{{ resource_prefix }}-termination-protection"
- image_id: "{{ ec2_ami_image }}"
- tags:
- TestId: "{{ resource_prefix }}"
- security_groups: "{{ sg.group_id }}"
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- termination_protection: true
- instance_type: "{{ ec2_instance_type }}"
- state: running
- wait: yes
- check_mode: yes
- register: create_instance_check_mode_results
-
- - name: Check the returned value for the earlier task
- assert:
- that:
- - "{{ not create_instance_check_mode_results.changed }}"
-
- - name: Create instance with termination protection (idempotent)
- ec2_instance:
- name: "{{ resource_prefix }}-termination-protection"
- image_id: "{{ ec2_ami_image }}"
- tags:
- TestId: "{{ resource_prefix }}"
- security_groups: "{{ sg.group_id }}"
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- termination_protection: true
- instance_type: "{{ ec2_instance_type }}"
- state: running
- wait: yes
- register: create_instance_results
-
- - name: Check return values of the create instance task
- assert:
- that:
- - "{{ not create_instance_results.changed }}"
- - "{{ create_instance_results.instances | length }} > 0"
-
- - name: Try to terminate the instance (expected to fail)
- ec2_instance:
- filters:
- tag:Name: "{{ resource_prefix }}-termination-protection"
- state: absent
- failed_when: "'Unable to terminate instances' not in terminate_instance_results.msg"
- register: terminate_instance_results
-
- # https://github.com/ansible/ansible/issues/67716
- # Updates to termination protection in check mode has a bug (listed above)
-
- - name: Set termination protection to false
- ec2_instance:
- name: "{{ resource_prefix }}-termination-protection"
- image_id: "{{ ec2_ami_image }}"
- termination_protection: false
- instance_type: "{{ ec2_instance_type }}"
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- register: set_termination_protection_results
-
- - name: Check return value
- assert:
- that:
- - "{{ set_termination_protection_results.changed }}"
- - "{{ not set_termination_protection_results.changes[0].DisableApiTermination.Value }}"
-
- - name: Set termination protection to false (idempotent)
- ec2_instance:
- name: "{{ resource_prefix }}-termination-protection"
- image_id: "{{ ec2_ami_image }}"
- termination_protection: false
- instance_type: "{{ ec2_instance_type }}"
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- register: set_termination_protection_results
-
- - name: Check return value
- assert:
- that:
- - "{{ not set_termination_protection_results.changed }}"
-
- - name: Set termination protection to true
- ec2_instance:
- name: "{{ resource_prefix }}-termination-protection"
- image_id: "{{ ec2_ami_image }}"
- termination_protection: true
- instance_type: "{{ ec2_instance_type }}"
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- register: set_termination_protection_results
-
- - name: Check return value
- assert:
- that:
- - "{{ set_termination_protection_results.changed }}"
- - "{{ set_termination_protection_results.changes[0].DisableApiTermination.Value }}"
-
- - name: Set termination protection to true (idempotent)
- ec2_instance:
- name: "{{ resource_prefix }}-termination-protection"
- image_id: "{{ ec2_ami_image }}"
- termination_protection: true
- instance_type: "{{ ec2_instance_type }}"
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- register: set_termination_protection_results
-
- - name: Check return value
- assert:
- that:
- - "{{ not set_termination_protection_results.changed }}"
-
- - name: Set termination protection to false (so we can terminate instance)
- ec2_instance:
- name: "{{ resource_prefix }}-termination-protection"
- image_id: "{{ ec2_ami_image }}"
- termination_protection: false
- instance_type: "{{ ec2_instance_type }}"
- vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
- register: set_termination_protection_results
-
- - name: Terminate the instance
- ec2_instance:
- filters:
- tag:TestId: "{{ resource_prefix }}"
- state: absent
-
- always:
-
- - name: Set termination protection to false (so we can terminate instance) (cleanup)
- ec2_instance:
- filters:
- tag:TestId: "{{ resource_prefix }}"
- termination_protection: false
- ignore_errors: yes
-
- - name: Terminate instance
- ec2_instance:
- filters:
- tag:TestId: "{{ resource_prefix }}"
- state: absent
- wait: false
- ignore_errors: yes
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/version_fail.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/version_fail.yml
deleted file mode 100644
index 67370ebe37..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/version_fail.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-- block:
- - name: "create t3.nano with cpu options (fails gracefully)"
- ec2_instance:
- state: present
- name: "ansible-test-{{ resource_prefix | regex_search('([0-9]+)$') }}-ec2"
- image_id: "{{ ec2_ami_image }}"
- instance_type: "t3.nano"
- cpu_options:
- core_count: 1
- threads_per_core: 1
- tags:
- TestId: "{{ ec2_instance_tag_TestId }}"
- register: ec2_instance_cpu_options_creation
- ignore_errors: yes
-
- - name: "check that graceful error message is returned when creation with cpu_options and old botocore"
- assert:
- that:
- - ec2_instance_cpu_options_creation.failed
- - 'ec2_instance_cpu_options_creation.msg == "cpu_options is only supported with botocore >= 1.10.16"'
-
- always:
- - name: "Terminate version_fail instances"
- ec2_instance:
- state: absent
- filters:
- "tag:TestId": "{{ ec2_instance_tag_TestId }}"
- wait: yes
- ignore_errors: yes
diff --git a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/version_fail_wrapper.yml b/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/version_fail_wrapper.yml
deleted file mode 100644
index ae5bd78500..0000000000
--- a/test/integration/targets/ec2_instance/roles/ec2_instance/tasks/version_fail_wrapper.yml
+++ /dev/null
@@ -1,30 +0,0 @@
----
-- include_role:
- name: 'setup_remote_tmp_dir'
-
-- set_fact:
- virtualenv: "{{ remote_tmp_dir }}/virtualenv"
- virtualenv_command: "{{ ansible_python_interpreter }} -m virtualenv"
-
-- set_fact:
- virtualenv_interpreter: "{{ virtualenv }}/bin/python"
-
-- pip:
- name: "virtualenv"
-
-- pip:
- name:
- - 'botocore<1.10.16'
- - boto3
- - coverage
- virtualenv: "{{ virtualenv }}"
- virtualenv_command: "{{ virtualenv_command }}"
- virtualenv_site_packages: no
-
-- include_tasks: version_fail.yml
- vars:
- ansible_python_interpreter: "{{ virtualenv_interpreter }}"
-
-- file:
- state: absent
- path: "{{ virtualenv }}"
diff --git a/test/integration/targets/ec2_instance/runme.sh b/test/integration/targets/ec2_instance/runme.sh
deleted file mode 100755
index aa324772bb..0000000000
--- a/test/integration/targets/ec2_instance/runme.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env bash
-#
-# Beware: most of our tests here are run in parallel.
-# To add new tests you'll need to add a new host to the inventory and a matching
-# '{{ inventory_hostname }}'.yml file in roles/ec2_instance/tasks/
-
-
-set -eux
-
-export ANSIBLE_ROLES_PATH=../
-
-ansible-playbook main.yml -i inventory "$@"