started doing tests in ansible since testinfra is being deprecated

This commit is contained in:
Bertrand Lanson 2023-05-23 22:20:19 +02:00
parent 5c45d27b16
commit 8eb8c69c49
6 changed files with 76 additions and 3 deletions

View File

@ -1,5 +1,3 @@
---
# defaults file for import_vault_root_ca
import_vault_root_ca_certificate_list:
- url: "https://openstack01.ednz.fr:8200/v1/ednz-root-ca/ca"
cert_name: "ednz_ca"
import_vault_root_ca_certificate_list: {}

View File

@ -0,0 +1,7 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include ednxzu.import_vault_root_ca"
ansible.builtin.include_role:
name: "ednxzu.import_vault_root_ca"

View File

@ -0,0 +1,4 @@
---
import_vault_root_ca_certificate_list:
- url: "https://openstack01.ednz.fr:8200/v1/ednz-root-ca/ca"
cert_name: "ednz_ca"

View File

@ -0,0 +1,37 @@
---
dependency:
name: galaxy
options:
requirements-file: ./requirements.yml
driver:
name: docker
platforms:
- name: instance
image: geerlingguy/docker-${MOLECULE_TEST_OS}-ansible
command: ""
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup
cgroupns_mode: host
privileged: true
pre_build_image: true
provisioner:
name: ansible
config_options:
defaults:
remote_tmp: /tmp/.ansible
verifier:
name: ansible
scenario:
name: with_custom_ca
test_sequence:
- dependency
- cleanup
- destroy
- syntax
- create
- prepare
- converge
- idempotence
- verify
- cleanup
- destroy

View File

@ -0,0 +1,3 @@
---
# requirements file for molecule
roles: []

View File

@ -0,0 +1,24 @@
---
# This is an example playbook to execute Ansible tests.
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: "Test: directory /usr/local/share/ca-certificates"
block:
- name: "Stat directory /usr/local/share/ca-certificates"
ansible.builtin.stat:
path: "/usr/local/share/ca-certificates"
register: usr_local_share_ca_certificates
- name: "Verify directory {{ import_vault_root_ca_cert_dir }}"
ansible.builtin.assert:
that:
- usr_local_share_ca_certificates.stat.exists
- usr_local_share_ca_certificates.stat.isdir
- usr_local_share_ca_certificates.stat.pw_name == 'root'
- usr_local_share_ca_certificates.stat.gr_name == 'root'
- usr_local_share_ca_certificates.stat.mode == '0755'
- name: "Get certificate information"