From 23e366f8df1d946fd2427c28414e61cdf902e7dc Mon Sep 17 00:00:00 2001 From: Bertrand Lanson Date: Mon, 12 Jun 2023 23:27:00 +0200 Subject: [PATCH] start moving to ansible for testing to replace testinfra --- molecule/default/verify.yml | 19 +++++++++++++++++++ molecule/with_custom_packages/verify.yml | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 molecule/default/verify.yml create mode 100644 molecule/with_custom_packages/verify.yml diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml new file mode 100644 index 0000000..bf52da2 --- /dev/null +++ b/molecule/default/verify.yml @@ -0,0 +1,19 @@ +--- +- 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' diff --git a/molecule/with_custom_packages/verify.yml b/molecule/with_custom_packages/verify.yml new file mode 100644 index 0000000..bf52da2 --- /dev/null +++ b/molecule/with_custom_packages/verify.yml @@ -0,0 +1,19 @@ +--- +- 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'