Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
067e0e4b3e | ||
|
|
cb78edff6f | ||
|
|
7cb99de32d | ||
|
|
6a35c7407e |
No files matched your search
@@ -28,7 +28,7 @@ jobs:
|
||||
timeout-minutes: 30
|
||||
# The ci image (images/ci, built by image.yml): tag for the release, digest enforced.
|
||||
container:
|
||||
image: git.rkdr.net/mortis/ci:0.2.54@sha256:2742be4ba03f71f00b06f1d2b318e8fd3866a800247bbd7e52508dfb0da6312c
|
||||
image: git.rkdr.net/mortis/ci:0.2.55@sha256:a20f7e4154aaba15a3dd5b2d42e5e84b307bab1128c9dc4cd4e54d55d6b64d60
|
||||
env:
|
||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||
steps:
|
||||
|
||||
@@ -44,7 +44,7 @@ jobs:
|
||||
# The ci image (images/ci, built by image.yml), at the pin of lint.yml: tag for the
|
||||
# release, digest enforced. Only its /opt/venv Python (with PyYAML) is used here.
|
||||
container:
|
||||
image: git.rkdr.net/mortis/ci:0.2.54@sha256:2742be4ba03f71f00b06f1d2b318e8fd3866a800247bbd7e52508dfb0da6312c
|
||||
image: git.rkdr.net/mortis/ci:0.2.55@sha256:a20f7e4154aaba15a3dd5b2d42e5e84b307bab1128c9dc4cd4e54d55d6b64d60
|
||||
steps:
|
||||
# The container has no Node, so JavaScript actions such as actions/checkout
|
||||
# cannot run; clone with git and the job token.
|
||||
|
||||
@@ -31,7 +31,7 @@ jobs:
|
||||
# The tag says which release, the digest is what is enforced (bump both together
|
||||
# when image.yml publishes a new version).
|
||||
container:
|
||||
image: git.rkdr.net/mortis/ci:0.2.54@sha256:2742be4ba03f71f00b06f1d2b318e8fd3866a800247bbd7e52508dfb0da6312c
|
||||
image: git.rkdr.net/mortis/ci:0.2.55@sha256:a20f7e4154aaba15a3dd5b2d42e5e84b307bab1128c9dc4cd4e54d55d6b64d60
|
||||
env:
|
||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||
PRE_COMMIT_HOME: /opt/pre-commit
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
breaking_changes:
|
||||
- >-
|
||||
pihole - A non-empty ``config.webserver.api.app_password`` is now refused, and ``app_pwhash``
|
||||
always renders empty, which disables app passwords. Released pihole-FTL upgrades a
|
||||
legacy-hashed app password on login by writing the new hash into the main ``pwhash``, so one
|
||||
login with the app password replaced the web password. Remove
|
||||
``config.webserver.api.app_password`` from ``pihole_overrides``; the first run after upgrading
|
||||
re-renders ``pihole.toml`` and reconfigures Pi-hole.
|
||||
@@ -58,13 +58,14 @@ The input asserts carry `always` (and `assert`), so they run whatever tags are s
|
||||
|
||||
## Tests
|
||||
|
||||
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It replaces the upstream repository with a local stub whose installer only logs its arguments and creates the database file, so it tests the merge, the asserts, the user, the configuration directory and the rendered `pihole.toml` (owner, group and mode), the clone's checked-out version, the installer sequence (install once, then reconfigure from the handler) and idempotence, not Pi-hole itself: no pihole-FTL service runs, so that the service loaded the configuration is not verified. It runs `check` before the converge (a fresh host) and after it (a configured host). Negative tests in `verify.yml` cover a host without Ubuntu facts, a missing `pihole_web_password`, an unset interface, empty upstreams, a non-string password and the placeholder password.
|
||||
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It replaces the upstream repository with a local stub whose installer only logs its arguments and creates the database file, so it tests the merge, the asserts, the user, the configuration directory and the rendered `pihole.toml` (owner, group and mode), the clone's checked-out version, the installer sequence (install once, then reconfigure from the handler) and idempotence, not Pi-hole itself: no pihole-FTL service runs, so that the service loaded the configuration is not verified. It runs `check` before the converge (a fresh host) and after it (a configured host). Negative tests in `verify.yml` cover a host without Ubuntu facts, a missing `pihole_web_password`, an unset interface, empty upstreams, a non-string password, the placeholder password and a non-empty app password.
|
||||
|
||||
## Notes
|
||||
|
||||
- Idempotent: yes.
|
||||
- Merge model: the role sets an internal fact to `pihole_default | combine(pihole_overrides | default({}), recursive=True)`. The input is only read, never overwritten, so each run recomputes the merge. Dictionaries are not merged across variable sources, so define `pihole_overrides` in one place only.
|
||||
- Secrets: the password is hashed twice with SHA-256 in the template (`pwhash`). The merge and both template tasks use `no_log`, and the templates `diff: false`, so a `pihole.toml` change shows no diff. `pihole_testing` masks the web password, app password and TOTP secret in its output. `totp_secret` and `app_password` default to empty strings.
|
||||
- App passwords: `config.webserver.api.app_password` must stay empty, and the role fails otherwise; `app_pwhash` always renders empty, which disables app passwords. Released pihole-FTL upgrades a legacy-hashed (double SHA-256) app password on login by writing the new hash into the main `pwhash`, so one login with the app password would replace the web password.
|
||||
- Install flow: the role creates the `pihole` system user (nologin), the configuration directory and, on first install, `pihole.toml`, because the unattended installer needs it first. It clones `repo.version` and runs the installer with `--unattended` only when `config.files.database` does not exist yet. A change to `pihole.toml` notifies the `reconfigure pihole` handler, which runs the installer with `--reconfigure --unattended`.
|
||||
- Updates: the role does not upgrade an installed Pi-hole; changing `repo.version` only moves the clone.
|
||||
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. On a host where the configuration directory does not exist yet, the `pihole.toml` template tasks are skipped under `--check`, because the directory they write into is not created.
|
||||
|
||||
@@ -308,7 +308,7 @@ pihole_default:
|
||||
password: "{{ pihole_web_password }}"
|
||||
# Pi-hole 2FA TOTP secret.
|
||||
totp_secret: ""
|
||||
# Pi-hole application password (to circumvent 2FA for legacy 3rd-party services)
|
||||
# Pi-hole application password: must stay empty, app_pwhash always renders empty (README Notes)
|
||||
app_password: ""
|
||||
# Should application password API sessions be allowed to modify config settings?
|
||||
app_sudo: false
|
||||
|
||||
@@ -13,8 +13,8 @@ argument_specs:
|
||||
over C(pihole_default) in C(defaults/main.yml). The spec types it as a dictionary only, because sub-options
|
||||
would reject every key it does not list. The merged result is an internal fact and never overwrites the
|
||||
input. The role fails unless the merged C(config.dns.upstreams) is a non-empty list, C(config.dns.interface)
|
||||
is a non-empty string and C(config.webserver.api.password) is a string other than
|
||||
C(changetoyourownpassword).
|
||||
is a non-empty string, C(config.webserver.api.password) is a string other than
|
||||
C(changetoyourownpassword) and C(config.webserver.api.app_password) is empty.
|
||||
- >-
|
||||
C(pihole_default) (every setting rendered into C(pihole.toml)) and C(pihole_install_script) (the quoted
|
||||
installer path under C(repo.path)) are role defaults deliberately not listed here, because argument
|
||||
@@ -47,7 +47,11 @@ argument_specs:
|
||||
C(config.dns.interface) must be set (string, for example C(eth0)): its default is an empty placeholder
|
||||
and the role fails until it is set. C(config.dns.upstreams) (list of IP addresses or hostnames,
|
||||
optionally with C(#port)) must stay non-empty. C(config.webserver.api.password) must stay a string.
|
||||
C(config.webserver.api.totp_secret) and C(config.webserver.api.app_password) are also credentials.
|
||||
C(config.webserver.api.totp_secret) is also a credential.
|
||||
- >-
|
||||
C(config.webserver.api.app_password) must stay empty and C(app_pwhash) always renders empty, which
|
||||
disables app passwords: released pihole-FTL replaces the main web password on a login with a
|
||||
legacy-hashed app password.
|
||||
- >-
|
||||
Other keys the tasks read are C(repo.remote), C(repo.version) (a tag, default C(v6.4)), C(repo.path)
|
||||
(default C(~/.cache/pi-hole) of the connecting user), C(user), C(group) (both default C(pihole)) and
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
database: passwd
|
||||
key: pihole
|
||||
|
||||
- name: The config carries the overridden upstreams and a hashed password
|
||||
- name: The config carries the overridden upstreams, a hashed password and no app password
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'9.9.9.9' in pihole_test_toml_content"
|
||||
@@ -66,6 +66,7 @@
|
||||
- "'\"eth0\"' not in pihole_test_toml_content"
|
||||
- "'molecule-test-password' not in pihole_test_toml_content"
|
||||
- pihole_test_toml_content is search('(?m)^\\s*pwhash = \"[0-9a-f]{64}\"')
|
||||
- pihole_test_toml_content is search('(?m)^\\s*app_pwhash = \"\"$')
|
||||
quiet: true
|
||||
vars:
|
||||
pihole_test_toml_content: "{{ pihole_test_toml.content | b64decode }}"
|
||||
@@ -167,3 +168,9 @@
|
||||
dns: {interface: molecule0}
|
||||
webserver: {api: {password: changetoyourownpassword}}
|
||||
expect: placeholder changetoyourownpassword
|
||||
- name: app-password-set
|
||||
overrides:
|
||||
config:
|
||||
dns: {interface: molecule0}
|
||||
webserver: {api: {password: molecule-test-password, app_password: molecule-test-app-password}}
|
||||
expect: app_password must stay empty
|
||||
@@ -53,3 +53,15 @@
|
||||
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
|
||||
|
||||
# Released pihole-FTL upgrades a legacy-hashed app password on login by writing the new hash
|
||||
# into the main pwhash, so the role renders app_pwhash empty, which disables app passwords.
|
||||
- name: Check that no app password is set
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- (__pihole_candidate.config.webserver.api.app_password | default('', true)) == ''
|
||||
fail_msg: >-
|
||||
config.webserver.api.app_password must stay empty: released pihole-FTL replaces the main
|
||||
web password when someone logs in with an app password the role has hashed. Remove
|
||||
app_password from pihole_overrides.
|
||||
quiet: true
|
||||
@@ -838,9 +838,9 @@
|
||||
#
|
||||
# Possible values are:
|
||||
# <valid Pi-hole password hash>
|
||||
# NOTE! I am assuming this should be double-hashed just like the regular password, but
|
||||
# this assumption has not been tested!
|
||||
app_pwhash = "{{ __pihole_effective.config.webserver.api.app_password | hash('sha256') | hash('sha256') }}"
|
||||
# Always empty, which disables app passwords: the role refuses app_password, because
|
||||
# released pihole-FTL rewrites the main pwhash on a login with a legacy-hashed app password.
|
||||
app_pwhash = ""
|
||||
|
||||
# Should application password API sessions be allowed to modify config settings?
|
||||
# Setting this to true allows third-party applications using the application password
|
||||
|
||||
Reference in new issue
Block a user