forked from ansible-collections/amazon.aws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests for aws_resource_actions (ansible-collections#876)
Add integration tests for aws_resource_actions SUMMARY Add some minimal integration tests for the aws_resource_actions callback plugin. ISSUE TYPE Feature Pull Request COMPONENT NAME plugins/callback/aws_resource_actions.py ADDITIONAL INFORMATION Combined with ansible-collections#873 we've got a full set... Reviewed-by: Alina Buzachis <None>
- Loading branch information
1 parent
14f571e
commit 397ca06
Showing
6 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
tests/integration/targets/callback_aws_resource_actions/aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cloud/aws |
6 changes: 6 additions & 0 deletions
6
tests/integration/targets/callback_aws_resource_actions/inventory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
35
tests/integration/targets/callback_aws_resource_actions/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
1 change: 1 addition & 0 deletions
1
tests/integration/targets/callback_aws_resource_actions/meta/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dependencies: [] |
19 changes: 19 additions & 0 deletions
19
tests/integration/targets/callback_aws_resource_actions/runme.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,3 @@ disabled | |
|
||
# Lookup plugins | ||
aws_ssm | ||
|
||
# Callback plugin | ||
aws_resource_actions |