added scenario #2

This commit is contained in:
Bertrand Lanson 2023-06-06 20:37:24 +02:00
parent 281d654bca
commit 674c959c97
3 changed files with 65 additions and 2 deletions

View File

@ -54,6 +54,35 @@
- stat_opt_adguard_data.stat.gr_name == 'root' - stat_opt_adguard_data.stat.gr_name == 'root'
- stat_opt_adguard_data.stat.mode == '0755' - 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" - name: "Test: file /opt/adguard/docker-compose.yml"
block: block:
- name: "Slurp file /opt/adguard/docker-compose.yml" - name: "Slurp file /opt/adguard/docker-compose.yml"

View File

@ -54,6 +54,35 @@
- stat_opt_adguard_data.stat.gr_name == 'root' - stat_opt_adguard_data.stat.gr_name == 'root'
- stat_opt_adguard_data.stat.mode == '0755' - 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" - name: "Test: file /opt/adguard/docker-compose.yml"
block: block:
- name: "Slurp file /opt/adguard/docker-compose.yml" - 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'] is defined
- opt_adguard_docker_compose_yml_json['version'] == '3.9' - 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'] 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'] is defined
- opt_adguard_docker_compose_yml_json['services']['adguard']['image'] == 'adguard/adguardhome:latest' - 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'] is defined
- opt_adguard_docker_compose_yml_json['networks']|length == 1 - 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'] is defined
- opt_adguard_docker_compose_yml_json['volumes']|length == 2 - 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']['conf'] is defined
- opt_adguard_docker_compose_yml_json['volumes']['data'] 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

View File

@ -20,6 +20,7 @@
group: root group: root
mode: '0600' mode: '0600'
notify: notify:
- systemctl-enable-adguard
- systemctl-restart-adguard - systemctl-restart-adguard
- name: "Create password file for node-exporter" - name: "Create password file for node-exporter"