Remove the pihole_force_install input, which had no effect, and the dead term of the install condition. Tag the merge and the configuration directory check always, so --skip-tags config-only no longer skips facts that later tasks read. Skip the installer log under --check, where the installer did not run. Read the env and user_id facts through ansible_facts, drop a redundant default, state the real reasons two defaults stay out of the argument spec, and bring the README to the fixed heading set. Assisted-by: Claude Code:claude-opus-5-5
56 lines
2.5 KiB
YAML
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 (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
|