diff --git a/roles/conjur_host_identity/tests/Dockerfile b/roles/conjur_host_identity/tests/Dockerfile index df27086f..d26ebb5e 100644 --- a/roles/conjur_host_identity/tests/Dockerfile +++ b/roles/conjur_host_identity/tests/Dockerfile @@ -40,3 +40,7 @@ RUN apt-get update && \ 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 + +# install Ansible Conjur Collection +RUN ansible-galaxy collection install cyberark.conjur && \ + ansible-galaxy install cyberark.conjur-host-identity diff --git a/roles/conjur_host_identity/tests/ansible.cfg b/roles/conjur_host_identity/tests/ansible.cfg index 5b1d8246..99066677 100644 --- a/roles/conjur_host_identity/tests/ansible.cfg +++ b/roles/conjur_host_identity/tests/ansible.cfg @@ -3,5 +3,4 @@ host_key_checking = False error_on_undefined_vars = True timeout = 60 inventory = inventory.tmp -roles_path = /cyberark remote_tmp = /tmp diff --git a/roles/conjur_host_identity/tests/docker-compose.yml b/roles/conjur_host_identity/tests/docker-compose.yml index 7fc96f50..6e91614f 100644 --- a/roles/conjur_host_identity/tests/docker-compose.yml +++ b/roles/conjur_host_identity/tests/docker-compose.yml @@ -17,9 +17,9 @@ services: # 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: - - ..:/cyberark/cyberark.conjur.conjur-host-identity/ - .:/cyberark/tests/ - /var/run/docker.sock:/var/run/docker.sock + pg: image: postgres:9.3 diff --git a/roles/conjur_host_identity/tests/test.sh b/roles/conjur_host_identity/tests/test.sh index 45d50c6d..70b54e5f 100755 --- a/roles/conjur_host_identity/tests/test.sh +++ b/roles/conjur_host_identity/tests/test.sh @@ -55,8 +55,10 @@ function setup_conjur { function run_test_cases { for test_case in test_cases/*; do - teardown_and_setup - run_test_case "$(basename -- "$test_case")" + if [ "${test_case}" != "test_cases/common" ]; then + teardown_and_setup + run_test_case "$(basename -- "$test_case")" + fi done } @@ -71,7 +73,7 @@ function run_test_case { " 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 + py.test --junitxml=./junit/${test_case} --connection docker -v test_cases/common/test_default.py " else echo ERROR: run_test called with no argument 1>&2 diff --git a/roles/conjur_host_identity/tests/test_cases/configure-conjur-identity/tests/test_default.py b/roles/conjur_host_identity/tests/test_cases/common/test_default.py similarity index 100% rename from roles/conjur_host_identity/tests/test_cases/configure-conjur-identity/tests/test_default.py rename to roles/conjur_host_identity/tests/test_cases/common/test_default.py diff --git a/roles/conjur_host_identity/tests/test_cases/configure-conjur-identity/playbook.yml b/roles/conjur_host_identity/tests/test_cases/configure-conjur-identity-from-collection/playbook.yml similarity index 88% rename from roles/conjur_host_identity/tests/test_cases/configure-conjur-identity/playbook.yml rename to roles/conjur_host_identity/tests/test_cases/configure-conjur-identity-from-collection/playbook.yml index 6972b50e..556d71f5 100644 --- a/roles/conjur_host_identity/tests/test_cases/configure-conjur-identity/playbook.yml +++ b/roles/conjur_host_identity/tests/test_cases/configure-conjur-identity-from-collection/playbook.yml @@ -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')}}" diff --git a/roles/conjur_host_identity/tests/test_cases/configure-conjur-identity-from-role/playbook.yml b/roles/conjur_host_identity/tests/test_cases/configure-conjur-identity-from-role/playbook.yml new file mode 100644 index 00000000..fdbb777c --- /dev/null +++ b/roles/conjur_host_identity/tests/test_cases/configure-conjur-identity-from-role/playbook.yml @@ -0,0 +1,11 @@ +--- +- name: Configuring conjur identity on remote hosts from Role + hosts: testapp + roles: + - role: cyberark.conjur-host-identity + conjur_account: cucumber + conjur_appliance_url: "https://conjur-proxy-nginx" + conjur_host_factory_token: "{{lookup('env', 'HFTOKEN')}}" + conjur_host_name: "conjur_{{ ansible_hostname }}" + conjur_ssl_certificate: "{{lookup('file', '../../conjur.pem')}}" + conjur_validate_certs: yes