Skip to content

Commit 0fdb8a3

Browse files
authored
Merge pull request #514 from Normo/explicit-become
unattended_upgrades: Add explicit become directives
2 parents 0166b3b + f1d7f29 commit 0fdb8a3

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

roles/unattended_upgrades/handlers/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
# handlers file for unattended-upgrades
99

1010
- name: 'Restart apt-daily timer'
11+
become: true
1112
ansible.builtin.systemd:
1213
daemon_reload: true
1314
name: 'apt-daily.timer'
1415
state: 'restarted'
1516
enabled: true
1617

1718
- name: 'Restart apt-daily-upgrade timer'
19+
become: true
1820
ansible.builtin.systemd:
1921
daemon_reload: true
2022
name: 'apt-daily-upgrade.timer'

roles/unattended_upgrades/tasks/reboot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# Ignored, since newer distros don't need this package
99
# https://github.com/jnv/ansible-role-unattended-upgrades/issues/6
1010
- name: "Install update-notifier-common"
11+
become: true
1112
ansible.builtin.apt:
1213
name: "update-notifier-common"
1314
state: "present"

roles/unattended_upgrades/tasks/systemd_timers.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,23 @@
66
---
77

88
- name: 'Test apt-daily timer expression'
9+
become: true
910
ansible.builtin.command:
1011
cmd: 'systemd-analyze calendar "{{ unattended_apt_daily_oncalendar }}"'
1112
register: '__apt_daily'
1213
changed_when: '__apt_daily.rc != 0'
1314
check_mode: false
1415

1516
- name: 'Test apt-daily-upgrade timer expression'
17+
become: true
1618
ansible.builtin.command:
1719
cmd: 'systemd-analyze calendar "{{ unattended_apt_daily_upgrade_oncalendar }}"'
1820
register: '__apt_daily_upgrade'
1921
changed_when: '__apt_daily_upgrade.rc != 0'
2022
check_mode: false
2123

2224
- name: 'Ensure directory apt-daily.timer.d exists'
25+
become: true
2326
ansible.builtin.file:
2427
path: '/etc/systemd/system/apt-daily.timer.d'
2528
mode: '0755'
@@ -28,6 +31,7 @@
2831
group: 'root'
2932

3033
- name: 'Ensure directory apt-daily-upgrade.timer.d exists'
34+
become: true
3135
ansible.builtin.file:
3236
path: '/etc/systemd/system/apt-daily-upgrade.timer.d'
3337
mode: '0755'
@@ -36,6 +40,7 @@
3640
group: 'root'
3741

3842
- name: 'Deploy apt-daily timer'
43+
become: true
3944
ansible.builtin.template:
4045
src: 'apt_daily_override.conf.j2'
4146
dest: '/etc/systemd/system/apt-daily.timer.d/schedule_override.conf'
@@ -48,6 +53,7 @@
4853
- 'Restart apt-daily timer'
4954

5055
- name: 'Deploy apt-daily-upgrade timer'
56+
become: true
5157
ansible.builtin.template:
5258
src: 'apt_daily_upgrade_override.conf.j2'
5359
dest: '/etc/systemd/system/apt-daily-upgrade.timer.d/schedule_override.conf'

roles/unattended_upgrades/tasks/systemd_timers_remove.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
---
77

88
- name: 'Remove apt-daily timer override'
9+
become: true
910
ansible.builtin.file:
1011
path: '/etc/systemd/system/apt-daily.timer.d/schedule_override.conf'
1112
state: 'absent'
1213
notify:
1314
- 'Restart apt-daily timer'
1415

1516
- name: 'Remove apt-daily-upgrade timer override'
17+
become: true
1618
ansible.builtin.file:
1719
path: '/etc/systemd/system/apt-daily-upgrade.timer.d/schedule_override.conf'
1820
state: 'absent'

roles/unattended_upgrades/tasks/unattended-upgrades.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- 'vars'
1717

1818
- name: "Install powermgmt-base"
19+
become: true
1920
ansible.builtin.apt:
2021
name: "powermgmt-base"
2122
state: "present"
@@ -25,6 +26,7 @@
2526
when: "unattended_only_on_ac_power"
2627

2728
- name: "Install unattended-upgrades"
29+
become: true
2830
ansible.builtin.apt:
2931
name: "unattended-upgrades"
3032
state: "present"
@@ -37,6 +39,7 @@
3739
when: "unattended_automatic_reboot | bool"
3840

3941
- name: "Create Apt auto-upgrades & unattended-upgrades configuration"
42+
become: true
4043
ansible.builtin.template:
4144
src: "unattended-upgrades.j2"
4245
dest: "/etc/apt/apt.conf.d/90-ansible-unattended-upgrades"

0 commit comments

Comments
 (0)