-
Notifications
You must be signed in to change notification settings - Fork 688
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide unattended-upgrades configuration via apt package
securedrop-config package will provide the configuration for focal only
- Loading branch information
Showing
13 changed files
with
118 additions
and
50 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
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: 5 additions & 34 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 |
---|---|---|
@@ -1,43 +1,14 @@ | ||
--- | ||
- name: Install unattended-upgrades package and update-notifier-common | ||
apt: | ||
name: "{{ item }}" | ||
state: present | ||
update_cache: yes | ||
with_items: | ||
- unattended-upgrades | ||
- update-notifier-common | ||
tags: | ||
- apt | ||
- unattended-upgrades | ||
# Configuration for unattended upgrades is almost exclusively managed by the | ||
# securedrop-config package under Focal. | ||
|
||
- name: Configure unattended-upgrades to update the packages from sources.list. | ||
copy: | ||
src: 20auto-upgrades | ||
dest: /etc/apt/apt.conf.d/20auto-upgrades | ||
mode: 0644 | ||
owner: root | ||
group: root | ||
tags: | ||
- apt | ||
- unattended-upgrades | ||
|
||
- name: Configure unattended-upgrades to update the packages from sources.list. | ||
- name: Configure unattended-upgrades to reboot daily at the scheduled time. | ||
template: | ||
src: 50unattended-upgrades.j2 | ||
dest: /etc/apt/apt.conf.d/50unattended-upgrades | ||
src: 80securedrop.j2 | ||
dest: /etc/apt/apt.conf.d/80securedrop | ||
mode: 0644 | ||
owner: root | ||
group: root | ||
tags: | ||
- apt | ||
- unattended-upgrades | ||
|
||
- name: Add cron job to indicate to unattended-upgrades that a reboot is required. | ||
cron: | ||
name: Indicate that a reboot is required at the scheduled time. | ||
job: "touch /var/run/reboot-required" | ||
hour: "*/12" | ||
tags: | ||
- cron | ||
- unatted-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"; |
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.3+1.7.0~rc1+{{ ansible_distribution_release }} | ||
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 |
File renamed without changes.
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
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