--- # 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