Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve aws testing #26892

Merged
merged 3 commits into from
Nov 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ packaging/release/ansible_release
/test/integration/inventory.networking
/test/integration/inventory.winrm
/test/integration/cloud-config-aws.yml
/test/integration/cloud-config-cs.ini
# python 'rope' stuff
.ropeproject
# local 'ack' config files
Expand Down
14 changes: 10 additions & 4 deletions docs/docsite/rst/dev_guide/testing_integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,17 @@ IAM policies for AWS

Ansible needs fairly wide ranging powers to run the tests in an AWS account. This rights can be provided to a dedicated user. These need to be configured before running the test.

testing-iam-policy.json.j2
--------------------------
testing-policies
----------------

The testing-iam-policy.json.j2 file contains a policy which can be given to the user
running the tests to minimize the rights of that user. Please note that while this policy does limit the user to one region, this does not fully restrict the user (primarily due to the limitations of the Amazon ARN notation). The user will still have wide privileges for viewing account definitions, and will also able to manage some resources that are not related to testing (for example, AWS lambdas with different names). Tests should not be run in a primary production account in any case.
``hacking/aws_config/testing_policies`` contains a set of policies that are required for all existing AWS module tests.
The ``hacking/aws_config/setup_iam.yml`` playbook can be used to add all of those policies to an IAM group (using
``-e iam_group=GROUP_NAME``. Once the group is created, you'll need to create a user and make the user a member of the
group. The policies are designed to minimize the rights of that user. Please note that while this policy does limit
the user to one region, this does not fully restrict the user (primarily due to the limitations of the Amazon ARN
notation). The user will still have wide privileges for viewing account definitions, and will also able to manage
some resources that are not related to testing (for example, AWS lambdas with different names). Tests should not
be run in a primary production account in any case.

Other Definitions required
--------------------------
Expand Down
66 changes: 36 additions & 30 deletions test/integration/targets/ec2_elb_lb/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
security_token: "{{ security_token }}"
state: present
zones:
- us-east-1c
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
listeners:
- protocol: http
load_balancer_port: 80
Expand All @@ -61,8 +61,8 @@
that:
- 'info.changed'
- 'info.elb.status == "created"'
- '"us-east-1c" in info.elb.zones'
- '"us-east-1d" in info.elb.zones'
- '"{{ ec2_region }}a" in info.elb.zones'
- '"{{ ec2_region }}b" in info.elb.zones'
- 'info.elb.health_check.healthy_threshold == 10'
- 'info.elb.health_check.interval == 30'
- 'info.elb.health_check.target == "HTTP:80/index.html"'
Expand Down Expand Up @@ -103,7 +103,7 @@
security_token: "{{ security_token }}"
state: present
zones:
- us-east-1b
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 80
Expand All @@ -125,7 +125,7 @@
that:
- 'info.elb.status == "ok"'
- 'info.changed'
- 'info.elb.zones[0] == "us-east-1b"'
- 'info.elb.zones[0] == "{{ ec2_region }}c"'

# ============================================================

Expand All @@ -140,9 +140,9 @@
security_token: "{{ security_token }}"
state: present
zones:
- us-east-1b
- us-east-1c
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 80
Expand All @@ -154,9 +154,9 @@
that:
- 'info.changed'
- 'info.elb.status == "ok"'
- '"us-east-1b" in info.elb.zones'
- '"us-east-1c" in info.elb.zones'
- '"us-east-1d" in info.elb.zones'
- '"{{ ec2_region }}a" in info.elb.zones'
- '"{{ ec2_region }}b" in info.elb.zones'
- '"{{ ec2_region }}c" in info.elb.zones'


# ============================================================
Expand All @@ -172,9 +172,9 @@
security_token: "{{ security_token }}"
state: present
zones:
- us-east-1b
- us-east-1c
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 80
Expand Down Expand Up @@ -204,9 +204,9 @@
security_token: "{{ security_token }}"
state: present
zones:
- us-east-1b
- us-east-1c
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 8081
Expand Down Expand Up @@ -263,8 +263,9 @@
load_balancer_port: 80
instance_port: 80
zones:
- us-east-1c
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
register: result
ignore_errors: true

Expand All @@ -282,8 +283,9 @@
region: "{{ ec2_region }}"
state: present
zones:
- us-east-1a
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 80
Expand All @@ -307,8 +309,9 @@
region: "{{ ec2_region }}"
state: present
zones:
- us-east-1a
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 80
Expand All @@ -332,8 +335,9 @@
region: "{{ ec2_region }}"
state: present
zones:
- us-east-1a
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 80
Expand All @@ -357,8 +361,9 @@
region: "{{ ec2_region }}"
state: present
zones:
- us-east-1a
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 80
Expand All @@ -383,8 +388,9 @@
region: "{{ ec2_region }}"
state: present
zones:
- us-east-1a
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 80
Expand Down
66 changes: 36 additions & 30 deletions test/integration/targets/elb_classic_lb/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
security_token: "{{ security_token }}"
state: present
zones:
- us-east-1c
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
listeners:
- protocol: http
load_balancer_port: 80
Expand All @@ -61,8 +61,8 @@
that:
- 'info.changed'
- 'info.elb.status == "created"'
- '"us-east-1c" in info.elb.zones'
- '"us-east-1d" in info.elb.zones'
- '"{{ ec2_region }}a" in info.elb.zones'
- '"{{ ec2_region }}b" in info.elb.zones'
- 'info.elb.health_check.healthy_threshold == 10'
- 'info.elb.health_check.interval == 30'
- 'info.elb.health_check.target == "HTTP:80/index.html"'
Expand Down Expand Up @@ -103,7 +103,7 @@
security_token: "{{ security_token }}"
state: present
zones:
- us-east-1b
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 80
Expand All @@ -125,7 +125,7 @@
that:
- 'info.elb.status == "ok"'
- 'info.changed'
- 'info.elb.zones[0] == "us-east-1b"'
- 'info.elb.zones[0] == "{{ ec2_region }}c"'

# ============================================================

Expand All @@ -140,9 +140,9 @@
security_token: "{{ security_token }}"
state: present
zones:
- us-east-1b
- us-east-1c
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 80
Expand All @@ -154,9 +154,9 @@
that:
- 'info.changed'
- 'info.elb.status == "ok"'
- '"us-east-1b" in info.elb.zones'
- '"us-east-1c" in info.elb.zones'
- '"us-east-1d" in info.elb.zones'
- '"{{ ec2_region }}a" in info.elb.zones'
- '"{{ ec2_region }}b" in info.elb.zones'
- '"{{ ec2_region }}c" in info.elb.zones'


# ============================================================
Expand All @@ -172,9 +172,9 @@
security_token: "{{ security_token }}"
state: present
zones:
- us-east-1b
- us-east-1c
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 80
Expand Down Expand Up @@ -204,9 +204,9 @@
security_token: "{{ security_token }}"
state: present
zones:
- us-east-1b
- us-east-1c
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 8081
Expand Down Expand Up @@ -263,8 +263,9 @@
load_balancer_port: 80
instance_port: 80
zones:
- us-east-1c
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
register: result
ignore_errors: true

Expand All @@ -282,8 +283,9 @@
region: "{{ ec2_region }}"
state: present
zones:
- us-east-1a
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 80
Expand All @@ -307,8 +309,9 @@
region: "{{ ec2_region }}"
state: present
zones:
- us-east-1a
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 80
Expand All @@ -332,8 +335,9 @@
region: "{{ ec2_region }}"
state: present
zones:
- us-east-1a
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 80
Expand All @@ -357,8 +361,9 @@
region: "{{ ec2_region }}"
state: present
zones:
- us-east-1a
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 80
Expand All @@ -383,8 +388,9 @@
region: "{{ ec2_region }}"
state: present
zones:
- us-east-1a
- us-east-1d
- "{{ ec2_region }}a"
- "{{ ec2_region }}b"
- "{{ ec2_region }}c"
listeners:
- protocol: http
load_balancer_port: 80
Expand Down