From b1caa3b3c7ad06bd5f1775c8eeb2761a73a55a7b 2020-08-26 16:55:26 From: Branko Majic Date: 2020-08-26 16:55:26 Subject: [PATCH] MAR-150: Refactor the common role tests fixture handling: - Use the cleanup playbook for removing the X.509 generated keys/certificates. - Drop the fixture.yml playbook, and include it inside of prepare playbook (reduce unnecessary nesting). --- diff --git a/roles/common/molecule/default/cleanup.yml b/roles/common/molecule/default/cleanup.yml new file mode 100644 index 0000000000000000000000000000000000000000..c99ee79c29bc84b49f955fbcdf8734cda064bc64 --- /dev/null +++ b/roles/common/molecule/default/cleanup.yml @@ -0,0 +1,15 @@ +--- + +- name: Clean-up fixtures + hosts: localhost + connection: local + gather_facts: false + tasks: + + - name: Remove X.509 material + file: + path: "{{ item }}" + state: absent + with_items: + - "tests/data/x509" + - "tests/data/.gimmecert" diff --git a/roles/common/molecule/default/fixtures.yml b/roles/common/molecule/default/fixtures.yml deleted file mode 100644 index c436e4d7a019cfa5481b344fc900bb0046f60e5f..0000000000000000000000000000000000000000 --- a/roles/common/molecule/default/fixtures.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- - -- hosts: localhost - connection: local - gather_facts: false - - tasks: - - - name: Remove existing X.509 material - file: - path: "tests/data/.gimmecert" - state: absent - - - name: Initialise the CA hierarchy - command: "gimmecert init --ca-hierarchy-depth 2" - args: - creates: "tests/data/.gimmecert" - chdir: "tests/data/" - - - name: Link to the generated X.509 material - file: - src: ".gimmecert" - dest: "tests/data/x509" - state: link diff --git a/roles/common/molecule/default/molecule.yml b/roles/common/molecule/default/molecule.yml index e8157ed81e30c61b4ebfe54b3f062f8786d40431..d8549b13d472505d4e1d4065b7e2316b7b8db2ac 100644 --- a/roles/common/molecule/default/molecule.yml +++ b/roles/common/molecule/default/molecule.yml @@ -49,6 +49,8 @@ platforms: provisioner: name: ansible + playbooks: + cleanup: cleanup.yml config_options: defaults: force_valid_group_names: "ignore" diff --git a/roles/common/molecule/default/prepare.yml b/roles/common/molecule/default/prepare.yml index 855490b8f4750252796bf83f09194aed6d3d111d..44089da739294c1f6f339451f77286e8549250a1 100644 --- a/roles/common/molecule/default/prepare.yml +++ b/roles/common/molecule/default/prepare.yml @@ -1,7 +1,22 @@ --- -- name: Fixtures - import_playbook: fixtures.yml +- name: Set-up fixtures + hosts: localhost + connection: local + gather_facts: false + tasks: + + - name: Initialise CA hierarchy + command: "gimmecert init --ca-hierarchy-depth 2" + args: + creates: "tests/data/.gimmecert" + chdir: "tests/data/" + + - name: Set-up link to generated X.509 material + file: + src: ".gimmecert" + dest: "tests/data/x509" + state: link - name: Prepare hosts: all