-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace cron-apt with unattended-upgrades on Focal #5684
Changes from all commits
5a0c16b
331d01d
475cf14
0e79028
50b9365
aef3584
bddc184
733bd11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,6 @@ common-steps: | |
- /focalcaches/layers.tar | ||
|
||
|
||
|
||
version: 2 | ||
jobs: | ||
lint: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
- name: Configure apt sources. | ||
template: | ||
src: sources.list.j2 | ||
dest: /etc/apt/sources.list | ||
mode: "0644" | ||
owner: root | ||
tags: | ||
- apt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
# Configuration for unattended upgrades is almost exclusively managed by the | ||
# securedrop-config package under Focal. | ||
|
||
- name: Configure unattended-upgrades to reboot daily at the scheduled time. | ||
template: | ||
src: 80securedrop.j2 | ||
dest: /etc/apt/apt.conf.d/80securedrop | ||
mode: 0644 | ||
owner: root | ||
group: root | ||
tags: | ||
- apt | ||
- unattended-upgrades | ||
|
||
- name: Ensure apt-daily and apt-daily-upgrade services are unmasked, started and enabled. | ||
systemd: | ||
name: "{{ item }}" | ||
state: started | ||
enabled: yes | ||
masked: no | ||
with_items: | ||
- 'apt-daily' | ||
- 'apt-daily-upgrade' | ||
tags: | ||
- apt | ||
- unattended-upgrades | ||
|
||
- name: Ensure apt-daily and apt-daily-upgrade timers are started, and enabled. | ||
systemd: | ||
name: "{{ item }}" | ||
state: started | ||
enabled: yes | ||
with_items: | ||
- 'apt-daily.timer' | ||
- 'apt-daily-upgrade.timer' | ||
tags: | ||
- apt | ||
- unattended-upgrades |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// If automatic reboot is enabled and needed, reboot at the specific | ||
// time instead of immediately | ||
// Default: "now" | ||
Unattended-Upgrade::Automatic-Reboot-Time "{{ daily_reboot_time }}:00"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## newer versions of the distribution. | ||
deb http://archive.ubuntu.com/ubuntu/ {{ ansible_distribution_release }} main | ||
|
||
## newer versions of the distribution. | ||
deb http://archive.ubuntu.com/ubuntu/ {{ ansible_distribution_release }} universe | ||
|
||
## Major bug fix updates produced after the final release of the | ||
## distribution. | ||
deb http://archive.ubuntu.com/ubuntu/ {{ ansible_distribution_release }}-updates main | ||
|
||
### Security fixes for distribution packages | ||
deb http://security.ubuntu.com/ubuntu {{ ansible_distribution_release }}-security main | ||
deb http://security.ubuntu.com/ubuntu {{ ansible_distribution_release }}-security universe | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good, clean restrictions here. Essentially, we're removing use of "multiverse" and "restricted", and allowing everything else. Confirmed that e.g.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,12 @@ securedrop_kernel_packages_to_remove: | |
- 'linux-image-.*generic' | ||
|
||
resolvconf_target_filepath: /etc/resolv.conf | ||
|
||
securedrop_common_packages: | ||
- apt-transport-https | ||
- aptitude | ||
- unattended-upgrades | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
- ntp | ||
- ntpdate | ||
- resolvconf | ||
- tmux |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,3 @@ | |
state: present | ||
update_cache: yes | ||
become: yes | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Source: securedrop | ||
Section: web | ||
Priority: optional | ||
Maintainer: SecureDrop Team <securedrop@freedom.press> | ||
Homepage: https://securedrop.org | ||
Package: securedrop-config | ||
Version: 0.1.4+{{ securedrop_version }}+{{ securedrop_target_distribution }} | ||
Depends: unattended-upgrades,update-notifier-common | ||
Architecture: all | ||
Description: Establishes baseline system state for running SecureDrop. | ||
Configures apt repositories. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/sh | ||
# postinst script for securedrop-config-focal | ||
|
||
set -e | ||
set -x | ||
|
||
case "$1" in | ||
configure) | ||
# Configuration required for unattended-upgrades | ||
cp /opt/securedrop/20auto-upgrades /etc/apt/apt.conf.d/ | ||
cp /opt/securedrop/50unattended-upgrades /etc/apt/apt.conf.d/ | ||
cp /opt/securedrop/reboot-flag /etc/cron.d/ | ||
|
||
;; | ||
abort-upgrade|abort-remove|abort-deconfigure) | ||
;; | ||
|
||
*) | ||
echo "postinst called with unknown argument \`$1'" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
|
||
exit 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[[ $- != *i* ]] && return | ||
|
||
which tmux >/dev/null 2>&1 || return | ||
|
||
tmux_attach_via_proc() { | ||
# If the tmux package is upgraded during the lifetime of a | ||
# session, attaching with the new binary can fail due to different | ||
# protocol versions. This function attaches using the reference to | ||
# the old executable found in the /proc tree of an existing | ||
# session. | ||
pid=$(pgrep --newest tmux) | ||
if test -n "$pid" | ||
then | ||
/proc/$pid/exe attach | ||
fi | ||
return 1 | ||
} | ||
|
||
if test -z "$TMUX" | ||
then | ||
(tmux attach || tmux_attach_via_proc || tmux new-session) | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
APT::Periodic::Update-Package-Lists "1"; | ||
APT::Periodic::Unattended-Upgrade "1"; | ||
APT::Periodic::AutocleanInterval "1"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Automatically upgrade packages from these (origin:archive/codename) pairs | ||
Unattended-Upgrade::Origins-Pattern { | ||
"origin=${distro_id},archive=${distro_codename}"; | ||
"origin=${distro_id},archive=${distro_codename}-security"; | ||
"origin=${distro_id},archive=${distro_codename}-updates"; | ||
"origin=SecureDrop,codename=${distro_codename}"; | ||
}; | ||
|
||
// List of packages to not update (regexp are supported) | ||
Unattended-Upgrade::Package-Blacklist { | ||
}; | ||
|
||
// This option allows you to control if on a unclean dpkg exit | ||
// unattended-upgrades will automatically run | ||
// dpkg --force-confold --configure -a | ||
// The default is true, to ensure updates keep getting installed | ||
// This mirrors the previous cron=apt config | ||
Unattended-Upgrade::AutoFixInterruptedDpkg "true"; | ||
|
||
// Split the upgrade into the smallest possible chunks so that | ||
// they can be interrupted with SIGUSR1. This makes the upgrade | ||
// a bit slower but it has the benefit that shutdown while a upgrade | ||
// is running is possible (with a small delay) | ||
//Unattended-Upgrade::MinimalSteps "true"; | ||
|
||
// Install all unattended-upgrades when the machine is shuting down | ||
// instead of doing it in the background while the machine is running | ||
// This will (obviously) make shutdown slower | ||
//Unattended-Upgrade::InstallOnShutdown "true"; | ||
|
||
// Send email to this address for problems or packages upgrades | ||
// If empty or unset then no email is sent, make sure that you | ||
// have a working mail setup on your system. A package that provides | ||
// 'mailx' must be installed. E.g. "user@example.com" | ||
//Unattended-Upgrade::Mail "root"; | ||
|
||
// Set this value to "true" to get emails only on errors. Default | ||
// is to always send a mail if Unattended-Upgrade::Mail is set | ||
//Unattended-Upgrade::MailOnlyOnError "true"; | ||
|
||
// Do automatic removal of new unused dependencies after the upgrade | ||
// (equivalent to apt-get autoremove) | ||
//Unattended-Upgrade::Remove-Unused-Dependencies "false"; | ||
|
||
// Automatically reboot *WITHOUT CONFIRMATION* | ||
// if the file /var/run/reboot-required is found after the upgrade | ||
Unattended-Upgrade::Automatic-Reboot "true"; | ||
|
||
// If automatic reboot is enabled and needed, reboot at the specific | ||
// time instead of immediately | ||
// Default: "now" | ||
// This is set in a template in the common role under the file 80securedrop | ||
|
||
// Automatically reboot even if there are users currently logged in | ||
// when Unattended-Upgrade::Automatic-Reboot is set to true | ||
Unattended-Upgrade::Automatic-Reboot-WithUsers "true"; | ||
|
||
// Use apt bandwidth limit feature, this example limits the download | ||
// speed to 70kb/sec | ||
//Acquire::http::Dl-Limit "70"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# The purpose of this cron is to drop the reboot-required flag every 12 hours | ||
# to ensure the system is rebooted nightly, regardless of updates being installed | ||
# or not. | ||
* */12 * * * touch /var/run/reboot-required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://wiki.debian.org/DebianRepository/Format#Origin has the definition (for the person who is looking at this in future).