Files
Kamino/roles/pihole/tasks/validate.yml
T
Defame1297 067e0e4b3e
Build / build (pull_request) Successful in 34s
Lint / renovate-config (pull_request) Successful in 9s
Molecule / select (pull_request) Successful in 9s
Lint / lint (pull_request) Successful in 2m45s
Molecule / scenarios (pull_request) Successful in 3m24s
Molecule / Result (pull_request) Successful in 2s
docs(pihole): say how to clear app_password and what the upgrade run does
The refusal message and the changelog fragment now tell the consumer to
remove app_password from pihole_overrides, the fragment says the first run
after upgrading re-renders pihole.toml and reconfigures Pi-hole, and the
role description lists the empty app_password among the conditions it
checks.

Refs: #383
Assisted-by: Claude Code
2026-12-06 22:09:22 +00:00

68 lines
3.1 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 (env.HOME, 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
# Released pihole-FTL upgrades a legacy-hashed app password on login by writing the new hash
# into the main pwhash, so the role renders app_pwhash empty, which disables app passwords.
- name: Check that no app password is set
ansible.builtin.assert:
that:
- (__pihole_candidate.config.webserver.api.app_password | default('', true)) == ''
fail_msg: >-
config.webserver.api.app_password must stay empty: released pihole-FTL replaces the main
web password when someone logs in with an app password the role has hashed. Remove
app_password from pihole_overrides.
quiet: true