mirror of https://github.com/ansible/ansible.git
Removed nested role for ec2_instance tests
Also moved environment setup and environment cleanup to separate task files Added CI group Updated c4.large instances to t3.nano, use ENA enabled AMI Updated AMIs with Amazon Linux AMI Updated us-east-1 AMI id Specify EBS size typo, volume_size Removed 'state: running', updated AMI with amz ami Also added several wait: false to speed things up Check for instance state, correctly Accept pending as valid state tags_and_vpc_settings do not wait for instance to complete wait for termination protected instance Updated IAM role name to match with policy Skip env cleanup when in CI Do not wait instance in external_resource_attach ENI remove is done in env_cleanup/CI wait some time for instance_profile instnace to be up Updated ebs_optimized_images Corrected task name Added aws_cleanup var in cloud-config-aws typo in runme default aws_cleanup to truepull/18320/head
parent
30a7670f36
commit
da1a621bd9
@ -1,2 +1,2 @@
|
||||
cloud/aws
|
||||
unsupported
|
||||
shippable/aws/group2
|
||||
|
@ -0,0 +1,23 @@
|
||||
---
|
||||
# defaults file for ec2_instance
|
||||
ec2_instance_name: '{{ resource_prefix }}-node'
|
||||
ec2_instance_owner: 'integration-run-{{ resource_prefix }}'
|
||||
ec2_ami_image:
|
||||
# Amazon Linux - collected 2019-05-10
|
||||
ap-northeast-1: ami-086063d8c95bfa211
|
||||
ap-northeast-2: ami-04a1d511fd8937540
|
||||
ap-south-1: ami-0d1ca7565b637e9a5
|
||||
ap-southeast-1: ami-07dd66a9764fbb937
|
||||
ap-southeast-2: ami-0ca7144d77a93c7a8
|
||||
ca-central-1: ami-0e5e1c6b373fed93b
|
||||
eu-central-1: ami-05ba799ee5fc165db
|
||||
eu-west-1: ami-055ff4f3e62e8e65e
|
||||
eu-west-2: ami-072edd63fd2b95ca7
|
||||
sa-east-1: ami-0c0698b4027cd5931
|
||||
us-east-1: ami-0771c28c5580e5716
|
||||
us-east-2: ami-063225b63017efd17
|
||||
us-west-1: ami-04abfbe0050a1ef1d
|
||||
us-west-2: ami-027c5e2ccf2970def
|
||||
|
||||
# We need to use ENA enabled AMIs to get EBS optimized instances.
|
||||
ec2_ebs_optimized_ami_image: "{{ ec2_ami_image }}"
|
@ -1,36 +0,0 @@
|
||||
---
|
||||
# defaults file for ec2_instance
|
||||
ec2_instance_name: '{{resource_prefix}}-node'
|
||||
ec2_instance_owner: 'integration-run-{{resource_prefix}}'
|
||||
ec2_ami_image:
|
||||
# https://wiki.centos.org/Cloud/AWS collected 2018-01-10
|
||||
ap-northeast-1: ami-571e3c30
|
||||
ap-northeast-2: ami-97cb19f9
|
||||
ap-south-1: ami-11f0837e
|
||||
ap-southeast-1: ami-30318f53
|
||||
ap-southeast-2: ami-24959b47
|
||||
ca-central-1: ami-daeb57be
|
||||
eu-central-1: ami-7cbc6e13
|
||||
eu-west-1: ami-0d063c6b
|
||||
eu-west-2: ami-c22236a6
|
||||
sa-east-1: ami-864f2dea
|
||||
us-east-1: ami-ae7bfdb8
|
||||
us-east-2: ami-9cbf9bf9
|
||||
us-west-1: ami-7c280d1c
|
||||
us-west-2: ami-0c2aba6c
|
||||
# We need to use ENA enabled AMIs to get EBS optimized instances.
|
||||
ec2_ebs_optimized_ami_image:
|
||||
ap-northeast-1: ami-00f9d04b3b3092052
|
||||
ap-northeast-2: ami-0c764df09c35858b8
|
||||
ap-south-1: ami-00796998f258969fd
|
||||
ap-southeast-1: ami-085fd1bd447be68e8
|
||||
ap-southeast-2: ami-0b8dea0e70b969adc
|
||||
ca-central-1: ami-05cac140c6a1fb960
|
||||
eu-central-1: ami-02ea8f348fa28c108
|
||||
eu-west-1: ami-0a5e707736615003c
|
||||
eu-west-2: ami-017b0e29fac27906b
|
||||
sa-east-1: ami-0160a8b6087883cb6
|
||||
us-east-1: ami-013be31976ca2c322
|
||||
us-east-2: ami-0350c5670171b5391
|
||||
us-west-1: ami-01beb64058d271bc4
|
||||
us-west-2: ami-061e7ebbc234015fe
|
@ -1,208 +0,0 @@
|
||||
---
|
||||
# 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
|
||||
#
|
||||
|
||||
# - include: ../../../../../setup_ec2/tasks/common.yml module_name: ec2_instance
|
||||
|
||||
- block:
|
||||
|
||||
# ============================================================
|
||||
- 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: Create VPC for use in testing
|
||||
ec2_vpc_net:
|
||||
name: "{{ resource_prefix }}-vpc"
|
||||
cidr_block: 10.22.32.0/23
|
||||
tags:
|
||||
Name: Ansible ec2_instance Testing VPC
|
||||
tenancy: default
|
||||
<<: *aws_connection_info
|
||||
register: testing_vpc
|
||||
|
||||
- name: Create internet gateway for use in testing
|
||||
ec2_vpc_igw:
|
||||
vpc_id: "{{ testing_vpc.vpc.id }}"
|
||||
state: present
|
||||
<<: *aws_connection_info
|
||||
register: igw
|
||||
|
||||
- name: Create default subnet in zone A
|
||||
ec2_vpc_subnet:
|
||||
state: present
|
||||
vpc_id: "{{ testing_vpc.vpc.id }}"
|
||||
cidr: 10.22.32.0/24
|
||||
az: "{{ aws_region }}a"
|
||||
resource_tags:
|
||||
Name: "{{ resource_prefix }}-subnet-a"
|
||||
<<: *aws_connection_info
|
||||
register: testing_subnet_a
|
||||
|
||||
- name: Create secondary subnet in zone B
|
||||
ec2_vpc_subnet:
|
||||
state: present
|
||||
vpc_id: "{{ testing_vpc.vpc.id }}"
|
||||
cidr: 10.22.33.0/24
|
||||
az: "{{ aws_region }}b"
|
||||
resource_tags:
|
||||
Name: "{{ resource_prefix }}-subnet-b"
|
||||
<<: *aws_connection_info
|
||||
register: testing_subnet_b
|
||||
|
||||
- name: create routing rules
|
||||
ec2_vpc_route_table:
|
||||
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 }}"
|
||||
<<: *aws_connection_info
|
||||
|
||||
- name: create a security group with the vpc
|
||||
ec2_group:
|
||||
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
|
||||
<<: *aws_connection_info
|
||||
register: sg
|
||||
|
||||
- include_tasks: cpu_options.yml
|
||||
- include_tasks: termination_protection.yml
|
||||
- include_tasks: tags_and_vpc_settings.yml
|
||||
- include_tasks: external_resource_attach.yml
|
||||
- include_tasks: block_devices.yml
|
||||
- include_tasks: default_vpc_tests.yml
|
||||
- include_tasks: iam_instance_role.yml
|
||||
- include_tasks: checkmode_tests.yml
|
||||
- include_tasks: ebs_optimized.yml
|
||||
- include_tasks: instance_no_wait.yml
|
||||
|
||||
# ============================================================
|
||||
|
||||
always:
|
||||
- name: remove any instances in the test VPC
|
||||
ec2_instance:
|
||||
filters:
|
||||
vpc_id: "{{ testing_vpc.vpc.id }}"
|
||||
state: absent
|
||||
<<: *aws_connection_info
|
||||
register: removed
|
||||
until: removed is not failed
|
||||
ignore_errors: yes
|
||||
retries: 10
|
||||
|
||||
- name: remove ENIs
|
||||
ec2_eni_info:
|
||||
filters:
|
||||
vpc-id: "{{ testing_vpc.vpc.id }}"
|
||||
<<: *aws_connection_info
|
||||
register: enis
|
||||
|
||||
- name: delete all ENIs
|
||||
ec2_eni:
|
||||
eni_id: "{{ item.id }}"
|
||||
state: absent
|
||||
<<: *aws_connection_info
|
||||
until: removed is not failed
|
||||
with_items: "{{ enis.network_interfaces }}"
|
||||
ignore_errors: yes
|
||||
retries: 10
|
||||
|
||||
- name: remove the security group
|
||||
ec2_group:
|
||||
name: "{{ resource_prefix }}-sg"
|
||||
description: a security group for ansible tests
|
||||
vpc_id: "{{ testing_vpc.vpc.id }}"
|
||||
state: absent
|
||||
<<: *aws_connection_info
|
||||
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 }}"
|
||||
<<: *aws_connection_info
|
||||
register: removed
|
||||
until: removed is not failed
|
||||
ignore_errors: yes
|
||||
retries: 10
|
||||
|
||||
- name: remove internet gateway
|
||||
ec2_vpc_igw:
|
||||
vpc_id: "{{ testing_vpc.vpc.id }}"
|
||||
state: absent
|
||||
<<: *aws_connection_info
|
||||
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: 10.22.32.0/24
|
||||
<<: *aws_connection_info
|
||||
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: 10.22.33.0/24
|
||||
<<: *aws_connection_info
|
||||
register: removed
|
||||
until: removed is not failed
|
||||
ignore_errors: yes
|
||||
retries: 10
|
||||
|
||||
- name: remove the VPC
|
||||
ec2_vpc_net:
|
||||
name: "{{ resource_prefix }}-vpc"
|
||||
cidr_block: 10.22.32.0/23
|
||||
state: absent
|
||||
tags:
|
||||
Name: Ansible Testing VPC
|
||||
tenancy: default
|
||||
<<: *aws_connection_info
|
||||
register: removed
|
||||
until: removed is not failed
|
||||
ignore_errors: yes
|
||||
retries: 10
|
@ -0,0 +1,112 @@
|
||||
- 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: remove any instances in the test VPC
|
||||
ec2_instance:
|
||||
filters:
|
||||
vpc_id: "{{ testing_vpc.vpc.id }}"
|
||||
state: absent
|
||||
<<: *aws_connection_info
|
||||
register: removed
|
||||
until: removed is not failed
|
||||
ignore_errors: yes
|
||||
retries: 10
|
||||
|
||||
- name: remove ENIs
|
||||
ec2_eni_info:
|
||||
filters:
|
||||
vpc-id: "{{ testing_vpc.vpc.id }}"
|
||||
<<: *aws_connection_info
|
||||
register: enis
|
||||
|
||||
- name: delete all ENIs
|
||||
ec2_eni:
|
||||
eni_id: "{{ item.id }}"
|
||||
state: absent
|
||||
<<: *aws_connection_info
|
||||
until: removed is not failed
|
||||
with_items: "{{ enis.network_interfaces }}"
|
||||
ignore_errors: yes
|
||||
retries: 10
|
||||
|
||||
- name: remove the security group
|
||||
ec2_group:
|
||||
name: "{{ resource_prefix }}-sg"
|
||||
description: a security group for ansible tests
|
||||
vpc_id: "{{ testing_vpc.vpc.id }}"
|
||||
state: absent
|
||||
<<: *aws_connection_info
|
||||
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 }}"
|
||||
<<: *aws_connection_info
|
||||
register: removed
|
||||
until: removed is not failed
|
||||
ignore_errors: yes
|
||||
retries: 10
|
||||
|
||||
- name: remove internet gateway
|
||||
ec2_vpc_igw:
|
||||
vpc_id: "{{ testing_vpc.vpc.id }}"
|
||||
state: absent
|
||||
<<: *aws_connection_info
|
||||
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: 10.22.32.0/24
|
||||
<<: *aws_connection_info
|
||||
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: 10.22.33.0/24
|
||||
<<: *aws_connection_info
|
||||
register: removed
|
||||
until: removed is not failed
|
||||
ignore_errors: yes
|
||||
retries: 10
|
||||
|
||||
- name: remove the VPC
|
||||
ec2_vpc_net:
|
||||
name: "{{ resource_prefix }}-vpc"
|
||||
cidr_block: 10.22.32.0/23
|
||||
state: absent
|
||||
tags:
|
||||
Name: Ansible Testing VPC
|
||||
tenancy: default
|
||||
<<: *aws_connection_info
|
||||
register: removed
|
||||
until: removed is not failed
|
||||
ignore_errors: yes
|
||||
retries: 10
|
@ -0,0 +1,77 @@
|
||||
- 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: Create VPC for use in testing
|
||||
ec2_vpc_net:
|
||||
name: "{{ resource_prefix }}-vpc"
|
||||
cidr_block: 10.22.32.0/23
|
||||
tags:
|
||||
Name: Ansible ec2_instance Testing VPC
|
||||
tenancy: default
|
||||
<<: *aws_connection_info
|
||||
register: testing_vpc
|
||||
|
||||
- name: Create internet gateway for use in testing
|
||||
ec2_vpc_igw:
|
||||
vpc_id: "{{ testing_vpc.vpc.id }}"
|
||||
state: present
|
||||
<<: *aws_connection_info
|
||||
register: igw
|
||||
|
||||
- name: Create default subnet in zone A
|
||||
ec2_vpc_subnet:
|
||||
state: present
|
||||
vpc_id: "{{ testing_vpc.vpc.id }}"
|
||||
cidr: 10.22.32.0/24
|
||||
az: "{{ aws_region }}a"
|
||||
resource_tags:
|
||||
Name: "{{ resource_prefix }}-subnet-a"
|
||||
<<: *aws_connection_info
|
||||
register: testing_subnet_a
|
||||
|
||||
- name: Create secondary subnet in zone B
|
||||
ec2_vpc_subnet:
|
||||
state: present
|
||||
vpc_id: "{{ testing_vpc.vpc.id }}"
|
||||
cidr: 10.22.33.0/24
|
||||
az: "{{ aws_region }}b"
|
||||
resource_tags:
|
||||
Name: "{{ resource_prefix }}-subnet-b"
|
||||
<<: *aws_connection_info
|
||||
register: testing_subnet_b
|
||||
|
||||
- name: create routing rules
|
||||
ec2_vpc_route_table:
|
||||
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 }}"
|
||||
<<: *aws_connection_info
|
||||
|
||||
- name: create a security group with the vpc
|
||||
ec2_group:
|
||||
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
|
||||
<<: *aws_connection_info
|
||||
register: sg
|
@ -0,0 +1,27 @@
|
||||
---
|
||||
# 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
|
||||
#
|
||||
|
||||
# - include: ../../../../../setup_ec2/tasks/common.yml module_name: ec2_instance
|
||||
|
||||
- block:
|
||||
|
||||
- include_tasks: env_setup.yml
|
||||
- include_tasks: cpu_options.yml
|
||||
- include_tasks: termination_protection.yml
|
||||
- include_tasks: tags_and_vpc_settings.yml
|
||||
- include_tasks: external_resource_attach.yml
|
||||
- include_tasks: block_devices.yml
|
||||
- include_tasks: default_vpc_tests.yml
|
||||
- include_tasks: iam_instance_role.yml
|
||||
- include_tasks: checkmode_tests.yml
|
||||
- include_tasks: ebs_optimized.yml
|
||||
- include_tasks: instance_no_wait.yml
|
||||
|
||||
always:
|
||||
- include_tasks: env_cleanup.yml
|
||||
when: aws_cleanup
|
Loading…
Reference in New Issue