-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[PR #1657/34e073d5 backport][stable-5] SSM connection plugin - Add encryption tests This is a backport of PR #1657 as merged into main (34e073d). Depends-On: ansible/ansible-zuul-jobs#1746 SUMMARY Expand on the aws_ssm connection integration tests Follow up on suggestion to use ssm_parameter to locate AMIs Add tests for connection using encrypted buckets ISSUE TYPE Feature Pull Request COMPONENT NAME aws_ssm ADDITIONAL INFORMATION Reviewed-by: Markus Bergholz <[email protected]>
- Loading branch information
1 parent
7dc4f32
commit b642edf
Showing
14 changed files
with
134 additions
and
26 deletions.
There are no files selected for viewing
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,2 @@ | ||
trivial: | ||
- aws_ssm - add initial integration tests for encrypted aws_ssm connections |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
time=10m | ||
time=20m | ||
|
||
cloud/aws | ||
connection_aws_ssm |
4 changes: 4 additions & 0 deletions
4
tests/integration/targets/connection_aws_ssm_encrypted_s3/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,4 @@ | ||
time=20m | ||
|
||
cloud/aws | ||
connection_aws_ssm |
6 changes: 6 additions & 0 deletions
6
tests/integration/targets/connection_aws_ssm_encrypted_s3/aws_ssm_integration_test_setup.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,6 @@ | ||
- hosts: localhost | ||
roles: | ||
- role: ../setup_connection_aws_ssm | ||
vars: | ||
target_os: fedora | ||
encrypted_bucket: True |
5 changes: 5 additions & 0 deletions
5
...integration/targets/connection_aws_ssm_encrypted_s3/aws_ssm_integration_test_teardown.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,5 @@ | ||
- hosts: localhost | ||
tasks: | ||
- include_role: | ||
name: ../setup_connection_aws_ssm | ||
tasks_from: cleanup.yml |
3 changes: 3 additions & 0 deletions
3
tests/integration/targets/connection_aws_ssm_encrypted_s3/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,3 @@ | ||
dependencies: | ||
- connection | ||
- setup_connection_aws_ssm |
31 changes: 31 additions & 0 deletions
31
tests/integration/targets/connection_aws_ssm_encrypted_s3/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,31 @@ | ||
#!/usr/bin/env bash | ||
|
||
PLAYBOOK_DIR=$(pwd) | ||
set -eux | ||
|
||
CMD_ARGS=("$@") | ||
|
||
# Destroy Environment | ||
cleanup() { | ||
|
||
cd "${PLAYBOOK_DIR}" | ||
ansible-playbook -c local aws_ssm_integration_test_teardown.yml "${CMD_ARGS[@]}" | ||
|
||
} | ||
|
||
trap "cleanup" EXIT | ||
|
||
# Setup Environment | ||
ansible-playbook -c local aws_ssm_integration_test_setup.yml "$@" | ||
|
||
# Export the AWS Keys | ||
set +x | ||
. ./aws-env-vars.sh | ||
set -x | ||
|
||
cd ../connection | ||
|
||
# Execute Integration tests | ||
INVENTORY="${PLAYBOOK_DIR}/ssm_inventory" ./test.sh \ | ||
-e target_hosts=aws_ssm \ | ||
"$@" |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
time=10m | ||
time=20m | ||
|
||
cloud/aws | ||
connection_aws_ssm |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
time=10m | ||
time=20m | ||
|
||
cloud/aws | ||
connection_aws_ssm |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
time=10m | ||
time=20m | ||
|
||
unstable | ||
cloud/aws | ||
|
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
40 changes: 40 additions & 0 deletions
40
tests/integration/targets/setup_connection_aws_ssm/tasks/encryption.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,40 @@ | ||
--- | ||
## Task file for setup/teardown AWS resources for aws_ssm integration testing | ||
- name: create a KMS key | ||
aws_kms: | ||
alias: '{{ kms_key_name }}' | ||
grants: | ||
- name: SSM-Agent-Access | ||
grantee_principal: '{{ role_output.iam_role.arn }}' | ||
retiring_principal: '{{ aws_caller_info.arn }}' | ||
operations: | ||
- Decrypt | ||
- Encrypt | ||
- GenerateDataKey | ||
- GenerateDataKeyWithoutPlaintext | ||
- DescribeKey | ||
- Verify | ||
- Sign | ||
- RetireGrant | ||
- name: Ansible-Test-Access | ||
grantee_principal: '{{ aws_caller_info.arn }}' | ||
retiring_principal: '{{ aws_caller_info.arn }}' | ||
operations: | ||
- Decrypt | ||
- Encrypt | ||
- GenerateDataKey | ||
- GenerateDataKeyWithoutPlaintext | ||
- DescribeKey | ||
- Verify | ||
- Sign | ||
- RetireGrant | ||
tags: | ||
ansible-test: '{{ resource_prefix }}-connection-ssm' | ||
|
||
# Note: This bucket will **NOT** be deleted, there are some nasty gotchas with the time it takes | ||
# to properly enable encryption so we have a permanant bucket which is automatically emptied | ||
- name: Ensure encrypted bucket exists | ||
s3_bucket: | ||
name: "{{ encrypted_s3_bucket_name }}" | ||
when: | ||
- encrypted_bucket | default(False) |
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
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