From a25a3115f21913cecb8f32fce823695407f2bf65 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 21 May 2021 11:23:45 +0200 Subject: [PATCH] Improved tests --- tests/pre.yml | 29 ----------------------------- tests/tasks/pre.yml | 32 ++++++++++++++++++++++++++++++++ tests/test.yml | 5 +++-- tests/vagrant.yml | 5 +++-- tests/vars/main.yml | 7 ++++++- 5 files changed, 44 insertions(+), 34 deletions(-) delete mode 100644 tests/pre.yml create mode 100644 tests/tasks/pre.yml diff --git a/tests/pre.yml b/tests/pre.yml deleted file mode 100644 index 3ba83a3..0000000 --- a/tests/pre.yml +++ /dev/null @@ -1,29 +0,0 @@ -# pre test file ---- -- name: pre | install dependencies - apt: - name: - - openssl - state: "{{ apt_install_state | default('latest') }}" - update_cache: true - cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}" - -- name: pre | generate key - command: > - openssl genrsa -out {{ playbook_dir }}/../files/ca-oefenweb-nl.key 2048; - args: - creates: "{{ playbook_dir }}/../files/ca-oefenweb-nl.key" - become: false - -- name: pre | generate crt - shell: > - openssl req \ - -subj '/C=NL/ST=NH/L=Amsterdam/O=Oefenweb.nl B.V./OU=Systeembeheer/CN=oefenweb.nl/emailAddress=root@oefenweb.nl/' \ - -x509 -new -nodes \ - -key {{ playbook_dir }}/../files/ca-oefenweb-nl.key \ - -days 1 \ - -out {{ playbook_dir }}/../files/ca-oefenweb-nl.crt \ - ; - args: - creates: "{{ playbook_dir }}/../files/ca-oefenweb-nl.crt" - become: false diff --git a/tests/tasks/pre.yml b/tests/tasks/pre.yml new file mode 100644 index 0000000..701f7fa --- /dev/null +++ b/tests/tasks/pre.yml @@ -0,0 +1,32 @@ +# pre test file +--- +- name: install dependencies + apt: + name: + - openssl + state: "{{ apt_install_state | default('latest') }}" + update_cache: true + cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}" + +- block: + + - name: generate key + command: > + openssl genrsa -out {{ ca_certificates_certificate_key_file }} 2048; + args: + creates: "{{ ca_certificates_certificate_key_file }}" + + - name: generate crt + shell: > + openssl req \ + -subj '/C=NL/ST=NH/L=Amsterdam/O=Oefenweb.nl B.V./OU=Systeembeheer/CN=oefenweb.nl/emailAddress=root@oefenweb.nl/' \ + -x509 -new -nodes \ + -key {{ ca_certificates_certificate_key_file }} \ + -days 1 \ + -out {{ ca_certificates_certificate_crt_file }} \ + ; + args: + creates: "{{ ca_certificates_certificate_crt_file }}" + + connection: local + become: false diff --git a/tests/test.yml b/tests/test.yml index 2c5781b..d3837dc 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -5,7 +5,8 @@ become: true pre_tasks: - name: include vars - include_vars: main.yml - - import_tasks: pre.yml + include_vars: "{{ playbook_dir }}/vars/main.yml" + - name: include tasks + include: "{{ playbook_dir }}/tasks/pre.yml" roles: - ../../ diff --git a/tests/vagrant.yml b/tests/vagrant.yml index c64c0c1..dce3560 100644 --- a/tests/vagrant.yml +++ b/tests/vagrant.yml @@ -5,7 +5,8 @@ become: true pre_tasks: - name: include vars - include_vars: main.yml - - import_tasks: pre.yml + include_vars: "{{ playbook_dir }}/vars/main.yml" + - name: include tasks + include: "{{ playbook_dir }}/tasks/pre.yml" roles: - ../../ diff --git a/tests/vars/main.yml b/tests/vars/main.yml index 2df2f57..c2fd962 100644 --- a/tests/vars/main.yml +++ b/tests/vars/main.yml @@ -1,5 +1,10 @@ # vars file --- ca_certificates_certificate_map: - - src: ca-oefenweb-nl.crt + - src: "{{ ca_certificates_certificate_crt_file | basename }}" dest: oefenweb/Oefenweb_nl-B_V.crt + +ca_certificates_certificate_directory: "{{ playbook_dir }}/../files" +ca_certificates_certificate_file: "{{ ca_certificates_certificate_directory }}/ca-oefenweb-nl" +ca_certificates_certificate_key_file: "{{ ca_certificates_certificate_file }}.key" +ca_certificates_certificate_crt_file: "{{ ca_certificates_certificate_file }}.crt"