added guardrails on enabled and state flags to systemd mask tasks to only disable and stop when the package is installed, otherwise just mask to prevent the service from ever starting should it get installed at a later time. This allows hardening to proceed when the service doesn't exist but masking has been requested. Otherwise the playbook run will fail at a step when the service which comes with the package doesn't already exist

Signed-off-by: Michael Hicks <nooneofconsequence@gmail.com>
This commit is contained in:
Michael Hicks 2026-03-04 10:40:41 -08:00
parent 497b3dc8d9
commit c4a97079b1
No known key found for this signature in database
GPG key ID: A939A14F4AFC6498
4 changed files with 61 additions and 46 deletions

View file

@ -105,6 +105,6 @@
notify: Systemd daemon reload
ansible.builtin.systemd:
name: bluetooth.service
enabled: false
state: stopped
enabled: "{{ ('bluez' in ansible_facts.packages) | ternary(false, omit) }}"
state: "{{ ('bluez' in ansible_facts.packages) | ternary('stopped', omit) }}"
masked: true