diff --git a/roles/pihole/README.md b/roles/pihole/README.md index f5db3df..faf445f 100644 --- a/roles/pihole/README.md +++ b/roles/pihole/README.md @@ -36,7 +36,7 @@ The upstreams default to `1.1.1.1` and `8.8.8.8`, `config.dns.domain` to `lan` a ## Tags -The input asserts carry `always` (and `assert`), so they run whatever tags are selected. The merge and the configuration-directory check, which only compute facts, carry `always` too, so skipping a tag never skips a fact a later task reads. The installed check (stat and fact) carries `updates-only`, and the reconfigure import carries `config-only`. The version fact, configuration and installation tasks carry no tag of their own, so they run only when no tags are selected. +The input asserts carry `always` (and `assert`), so they run whatever tags are selected. The merge, the installed check and the configuration-directory check, which only compute facts, carry `always` too, so skipping a tag never skips a fact a later task reads. The reconfigure import carries `config-only`. The version fact, configuration and installation tasks carry no tag of their own, so they run only when no tags are selected. ## Example play diff --git a/roles/pihole/tasks/main.yml b/roles/pihole/tasks/main.yml index 783aed5..5fb6333 100644 --- a/roles/pihole/tasks/main.yml +++ b/roles/pihole/tasks/main.yml @@ -15,16 +15,17 @@ ansible.builtin.set_fact: __pihole_version: "{{ __pihole_effective.repo.version }}" +# Fact-only, under always: the configuration and installation tasks read it. - name: Check if Pi-Hole is already installed ansible.builtin.stat: path: "{{ __pihole_effective.config.files.database }}" register: __pihole_database - tags: updates-only + tags: always - name: Set Pi-Hole installation status ansible.builtin.set_fact: __pihole_installed: "{{ __pihole_database.stat.exists | default(false) }}" - tags: updates-only + tags: always # Read by the template tasks: under --check the directory is not created, so on a first run # there is no directory to render pihole.toml into. Under always, because one reader is diff --git a/roles/pihole/tasks/merge-defaults.yml b/roles/pihole/tasks/merge-defaults.yml index 67ac3c5..5f3a77b 100644 --- a/roles/pihole/tasks/merge-defaults.yml +++ b/roles/pihole/tasks/merge-defaults.yml @@ -3,7 +3,6 @@ # "__pihole_effective", so the input is never overwritten and every run recomputes the merge. # https://docs.ansible.com/ansible/latest/collections/ansible/builtin/combine_filter.html - name: Merge overrides over the default variable - tags: default ansible.builtin.set_fact: __pihole_effective: "{{ pihole_default | combine(pihole_overrides | default({}), recursive=True) }}" # the merged settings hold the web password