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

Add integration tests for aws_resource_actions #876

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cloud/aws
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[tests]
localhost

[all:vars]
ansible_connection=local
ansible_python_interpreter="{{ ansible_playbook_python }}"
35 changes: 35 additions & 0 deletions tests/integration/targets/callback_aws_resource_actions/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
- hosts: localhost
gather_facts: no
collections:
- amazon.aws
module_defaults:
group/aws:
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
security_token: "{{ security_token | default(omit) }}"
region: "{{ aws_region }}"
tasks:
- ec2_instance_info:
register: ec2_info

- assert:
that:
- '"resource_actions" in ec2_info'
- '"ec2:DescribeInstances" in ec2_info.resource_actions'

- aws_az_info:
register: az_info

- assert:
that:
- '"resource_actions" in az_info'
- '"ec2:DescribeAvailabilityZones" in az_info.resource_actions'

- aws_caller_info:
register: caller_info

- assert:
that:
- '"resource_actions" in caller_info'
- '"sts:GetCallerIdentity" in caller_info.resource_actions'
- '"iam:ListAccountAliases" in caller_info.resource_actions'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dependencies: []
19 changes: 19 additions & 0 deletions tests/integration/targets/callback_aws_resource_actions/runme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -eux

export ANSIBLE_CALLBACK_WHITELIST="aws_resource_actions"

OUTFILE="callback_aws_resource_actions.out"
trap 'rm -rvf "${OUTFILE}" "${OUTFILE}.actions"' EXIT

# Tests that the resource_actions are added to each task
ansible-playbook main.yml -i localhost "$@" | tee "${OUTFILE}"

# There should be a summary at the end of the run with the actions performed:
# AWS ACTIONS: ['ec2:DescribeAvailabilityZones', 'ec2:DescribeInstances', 'iam:ListAccountAliases', 'sts:GetCallerIdentity']
grep -E "AWS ACTIONS: \[" "${OUTFILE}" > "${OUTFILE}.actions"
for action in 'ec2:DescribeAvailabilityZones' 'ec2:DescribeInstances' 'iam:ListAccountAliases' 'sts:GetCallerIdentity'
do
grep "${action}" "${OUTFILE}.actions"
done
3 changes: 0 additions & 3 deletions tests/integration/targets/legacy_missing_tests/aliases
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@ disabled

# Lookup plugins
aws_ssm

# Callback plugin
aws_resource_actions