-
Notifications
You must be signed in to change notification settings - Fork 690
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5684 from freedomofpress/5295-unattended-upgrades
Replace cron-apt with unattended-upgrades on Focal
- Loading branch information
Showing
26 changed files
with
547 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,6 @@ common-steps: | |
- /focalcaches/layers.tar | ||
|
||
|
||
|
||
version: 2 | ||
jobs: | ||
lint: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
install_files/ansible-base/roles/common/tasks/apt_sources.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
install_files/ansible-base/roles/common/tasks/unattended_upgrades.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
4 changes: 4 additions & 0 deletions
4
install_files/ansible-base/roles/common/templates/80securedrop.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
13 changes: 13 additions & 0 deletions
13
install_files/ansible-base/roles/common/templates/sources.list.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,3 @@ | |
state: present | ||
update_cache: yes | ||
become: yes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
22 changes: 22 additions & 0 deletions
22
install_files/securedrop-config-focal/etc/profile.d/securedrop_additions.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
3 changes: 3 additions & 0 deletions
3
install_files/securedrop-config-focal/opt/securedrop/20auto-upgrades
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
60 changes: 60 additions & 0 deletions
60
install_files/securedrop-config-focal/opt/securedrop/50unattended-upgrades
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. "[email protected]" | ||
//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"; |
4 changes: 4 additions & 0 deletions
4
install_files/securedrop-config-focal/opt/securedrop/reboot-flag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.