Fail with nice error message if elb target_type=ip not supported (#38313)

* Add helpful failure message if target_type=ip is not supported

Create test case for target_type=ip not supported

* Update elb_target_group module to latest standards

Use AnsibleAWSModule
Improve exception handling
Improve connection handling
This commit is contained in:
Will Thames 2018-05-03 22:36:52 +10:00 committed by ansibot
commit 29770a297a
9 changed files with 135 additions and 88 deletions

View file

@ -1,2 +1,3 @@
cloud/aws
unsupported
elb_target_group

View file

@ -1,4 +0,0 @@
---
ec2_ami_image:
us-east-1: ami-8c1be5f6
us-east-2: ami-c5062ba0

View file

@ -0,0 +1,5 @@
- hosts: localhost
connection: local
roles:
- elb_target

View file

@ -0,0 +1,7 @@
---
ec2_ami_image:
us-east-1: ami-8c1be5f6
us-east-2: ami-c5062ba0
tg_name: "ansible-test-{{ resource_prefix | regex_search('([0-9]+)$') }}-tg"
lb_name: "ansible-test-{{ resource_prefix | regex_search('([0-9]+)$') }}-lb"

View file

@ -5,7 +5,6 @@
- name:
debug: msg="********** Setting up elb_target test dependencies **********"
# ============================================================
- name: set up aws connection info
@ -19,16 +18,6 @@
# ============================================================
- name: create target group name
set_fact:
tg_name: "ansible-test-{{ resource_prefix | regex_search('([0-9]+)$') }}-tg"
- name: create application load balancer name
set_fact:
lb_name: "ansible-test-{{ resource_prefix | regex_search('([0-9]+)$') }}-lb"
# ============================================================
- name: set up testing VPC
ec2_vpc_net:
name: "{{ resource_prefix }}-vpc"

View file

@ -0,0 +1,33 @@
- hosts: localhost
connection: local
tasks:
- name: set up aws connection info
set_fact:
aws_connection_info: &aws_connection_info
aws_access_key: madeup
aws_secret_key: madeup
security_token: madeup
region: "{{ aws_region }}"
no_log: yes
- name: set up testing target group (type=ip)
elb_target_group:
name: "ansible-test-{{ resource_prefix | regex_search('([0-9]+)$') }}-tg"
health_check_port: 80
protocol: http
port: 80
vpc_id: 'vpc-abcd1234'
state: present
target_type: ip
tags:
Description: "Created by {{ resource_prefix }}"
<<: *aws_connection_info
register: elb_target_group_type_ip
ignore_errors: yes
- name: check that setting up target group with type=ip fails with friendly message
assert:
that:
- elb_target_group_type_ip is failed
- "'msg' in elb_target_group_type_ip"

View file

@ -0,0 +1,26 @@
#!/usr/bin/env bash
# We don't set -u here, due to pypa/virtualenv#150
set -ex
MYTMPDIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')
trap 'rm -rf "${MYTMPDIR}"' EXIT
# This is needed for the ubuntu1604py3 tests
# Ubuntu patches virtualenv to make the default python2
# but for the python3 tests we need virtualenv to use python3
PYTHON=${ANSIBLE_TEST_PYTHON_INTERPRETER:-python}
# Test graceful failure for older versions of botocore
virtualenv --system-site-packages --python "${PYTHON}" "${MYTMPDIR}/botocore-1.7.1"
source "${MYTMPDIR}/botocore-1.7.1/bin/activate"
$PYTHON -m pip install 'botocore<=1.7.1' boto3
ansible-playbook -i ../../inventory -e @../../integration_config.yml -e @../../cloud-config-aws.yml -v playbooks/version_fail.yml "$@"
# Run full test suite
virtualenv --system-site-packages --python "${PYTHON}" "${MYTMPDIR}/botocore-recent"
source "${MYTMPDIR}/botocore-recent/bin/activate"
$PYTHON -m pip install 'botocore>=1.8.0' boto3
ansible-playbook -i ../../inventory -e @../../integration_config.yml -e @../../cloud-config-aws.yml -v playbooks/full_test.yml "$@"