forked from CCCHH/ansible-infra
Vendor Galaxy Roles and Collections
This commit is contained in:
parent
c1e1897cda
commit
2aed20393f
85 changed files with 387444 additions and 2 deletions
5
ansible_collections/community/sops/tests/integration/targets/vars_sops/.gitignore
vendored
Normal file
5
ansible_collections/community/sops/tests/integration/targets/vars_sops/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
*/out
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
creation_rules:
|
||||
- pgp: FBC7B9E2A4F9289AC0C1D4843D16CEE4A27381B4
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<!--
|
||||
Copyright (c) Ansible Project
|
||||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
-->
|
||||
|
||||
## How the tests work
|
||||
|
||||
`ansible-test integration --docker ubuntu1804 -v var_sops` essentially executes `runme.sh`. That script does:
|
||||
|
||||
1. Make sure it isn't run for Ansible 2.9 (which does not support vars plugins);
|
||||
2. Use the `setup.yml` playbook to install the requirements (sops);
|
||||
3. Look at all subdirectories called `test-*`, and for each of them:
|
||||
1. Execute the playbook `playbook.yml` in it;
|
||||
2. Call `validate.sh` in it with parameters `<exit_code> <path_to_captured_output>`;
|
||||
3. If `validate.sh` exists with an exit code not equal to 0, the test has failed.
|
||||
|
||||
## Adding more tests
|
||||
|
||||
If possible, extend an existing test. If that's not possible, or if you are afraid to pollute one's test environment with more data, create a new one:
|
||||
|
||||
1. Create a subdirectory `test-<name_of_your_test>`;
|
||||
2. Create a `playbook.yml` and `validate.sh` in there (copy from a similar test and adjust);
|
||||
3. Create subdirectories `group_vars` and/or `host_vars` and fill them as needed.
|
||||
|
||||
For creating sops encrypted files, use the private GPG keys from https://raw.githubusercontent.com/getsops/sops/master/pgp/sops_functional_tests_key.asc. There is a `.sops.yaml` file in this directory which makes sure that sops automatically uses the correct one of the keys provided in that file.
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
gha/main
|
||||
skip/aix
|
||||
skip/osx
|
||||
skip/freebsd
|
||||
skip/python2.6 # lookups are controller only, and we no longer support Python 2.6 on the controller
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
dependencies:
|
||||
- setup_sops
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
set -eux
|
||||
|
||||
if [ "$(command -v sops)" == "" ]; then
|
||||
echo "sops is not installed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "First parameter must be test name, second parameter the SOPS version!"
|
||||
exit 1
|
||||
fi
|
||||
TEST="$1"
|
||||
SOPS_VERSION="$2"
|
||||
|
||||
if [ -e "${TEST}/min-version" ]; then
|
||||
MIN_VERSION="$(cat "${TEST}/min-version")"
|
||||
if [ "$(echo -e "${SOPS_VERSION}\n${MIN_VERSION}" | sort -V | head -1)" != "${MIN_VERSION}" ]; then
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
if [ -e "${TEST}/max-version" ]; then
|
||||
MAX_VERSION="$(cat "${TEST}/max-version")"
|
||||
if [ "$(echo -e "${SOPS_VERSION}\n${MAX_VERSION}" | sort -V | head -1)" != "${SOPS_VERSION}" ]; then
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
shift 2
|
||||
|
||||
(
|
||||
cd "${TEST}"
|
||||
if [ -x "setup.sh" ]; then
|
||||
./setup.sh
|
||||
fi
|
||||
if [ -x "run.sh" ]; then
|
||||
ANSIBLE_VARS_ENABLED=host_group_vars,community.sops.sops ./run.sh "$@" 2>&1 | tee out
|
||||
RESULT=${PIPESTATUS[0]}
|
||||
else
|
||||
ANSIBLE_VARS_ENABLED=host_group_vars,community.sops.sops ansible-playbook playbook.yml -i hosts -v "$@" 2>&1 | tee out
|
||||
RESULT=${PIPESTATUS[0]}
|
||||
fi
|
||||
./validate.sh "${RESULT}" out
|
||||
)
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
set -eux
|
||||
|
||||
if [ "$(command -v sops)" == "" ]; then
|
||||
echo "sops is not installed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get hold of SOPS version
|
||||
set +e
|
||||
SOPS_VERSION_RAW="$(sops --version --disable-version-check)" || SOPS_VERSION_RAW="$(sops --version)"
|
||||
set -e
|
||||
SOPS_VERSION="$(echo "${SOPS_VERSION_RAW}" | sed -E 's/^sops ([0-9.]+).*/\1/g')"
|
||||
|
||||
# Run all tests
|
||||
for TEST in $(find . -maxdepth 1 -type d -name 'test-*' | sort); do
|
||||
./run-test.sh "${TEST}" "${SOPS_VERSION}" "$@"
|
||||
done
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
set -eux
|
||||
|
||||
# Install sops
|
||||
ANSIBLE_ROLES_PATH=.. ansible-playbook setup.yml
|
||||
|
||||
if [ "$(command -v sops)" == "" ]; then
|
||||
# sops was not installed
|
||||
exit
|
||||
fi
|
||||
|
||||
./run-tests.sh
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Setup sops
|
||||
import_role:
|
||||
name: setup_sops
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
this-is-not: a sops file
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
[all]
|
||||
localhost ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}"
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- hosts: localhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Make sure group_vars/all.sops.yaml was found
|
||||
debug:
|
||||
msg: '{{ foo }}'
|
||||
- name: Make sure group_vars/all/test.sops.yaml was found
|
||||
debug:
|
||||
msg: '{{ bar }}'
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
set -e
|
||||
ANSIBLE_VARS_SOPS_PLUGIN_HANDLE_UNENCRYPTED_FILES=error \
|
||||
ansible-playbook playbook.yml -i hosts -v "$@"
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
set -eux
|
||||
|
||||
if [ "$1" != 4 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
( grep -F "ERROR! error with file" "$2" && grep "sops metadata not found" "$2" ) || ( grep -F "[ERROR]: error with file" "$2" && grep "sops metadata not found" "$2" ) || ( grep -F "ERROR! SOPS vars plugin: file" "$2" && grep "is not encrypted" "$2" ) || ( grep -F "[ERROR]: SOPS vars plugin: file" "$2" && grep "is not encrypted" "$2" )
|
||||
( grep -vF "[WARNING]: SOPS vars plugin: skipping unencrypted file" "$2" )
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
this-is-not: a sops file
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
[all]
|
||||
localhost ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}"
|
||||
|
|
@ -0,0 +1 @@
|
|||
3.9.0
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- hosts: localhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Make sure group_vars/all.sops.yaml was found
|
||||
debug:
|
||||
msg: '{{ foo }}'
|
||||
- name: Make sure group_vars/all/test.sops.yaml was found
|
||||
debug:
|
||||
msg: '{{ bar }}'
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
set -e
|
||||
ANSIBLE_VARS_SOPS_PLUGIN_HANDLE_UNENCRYPTED_FILES=skip \
|
||||
ansible-playbook playbook.yml -i hosts -v "$@"
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue