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

Remove Python 3.7, 2.x #69

Merged
merged 2 commits into from
Nov 12, 2021
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
4 changes: 0 additions & 4 deletions .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
# - devel
#
#Python versions:
# - Python 2.7
# - Python 3.7
# - Python 3.8

name: CI
Expand All @@ -36,8 +34,6 @@ jobs:
- stable-2.10
- devel
python:
- 2.7
- 3.7
- 3.8
runs-on: ubuntu-latest
steps:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ Configure a remote node with a Conjur identity and Summon:
- hosts: servers
roles:
- role: cyberark.conjur.conjur-host-identity
conjur_appliance_url: 'https://conjur.myorg.com',
conjur_account: 'myorg',
conjur_host_factory_token: "{{ lookup('env', 'HFTOKEN') }}",
conjur_appliance_url: 'https://conjur.myorg.com'
conjur_account: 'myorg'
conjur_host_factory_token: "{{ lookup('env', 'HFTOKEN') }}"
conjur_host_name: "{{ inventory_hostname }}"
conjur_ssl_certificate: "{{ lookup('file', '/path/to/conjur.pem') }}"
conjur_validate_certs: yes
Expand Down
9 changes: 7 additions & 2 deletions ci/test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -x
#!/bin/bash -ex

# Test runner for Ansible Conjur Collection

Expand Down Expand Up @@ -41,7 +41,7 @@ function run_role_test {

# Handles input to dictate wether all tests should be ran, or just one set
function handle_input {
if [[ ! -z ${target} ]]; then
if [[ -n ${target} ]]; then
for test_dir in "${test_directories[@]}"; do
if [[ ${target} == "${test_dir}" ]]; then
run_test ${target}
Expand Down Expand Up @@ -85,6 +85,11 @@ while getopts ahd: option; do
;;
h) help
;;
* )
echo "$1 is not a valid option"
help
exit 1
;;
esac
done

44 changes: 31 additions & 13 deletions roles/conjur_host_identity/tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
FROM ubuntu:18.04
FROM ubuntu:latest

RUN apt-get update && apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common \
python3-pip
ENV DEBIAN_FRONTEND=noninteractive

RUN pip3 install pytest pytest-testinfra ansible && mkdir -p /conjurinc/
WORKDIR /cyberark

# install ansible
RUN apt-get update && \
apt-get install -y ansible

# install python 3
RUN apt-get update && \
apt-get install -y python3-pip && \
pip3 install --upgrade pip==9.0.3

# install ansible and its test tool
RUN pip3 install ansible pytest-testinfra

# install docker installation requirements
RUN apt-get update && \
apt-get install -y apt-transport-https \
ca-certificates \
curl \
software-properties-common

# install docker
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
RUN add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
RUN apt-get update && apt-get -y install docker-ce

RUN apt-get update && \
apt-get -y install docker-ce

# NOTE: Everything above is copied from REPO_ROOT/tests/conjur_variable/Dockerfile. It defines a
# standard container image for running ansible tests

# install ruby
RUN apt-get update && apt-get install -y gcc build-essential
RUN apt-add-repository -y ppa:brightbox/ruby-ng && apt-get update && apt-get install -y ruby2.4 ruby2.4-dev
RUN gem install conjur-cli

WORKDIR /conjurinc/

CMD ["/bin/sleep", "1d"]
2 changes: 1 addition & 1 deletion roles/conjur_host_identity/tests/ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ host_key_checking = False
error_on_undefined_vars = True
timeout = 60
inventory = inventory.tmp
roles_path = /conjurinc
roles_path = /cyberark
remote_tmp = /tmp
9 changes: 7 additions & 2 deletions roles/conjur_host_identity/tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@ services:
build:
context: .
dockerfile: Dockerfile
command: /bin/sleep 1d
environment:
CONJUR_APPLIANCE_URL: http://conjur:3000
CONJUR_ACCOUNT: cucumber
CONJUR_AUTHN_LOGIN: host/ansible/ansible-master
CONJUR_AUTHN_API_KEY: ${ANSIBLE_CONJUR_AUTHN_API_KEY}
CONJUR_CUSTOM_AUTHN_API_KEY: ${CUSTOM_CONJUR_AUTHN_API_KEY}
COMPOSE_PROJECT_NAME: ${COMPOSE_PROJECT_NAME}
# NOTE: Explicitly setting the ANSIBLE_CONFIG envvar avoids Ansible ignoring
# the configuration because it is in a world-writable working directory,
# see https://docs.ansible.com/ansible/latest/reference_appendices/config.html#avoiding-security-risks-with-ansible-cfg-in-the-current-directory.
ANSIBLE_CONFIG: ./ansible.cfg
volumes:
- ..:/conjurinc/cyberark.conjur.conjur-host-identity/
- .:/conjurinc/tests/
- ..:/cyberark/cyberark.conjur.conjur-host-identity/
- .:/cyberark/tests/
- /var/run/docker.sock:/var/run/docker.sock
pg:
image: postgres:9.3
Expand Down
2 changes: 1 addition & 1 deletion roles/conjur_host_identity/tests/inventory-playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
hosts: localhost
tasks:
- name: compile inventory template
template: src=inventory.j2 dest=/conjurinc/tests/inventory.tmp
template: src=inventory.j2 dest=/cyberark/tests/inventory.tmp
27 changes: 16 additions & 11 deletions roles/conjur_host_identity/tests/test.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#!/bin/bash -e
set -x
#!/bin/bash
set -ex

function finish {
function clean {
echo 'Removing test environment'
echo '---'
docker-compose down -v
rm -rf inventory.tmp
}
function finish {
rv=$?
clean || true
exit $rv
}
trap finish EXIT
finish
clean

# normalises project name by filtering non alphanumeric characters and transforming to lowercase
declare -x COMPOSE_PROJECT_NAME
Expand All @@ -22,7 +27,7 @@ declare ansible_cid=''

function api_key_for {
local role_id=$1
if [ ! -z "$role_id" ]
if [ -n "$role_id" ]
then
docker exec ${conjur_cid} rails r "print Credentials['${role_id}'].api_key"
else
Expand All @@ -43,7 +48,7 @@ function setup_conjur {
docker exec ${cli_cid} conjur policy load root /policy/root.yml

# set secret values
docker exec ${cli_cid} bash -c '
docker exec ${cli_cid} bash -ec '
conjur variable values add ansible/target-password target_secret_password
'
}
Expand All @@ -58,13 +63,13 @@ function run_test_cases {
function run_test_case {
echo "---- testing ${test_case} ----"
local test_case=$1
if [ ! -z "$test_case" ]
if [ -n "$test_case" ]
then
docker exec "${ansible_cid}" env HFTOKEN="$(hf_token)" bash -c "
docker exec "${ansible_cid}" env HFTOKEN="$(hf_token)" bash -ec "
cd tests
ansible-playbook test_cases/${test_case}/playbook.yml
"
docker exec "${ansible_cid}" bash -c "
docker exec "${ansible_cid}" bash -ec "
cd tests
py.test --junitxml=./junit/${test_case} --connection docker -v test_cases/${test_case}/tests/test_default.py
"
Expand All @@ -81,7 +86,7 @@ function teardown_and_setup {

function wait_for_server {
# shellcheck disable=SC2016
docker exec "${cli_cid}" bash -c '
docker exec "${cli_cid}" bash -ec '
for i in $( seq 20 ); do
curl -o /dev/null -fs -X OPTIONS ${CONJUR_APPLIANCE_URL} > /dev/null && echo "server is up" && break
echo "."
Expand All @@ -96,7 +101,7 @@ function fetch_ssl_cert {

function generate_inventory {
# uses .j2 template to generate inventory prepended with COMPOSE_PROJECT_NAME
docker-compose exec -T ansible bash -c '
docker-compose exec -T ansible bash -ec '
cd tests
ansible-playbook inventory-playbook.yml
'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Configuring conjur identity on remote hosts
hosts: testapp
roles:
- role: cyberark.conjur.conjur-host-identity
- role: "cyberark.conjur.conjur-host-identity"
conjur_account: cucumber
conjur_appliance_url: "https://conjur-proxy-nginx"
conjur_host_factory_token: "{{lookup('env', 'HFTOKEN')}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import testinfra.utils.ansible_runner

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
'/conjurinc/tests/inventory.tmp').get_hosts('testapp')
'/cyberark/tests/inventory.tmp').get_hosts('testapp')


def test_hosts_file(host):
Expand Down
2 changes: 1 addition & 1 deletion tests/conjur_variable/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function run_test_case {
local test_case=$1
echo "---- testing ${test_case} ----"

if [ ! -n "$test_case" ]; then
if [ -z "$test_case" ]; then
echo ERROR: run_test called with no argument 1>&2
exit 1
fi
Expand Down
10 changes: 10 additions & 0 deletions tests/sanity/ignore-2.13.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Jenkinsfile shebang
tests/conjur_variable/test.sh shebang
tests/conjur_variable/policy/root.yml yamllint:unparsable-with-libyaml # File loaded by Conjur server, not via Python
roles/conjur_host_identity/tests/test.sh shebang
roles/conjur_host_identity/tests/policy/root.yml yamllint:unparsable-with-libyaml # File loaded by Conjur server, not via Python
ci/build_release shebang
ci/parse-changelog.sh shebang
ci/publish_to_galaxy shebang
ci/test.sh shebang
secrets.yml yamllint:unparsable-with-libyaml # File loaded by Summon utility (in Jenkinsfile), not via Python