From 11702792f39704236561ca29af43105bb4121842 Mon Sep 17 00:00:00 2001 From: Bertrand Lanson Date: Fri, 26 May 2023 22:19:56 +0200 Subject: [PATCH] added default test for container health --- molecule/default/verify.yml | 16 +++++++++++++++- molecule/with_custom_ca/verify.yml | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index 29b6c1d..47a9f72 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -1,9 +1,23 @@ --- -# This is an example playbook to execute Ansible tests. - name: Verify hosts: all gather_facts: false tasks: + - name: "Test: file /etc/hosts" + block: + - name: "Stat file /etc/hosts" + ansible.builtin.stat: + path: "/etc/hosts" + register: stat_etc_hosts + + - name: "Verify file /etc/hosts" + ansible.builtin.assert: + that: + - stat_etc_hosts.stat.exists + - stat_etc_hosts.stat.isreg + - stat_etc_hosts.stat.pw_name == 'root' + - stat_etc_hosts.stat.gr_name == 'root' + - name: "Test: directory /usr/local/share/ca-certificates" block: - name: "Stat directory /usr/local/share/ca-certificates" diff --git a/molecule/with_custom_ca/verify.yml b/molecule/with_custom_ca/verify.yml index 4a028a6..977fce5 100644 --- a/molecule/with_custom_ca/verify.yml +++ b/molecule/with_custom_ca/verify.yml @@ -1,9 +1,23 @@ --- -# This is an example playbook to execute Ansible tests. - name: Verify hosts: all gather_facts: false tasks: + - name: "Test: file /etc/hosts" + block: + - name: "Stat file /etc/hosts" + ansible.builtin.stat: + path: "/etc/hosts" + register: stat_etc_hosts + + - name: "Verify file /etc/hosts" + ansible.builtin.assert: + that: + - stat_etc_hosts.stat.exists + - stat_etc_hosts.stat.isreg + - stat_etc_hosts.stat.pw_name == 'root' + - stat_etc_hosts.stat.gr_name == 'root' + - name: "Test: directory /usr/local/share/ca-certificates" block: - name: "Stat directory /usr/local/share/ca-certificates"