Files
Kamino/roles/pihole/molecule/default/prepare.yml
T
Defame1297 bf6f9b5800
Build / build (pull_request) Successful in 27s
Lint / lint (pull_request) Successful in 2m7s
Molecule / molecule (pull_request) Failing after 2m27s
test(pihole): add the default molecule scenario
Runs on noble and resolute without the real Pi-hole: the clone target
is a local git repository whose installer is a stub that logs its
arguments and creates the database file.

Covers a check run before the converge and after idempotence, the
merge, the rendered pihole.toml (upstreams, interface, hashed
password, owner and mode), the system user, the installer sequence
(install once, then reconfigure from the handler) and a negative test
for every validation: no Ubuntu facts, a missing pihole_web_password,
an unset interface, empty upstreams, a non-string and a placeholder
password. No pihole-FTL service runs, so the loaded configuration is
not verified.

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

37 lines
1.5 KiB
YAML

---
# The role clones the upstream Pi-hole repository and runs its installer, which needs a real
# DNS stack (pihole-FTL, port 53, the gravity database). A container cannot honestly test that,
# so the clone target is a local git repository whose installer is a stub that logs its
# arguments and creates the database file the role checks for an existing install.
- name: Prepare
hosts: all
gather_facts: false
tasks:
- name: Install git
ansible.builtin.apt:
name: git
state: present
update_cache: true
- name: Build the stub upstream repository
ansible.builtin.shell:
cmd: |
set -e
rm -rf /opt/pihole-stub /opt/pihole-stub.git /var/log/pihole-stub-installer.log
mkdir -p "/opt/pihole-stub/automated install"
cat > "/opt/pihole-stub/automated install/basic-install.sh" <<'STUB'
#!/bin/sh
echo "$*" >> /var/log/pihole-stub-installer.log
mkdir -p /etc/pihole
touch /etc/pihole/pihole-FTL.db
STUB
chmod 0755 "/opt/pihole-stub/automated install/basic-install.sh"
cd /opt/pihole-stub
git init -q -b main
git -c user.name=molecule -c user.email=molecule@localhost add -A
git -c user.name=molecule -c user.email=molecule@localhost commit -q -m stub
git tag v6.4
git clone -q --bare /opt/pihole-stub /opt/pihole-stub.git
executable: /bin/bash
changed_when: true