2018-08-20 12:49:00 +02:00
|
|
|
- hosts: localhost
|
|
|
|
connection: local
|
2019-03-18 14:29:03 +01:00
|
|
|
environment: "{{ ansible_test.environment }}"
|
2018-08-20 12:49:00 +02:00
|
|
|
vars:
|
|
|
|
resource_prefix: 'ansible-testing'
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- block:
|
|
|
|
- name: set up aws connection info
|
|
|
|
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
|
2018-11-09 13:11:51 +01:00
|
|
|
|
2018-08-20 12:49:00 +02:00
|
|
|
- name: Include vars file in roles/ec2_instance/defaults/main.yml
|
|
|
|
include_vars:
|
|
|
|
file: 'roles/ec2_instance/defaults/main.yml'
|
|
|
|
|
|
|
|
- name: create c4.large with cpu options (fails gracefully)
|
|
|
|
ec2_instance:
|
|
|
|
state: present
|
|
|
|
name: "ansible-test-{{ resource_prefix | regex_search('([0-9]+)$') }}-ec2"
|
|
|
|
image_id: "{{ ec2_ami_image[aws_region] }}"
|
|
|
|
instance_type: c4.large
|
|
|
|
cpu_options:
|
|
|
|
core_count: 1
|
|
|
|
threads_per_core: 1
|
|
|
|
<<: *aws_connection_info
|
|
|
|
register: ec2_instance_cpu_options_creation
|
|
|
|
ignore_errors: yes
|
|
|
|
|
2018-11-09 13:11:51 +01:00
|
|
|
- name: check that graceful error message is returned when creation with cpu_options and old botocore
|
2018-08-20 12:49:00 +02:00
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- ec2_instance_cpu_options_creation.failed
|
2018-11-09 13:11:51 +01:00
|
|
|
- 'ec2_instance_cpu_options_creation.msg == "cpu_options is only supported with botocore >= 1.10.16"'
|
2019-03-06 13:46:37 +01:00
|
|
|
|
|
|
|
always:
|
|
|
|
- name: cleanup c4.large in case graceful failure was in fact a graceful success
|
|
|
|
ec2_instance:
|
|
|
|
state: absent
|
|
|
|
name: "ansible-test-{{ resource_prefix | regex_search('([0-9]+)$') }}-ec2"
|
|
|
|
<<: *aws_connection_info
|
|
|
|
ignore_errors: yes
|