feat(pihole): add the pihole role #372

Merged
Defame1297 merged 10 commits from feat/pihole-role into main 2026-11-25 19:37:22 +00:00
2 changed files with 38 additions and 1 deletions
Showing only changes of commit 71ae86dc61 - Show all commits

No files matched your search

+1 -1
View File
@@ -63,7 +63,7 @@ verifier:
scenario:
# molecule's default sequence minus both destroys (scripts/run_molecule_scenarios.sh removes the
# containers as soon as this scenario ends; after a local run, run `molecule destroy` yourself),
# with a check run before the converge (first-run preview) and after the idempotence run.
# plus two check steps: one before the converge (first-run preview), one after the idempotence run.
test_sequence:
- dependency
- cleanup
+37
View File
@@ -16,6 +16,13 @@
- name: Verify
hosts: all
gather_facts: true
# The role defaults, for the clone path and version the converge used: the scenario overrides
# neither, so the override falls back to them. Only the leaves read below are templated.
vars_files:
- ../../defaults/main.yml
vars:
pihole_test_repo_path: "{{ pihole_test_overrides.repo.path | default(pihole_default.repo.path) }}"
pihole_test_repo_version: "{{ pihole_test_overrides.repo.version | default(pihole_default.repo.version) }}"
tasks:
- name: Read the rendered pihole.toml
ansible.builtin.slurp:
@@ -27,6 +34,18 @@
path: /etc/pihole/pihole.toml
register: pihole_test_toml_stat
- name: Stat the configuration directory
ansible.builtin.stat:
path: /etc/pihole
register: pihole_test_config_dir
# The git module only checks out; it cannot report which tag HEAD is at.
- name: Read the tag the clone is checked out at
ansible.builtin.command: # noqa: command-instead-of-module
cmd: git -C {{ pihole_test_repo_path | quote }} describe --tags --exact-match HEAD
register: pihole_test_clone_tag
changed_when: false
- name: Read the stub installer log
ansible.builtin.slurp:
src: /var/log/pihole-stub-installer.log
@@ -55,9 +74,27 @@
ansible.builtin.assert:
that:
- pihole_test_toml_stat.stat.pw_name == 'pihole'
- pihole_test_toml_stat.stat.gr_name == 'pihole'
- pihole_test_toml_stat.stat.mode == '0664'
quiet: true
- name: The configuration directory belongs to the pihole user and group, mode 0755
ansible.builtin.assert:
that:
- pihole_test_config_dir.stat.isdir
- pihole_test_config_dir.stat.pw_name == 'pihole'
- pihole_test_config_dir.stat.gr_name == 'pihole'
- pihole_test_config_dir.stat.mode == '0755'
quiet: true
# The stub repository tags its only commit with the default repo.version (prepare.yml).
- name: The clone is checked out at the configured version
ansible.builtin.assert:
that:
- pihole_test_clone_tag.stdout == pihole_test_repo_version
fail_msg: "Clone at {{ pihole_test_clone_tag.stdout }}, expected {{ pihole_test_repo_version }}"
quiet: true
- name: The user is a system account without a login shell
ansible.builtin.assert:
that: