Files
Kamino/roles/pihole/tasks/validate.yml
T
Defame1297 66628635b9 feat(pihole): add the pihole role
Installs Pi-hole v6 on Ubuntu noble and resolute by cloning the
upstream repository and running its installer unattended, with
pihole.toml rendered from pihole_default merged with pihole_overrides.
A change to pihole.toml runs the installer's reconfigure mode.

Validation runs first under always: the host must be Ubuntu, and the
merged settings need a non-empty interface and upstream list and a
string password other than the placeholder. pihole_web_password is a
required no_log input. Computed values are internal __pihole_ names.

Derived from codeberg.org/ansible/pihole (GPL-3.0-only) with Pi-hole
FTL comment text (EUPL-1.2): REUSE.toml annotations, the EUPL-1.2
text and NOTICE entries record both. The README roadmap drops pihole.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-25 18:10:59 +00:00

56 lines
2.5 KiB
YAML

---
# Input checks. Imported first in main.yml with tags: always, so a bad input fails before any
# change. pihole_web_password is required by the argument spec, which runs before this file.
# The role also reads gathered facts (ansible_env.HOME, ansible_user_id), so a run without
# them fails here too.
- name: Require Ubuntu
ansible.builtin.assert:
that:
- ansible_facts['distribution'] | default('') == 'Ubuntu'
fail_msg: >-
pihole supports Ubuntu only (found: {{ ansible_facts['distribution'] | default('no gathered facts') }}).
The role reads gathered facts, so run it in a play that gathers them.
quiet: true
# The merge is computed here as well as in merge-defaults.yml, so these checks run before
# anything else, on every tag selection.
- name: Check the merged Pi-hole settings
vars:
__pihole_candidate: "{{ pihole_default | combine(pihole_overrides | default({}), recursive=True) }}"
block:
- name: Check that at least one upstream DNS server is defined
ansible.builtin.assert:
that:
- __pihole_candidate.config.dns.upstreams is defined
- __pihole_candidate.config.dns.upstreams | length > 0
fail_msg: pihole_overrides.config.dns.upstreams must be a non-empty list of upstream DNS servers.
quiet: true
- name: Check that the DNS interface is set
ansible.builtin.assert:
that:
- __pihole_candidate.config.dns.interface is string
- __pihole_candidate.config.dns.interface | trim | length > 0
fail_msg: >-
The merged config.dns.interface is empty. Set it through the pihole_overrides dictionary
(for example pihole_overrides.config.dns.interface: eth0); there is no role default.
quiet: true
- name: Check that the web password is a string
ansible.builtin.assert:
that:
- __pihole_candidate.config.webserver.api.password is defined
- __pihole_candidate.config.webserver.api.password is string
fail_msg: The merged config.webserver.api.password must be a string.
quiet: true
- name: Check that the web password has been changed from the placeholder
ansible.builtin.assert:
that:
- __pihole_candidate.config.webserver.api.password != "changetoyourownpassword"
fail_msg: >-
The web password is the placeholder changetoyourownpassword: set pihole_web_password, or
pihole_overrides.config.webserver.api.password, to a secret of your own.
quiet: true