ec2_instance: ebs_optimized is not sub-option of 'network' (#48341)

* ebs_optimized is not suboption of 'network'

* Add Shaps as ec2_instance maintainer

* Added workaround-backward compatible check for ebs_optimized

* Added ebs_optimized test

* CI fixes, dynamic select of ENA-enabled AMI
This commit is contained in:
Andrea Tartaglia 2018-11-09 12:11:51 +00:00 committed by John R Barker
commit b7d9feb7dc
6 changed files with 63 additions and 5 deletions

View file

@ -18,3 +18,19 @@ ec2_ami_image:
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

View file

@ -0,0 +1,34 @@
- 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: Make EBS optimized instance in the testing subnet of the test VPC
ec2_instance:
name: "{{ resource_prefix }}-test-ebs-optimized-instance-in-vpc"
image_id: "{{ ec2_ebs_optimized_ami_image[aws_region] }}"
tags:
TestId: "{{ resource_prefix }}"
security_groups: "{{ sg.group_id }}"
vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
ebs_optimized: true
instance_type: t3.nano
<<: *aws_connection_info
register: ebs_opt_in_vpc
- name: Get ec2 instance facts
ec2_instance_facts:
filters:
"tag:Name": "{{ resource_prefix }}-test-ebs-optimized-instance-in-vpc"
"instance-state-name": "running"
<<: *aws_connection_info
register: ebs_opt_instance_fact
- name: Assert instance is ebs_optimized
assert:
that:
- "{{ ebs_opt_instance_fact.instances.0.ebs_optimized }}"

View file

@ -97,6 +97,7 @@
- include_tasks: default_vpc_tests.yml
- include_tasks: iam_instance_role.yml
- include_tasks: checkmode_tests.yml
- include_tasks: ebs_optimized.yml
# ============================================================

View file

@ -13,7 +13,7 @@
security_token: "{{ security_token }}"
region: "{{ aws_region }}"
no_log: True
- name: Include vars file in roles/ec2_instance/defaults/main.yml
include_vars:
file: 'roles/ec2_instance/defaults/main.yml'
@ -31,8 +31,8 @@
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
- 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"'
- 'ec2_instance_cpu_options_creation.msg == "cpu_options is only supported with botocore >= 1.10.16"'