fix(pihole): address review findings
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
This commit is contained in:
1 parent
9979dfa8ed
commit
d84fb4a2f4
7 files changed
+33
-38
No files matched your search
@@ -27,8 +27,7 @@
|
||||
dest: "{{ __pihole_effective.repo.path }}"
|
||||
version: "{{ __pihole_version }}"
|
||||
become: true
|
||||
become_user: "{{ ansible_user_id }}"
|
||||
register: __pihole_repo
|
||||
become_user: "{{ ansible_facts['user_id'] }}"
|
||||
|
||||
|
||||
# what happens if we run the install script with a pre-existing pihole on the system?
|
||||
@@ -38,11 +37,9 @@
|
||||
# on my machine the install script produced a never-ending output of "y" lines immediately after
|
||||
# successfully restarting the pihole-FTL service (if output was printed to file it quickly
|
||||
# filled the available disk space). Did this happen because Pi-Hole was already installed?
|
||||
# Only on a first install: on an installed Pi-hole the role leaves upgrades alone.
|
||||
- name: Run Pi-Hole installation script in unattended mode
|
||||
when:
|
||||
- (__pihole_repo.changed | bool) or (pihole_force_install | bool) or true
|
||||
# but not if pihole is already installed, in that case let the updater do its job
|
||||
- not (__pihole_installed | bool)
|
||||
when: not (__pihole_installed | bool)
|
||||
block:
|
||||
|
||||
# the unattended install only works if pihole.toml already exists (configure.yml)
|
||||
@@ -65,11 +62,16 @@
|
||||
ansible.builtin.slurp:
|
||||
src: "{{ __pihole_effective.repo.path }}/pihole_install.log"
|
||||
register: __pihole_install_log
|
||||
when: pihole_testing | bool
|
||||
# under --check the installer was skipped, so there is no log to read
|
||||
when:
|
||||
- pihole_testing | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
# https://www.shellhacks.com/ansible-cat-file-print-read-file-content
|
||||
- name: Display the install log
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ __pihole_install_log.content | b64decode }}"
|
||||
when: pihole_testing | bool
|
||||
when:
|
||||
- pihole_testing | bool
|
||||
- not ansible_check_mode
|
||||
# END OF BLOCK
|
||||
@@ -5,13 +5,11 @@
|
||||
ansible.builtin.import_tasks: validate.yml
|
||||
tags: [always, assert]
|
||||
|
||||
# Fact-only, under always: every later task reads the merged settings, so skipping a tag
|
||||
# must not skip the merge.
|
||||
- name: Merge configuration defaults
|
||||
ansible.builtin.import_tasks: merge-defaults.yml
|
||||
tags:
|
||||
- default
|
||||
- backups-only
|
||||
- config-only
|
||||
- updates-only
|
||||
tags: always
|
||||
|
||||
- name: Set Pi-Hole version variable
|
||||
ansible.builtin.set_fact:
|
||||
@@ -29,12 +27,13 @@
|
||||
tags: updates-only
|
||||
|
||||
# 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.
|
||||
# there is no directory to render pihole.toml into. Under always, because one reader is
|
||||
# untagged and the other tagged config-only.
|
||||
- name: Check whether the Pi-Hole configuration directory exists
|
||||
ansible.builtin.stat:
|
||||
path: "{{ __pihole_effective.config.files.database | dirname }}"
|
||||
register: __pihole_config_dir
|
||||
tags: config-only
|
||||
tags: always
|
||||
|
||||
- name: Configure Pi-Hole
|
||||
ansible.builtin.import_tasks: configure.yml
|
||||
|
||||
@@ -20,5 +20,5 @@
|
||||
|
||||
- name: Pausing to highlight merge result
|
||||
ansible.builtin.wait_for:
|
||||
timeout: "{{ pihole_testing_timeout | default(5) }}"
|
||||
timeout: "{{ pihole_testing_timeout }}"
|
||||
when: pihole_testing | bool
|
||||
@@ -2,7 +2,7 @@
|
||||
# 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
|
||||
# The role also reads gathered facts (env.HOME, user_id), so a run without
|
||||
# them fails here too.
|
||||
- name: Require Ubuntu
|
||||
ansible.builtin.assert:
|
||||
|
||||
Reference in new issue
Block a user