From a89823666a5e0dd041e76a7560896d540528e8b9 Mon Sep 17 00:00:00 2001 From: Ted Cook Date: Thu, 2 Nov 2023 22:33:25 -0600 Subject: [PATCH] Add verification play --- molecule/common/verify.yml | 40 +++++++++++++++++++++++++++++++++++ molecule/default/molecule.yml | 8 +++---- molecule/elastic/molecule.yml | 8 +++---- 3 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 molecule/common/verify.yml diff --git a/molecule/common/verify.yml b/molecule/common/verify.yml new file mode 100644 index 0000000..150a0c2 --- /dev/null +++ b/molecule/common/verify.yml @@ -0,0 +1,40 @@ +--- +- name: Verify + hosts: all + tasks: + - name: Collect package facts + ansible.builtin.package_facts: + + - name: Verify package deployment + ansible.builtin.fail: + msg: "Package {{ _package }} was not deployed" + vars: + _package: heartbeat-elastic + when: _package not in packages + + - name: Collect service facts + ansible.builtin.service_facts: + + - name: Verify service run state + ansible.builtin.fail: + msg: "Service {{ _service }} is not running" + vars: + _service: heartbeat-elastic.service + when: services[_service].state != "running" + + - name: Verify service boot state + ansible.builtin.fail: + msg: "Service {{ _service }} is not enabled" + vars: + _service: heartbeat-elastic.service + when: services[_service].status != "enabled" + + - name: Stat output filename + ansible.builtin.stat: + path: "{{ heartbeat_conf.output.file.path }}/{{ heartbeat_conf.output.file.filename }}" + register: _output_file + + - name: Verify output file + ansible.builtin.fail: + msg: "Output file {{ heartbeat_conf.output.file.filename}} not found" + when: not _output_file.stat.exists diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 6a98ebf..aaf10e4 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -36,9 +36,9 @@ provisioner: schedule: '*/1 * * * * * *' urls: - https://www.google.com - output: - elasticsearch: - hosts: - - "localhost:9200" + output: + file: + path: /tmp + filename: heartbeat verifier: name: ansible diff --git a/molecule/elastic/molecule.yml b/molecule/elastic/molecule.yml index fed55c7..28ae644 100644 --- a/molecule/elastic/molecule.yml +++ b/molecule/elastic/molecule.yml @@ -38,9 +38,9 @@ provisioner: schedule: '*/1 * * * * * *' urls: - https://www.google.com - output: - elasticsearch: - hosts: - - "localhost:9200" + output: + file: + path: /tmp + filename: heartbeat verifier: name: ansible