Skip to content

Commit d2d25d9

Browse files
Copilotjosecelano
andcommitted
fix: [#17] add Debian family conditionals to security updates playbook
Add 'when: ansible_os_family == "Debian"' conditions to all APT and unattended-upgrades specific tasks to prevent errors on non-Debian systems Co-authored-by: josecelano <[email protected]>
1 parent 4d88cd5 commit d2d25d9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

templates/ansible/configure-security-updates.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,30 @@
2828
line: 'APT::Periodic::Unattended-Upgrade "1";'
2929
create: true
3030
backup: true
31+
when: ansible_os_family == "Debian"
3132

3233
- name: Enable automatic reboot for security updates
3334
ansible.builtin.lineinfile:
3435
path: /etc/apt/apt.conf.d/50unattended-upgrades
3536
regexp: "^Unattended-Upgrade::Automatic-Reboot"
3637
line: 'Unattended-Upgrade::Automatic-Reboot "true";'
3738
backup: true
39+
when: ansible_os_family == "Debian"
3840

3941
- name: Set automatic reboot time to 2:00 AM
4042
ansible.builtin.lineinfile:
4143
path: /etc/apt/apt.conf.d/50unattended-upgrades
4244
regexp: "^Unattended-Upgrade::Automatic-Reboot-Time"
4345
line: 'Unattended-Upgrade::Automatic-Reboot-Time "02:00";'
4446
backup: true
47+
when: ansible_os_family == "Debian"
4548

4649
- name: Enable and start unattended-upgrades service
4750
ansible.builtin.systemd:
4851
name: unattended-upgrades
4952
enabled: true
5053
state: started
54+
when: ansible_os_family == "Debian"
5155
ignore_errors: true # Ignore in container environments where systemd might not work
5256

5357
- name: Verify unattended-upgrades configuration
@@ -56,6 +60,7 @@
5660
register: unattended_upgrades_test
5761
changed_when: false
5862
failed_when: false # Don't fail on verification errors in test environments
63+
when: ansible_os_family == "Debian"
5964

6065
- name: Display verification result
6166
ansible.builtin.debug:

0 commit comments

Comments
 (0)