Files
Kamino/roles/pihole/tasks/configure.yml
T
Defame1297 66628635b9 feat(pihole): add the pihole role
Installs Pi-hole v6 on Ubuntu noble and resolute by cloning the
upstream repository and running its installer unattended, with
pihole.toml rendered from pihole_default merged with pihole_overrides.
A change to pihole.toml runs the installer's reconfigure mode.

Validation runs first under always: the host must be Ubuntu, and the
merged settings need a non-empty interface and upstream list and a
string password other than the placeholder. pihole_web_password is a
required no_log input. Computed values are internal __pihole_ names.

Derived from codeberg.org/ansible/pihole (GPL-3.0-only) with Pi-hole
FTL comment text (EUPL-1.2): REUSE.toml annotations, the EUPL-1.2
text and NOTICE entries record both. The README roadmap drops pihole.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-25 18:10:59 +00:00

38 lines
1.3 KiB
YAML

---
# For the unattended install to work as intended (i.e., unattended) pihole.toml must be in
# place *before* the installer runs, so the role creates the pihole user and group itself.
- name: Create system user and group (nologin shell) for {{ __pihole_effective.user }}
become: true
ansible.builtin.user:
name: "{{ __pihole_effective.user }}"
state: present
system: true
shell: /usr/sbin/nologin
# this task requires the __pihole_effective.user user/group to exist, fails otherwise
- name: Create Pi-Hole configuration directory
become: true
ansible.builtin.file:
name: "{{ __pihole_effective.config.files.database | dirname }}"
state: directory
owner: "{{ __pihole_effective.user }}"
group: "{{ __pihole_effective.group }}"
mode: '0755'
- name: Prepare Pi-Hole configuration (first-time installation)
become: true
ansible.builtin.template:
src: pihole.toml.j2
dest: "{{ __pihole_effective.config.files.database | dirname }}/pihole.toml"
owner: "{{ __pihole_effective.user }}"
group: "{{ __pihole_effective.group }}"
mode: '0644'
when:
- not (__pihole_installed | bool)
- not ansible_check_mode or __pihole_config_dir.stat.exists
notify: reconfigure pihole
# the rendered file holds the password hashes and the TOTP secret
no_log: true
diff: false