From 674c959c97d46183a5383c15aaa77b7bd9702698 Mon Sep 17 00:00:00 2001 From: Bertrand Lanson Date: Tue, 6 Jun 2023 20:37:24 +0200 Subject: [PATCH] added scenario #2 --- molecule/default/verify.yml | 29 +++++++++++++++++++ molecule/with_extra_sidecars/verify.yml | 37 +++++++++++++++++++++++-- tasks/configure.yml | 1 + 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index 4406898..40a9603 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -54,6 +54,35 @@ - stat_opt_adguard_data.stat.gr_name == 'root' - stat_opt_adguard_data.stat.mode == '0755' + - name: "Test: service adguard" + block: + - name: "Get service adguard" + ansible.builtin.service_facts: + + - name: "Stat file /etc/systemd/system/adguard.service" + ansible.builtin.stat: + path: "/etc/systemd/system/adguard.service" + register: stat_etc_systemd_system_adguard_service + + - name: "Slurp file /etc/systemd/system/adguard.service" + ansible.builtin.slurp: + src: "/etc/systemd/system/adguard.service" + register: slurp_etc_systemd_system_adguard_service + + - name: "Verify service consul" + ansible.builtin.assert: + that: + - stat_etc_systemd_system_adguard_service.stat.exists + - stat_etc_systemd_system_adguard_service.stat.isreg + - stat_etc_systemd_system_adguard_service.stat.pw_name == 'root' + - stat_etc_systemd_system_adguard_service.stat.gr_name == 'root' + - stat_etc_systemd_system_adguard_service.stat.mode == '0644' + - slurp_etc_systemd_system_adguard_service.content != '' + - ansible_facts.services['adguard.service'] is defined + - ansible_facts.services['adguard.service']['source'] == 'systemd' + - ansible_facts.services['adguard.service']['state'] == 'inactive' + - ansible_facts.services['adguard.service']['status'] == 'enabled' + - name: "Test: file /opt/adguard/docker-compose.yml" block: - name: "Slurp file /opt/adguard/docker-compose.yml" diff --git a/molecule/with_extra_sidecars/verify.yml b/molecule/with_extra_sidecars/verify.yml index 4406898..76b7b9a 100644 --- a/molecule/with_extra_sidecars/verify.yml +++ b/molecule/with_extra_sidecars/verify.yml @@ -54,6 +54,35 @@ - stat_opt_adguard_data.stat.gr_name == 'root' - stat_opt_adguard_data.stat.mode == '0755' + - name: "Test: service adguard" + block: + - name: "Get service adguard" + ansible.builtin.service_facts: + + - name: "Stat file /etc/systemd/system/adguard.service" + ansible.builtin.stat: + path: "/etc/systemd/system/adguard.service" + register: stat_etc_systemd_system_adguard_service + + - name: "Slurp file /etc/systemd/system/adguard.service" + ansible.builtin.slurp: + src: "/etc/systemd/system/adguard.service" + register: slurp_etc_systemd_system_adguard_service + + - name: "Verify service consul" + ansible.builtin.assert: + that: + - stat_etc_systemd_system_adguard_service.stat.exists + - stat_etc_systemd_system_adguard_service.stat.isreg + - stat_etc_systemd_system_adguard_service.stat.pw_name == 'root' + - stat_etc_systemd_system_adguard_service.stat.gr_name == 'root' + - stat_etc_systemd_system_adguard_service.stat.mode == '0644' + - slurp_etc_systemd_system_adguard_service.content != '' + - ansible_facts.services['adguard.service'] is defined + - ansible_facts.services['adguard.service']['source'] == 'systemd' + - ansible_facts.services['adguard.service']['state'] == 'stopped' + - ansible_facts.services['adguard.service']['status'] == 'enabled' + - name: "Test: file /opt/adguard/docker-compose.yml" block: - name: "Slurp file /opt/adguard/docker-compose.yml" @@ -72,13 +101,17 @@ - opt_adguard_docker_compose_yml_json['version'] is defined - opt_adguard_docker_compose_yml_json['version'] == '3.9' - opt_adguard_docker_compose_yml_json['services'] is defined - - opt_adguard_docker_compose_yml_json['services']|length == 1 + - opt_adguard_docker_compose_yml_json['services']|length == 3 + - opt_adguard_docker_compose_yml_json['services']['keepalived'] is defined + - opt_adguard_docker_compose_yml_json['services']['keepalived']['image'] == 'ghcr.io/rmartin16/keepalived:latest' - opt_adguard_docker_compose_yml_json['services']['adguard'] is defined - opt_adguard_docker_compose_yml_json['services']['adguard']['image'] == 'adguard/adguardhome:latest' + - opt_adguard_docker_compose_yml_json['services']['node_exporter'] is defined + - opt_adguard_docker_compose_yml_json['services']['node_exporter']['image'] == 'ebrianne/adguard-exporter:latest' - opt_adguard_docker_compose_yml_json['networks'] is defined - opt_adguard_docker_compose_yml_json['networks']|length == 1 - opt_adguard_docker_compose_yml_json['volumes'] is defined - opt_adguard_docker_compose_yml_json['volumes']|length == 2 - opt_adguard_docker_compose_yml_json['volumes']['conf'] is defined - opt_adguard_docker_compose_yml_json['volumes']['data'] is defined - - opt_adguard_docker_compose_yml_json['secrets'] is not defined + - opt_adguard_docker_compose_yml_json['secrets'] is defined diff --git a/tasks/configure.yml b/tasks/configure.yml index 2cfc757..af28979 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -20,6 +20,7 @@ group: root mode: '0600' notify: + - systemctl-enable-adguard - systemctl-restart-adguard - name: "Create password file for node-exporter"