-
Notifications
You must be signed in to change notification settings - Fork 0
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
Unattend upgrades [WIP] #2
Open
romanpeters
wants to merge
5
commits into
master
Choose a base branch
from
unattend-upgrades
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8205889
Task: security/unattended-upgrades
romanpeters 7f84e1e
Use script without OTP code
romanpeters dbf69c5
Make macOS compatible
romanpeters d347cf0
Prevent APT merge list error (disabled)
romanpeters 72b43f7
Added unattended_upgrades vars
romanpeters File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,7 @@ | |
service: | ||
name: "sshd" | ||
state: "reloaded" | ||
|
||
- name: "systemctl daemon-reload" | ||
systemd: | ||
daemon_reload: true |
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 |
---|---|---|
|
@@ -39,6 +39,6 @@ for team in ${TEAMS[@]}; do | |
done | ||
|
||
echo "Updating authorized-keys template." | ||
mv --backup=numbered .new-authorized-keys templates/home/pi/.ssh/authorized_keys.j2 | ||
mv .new-authorized-keys templates/home/pi/.ssh/authorized_keys.j2 | ||
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. Same |
||
|
||
echo "Done!" |
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,38 @@ | ||
--- | ||
# Needed because of Ansible issue #25414 | ||
- name: "check if unattended-upgrades is not in progress" | ||
shell: | ||
"while fuser /var/lib/dpkg/lock; do sleep 1; done;" | ||
become: true | ||
changed_when: false | ||
|
||
- name: "install common utilities" | ||
apt: | ||
name: | ||
- "aptitude" | ||
- "htop" | ||
- "unattended-upgrades" | ||
- "haveged" | ||
state: "present" | ||
|
||
# uncomment in case of merge list error | ||
# https://www.ihaveapc.com/2011/05/how-to-fix-problem-with-mergelist-varlibaptlists-error-in-ubuntu-11-04/ | ||
#- name: "remove merge list" | ||
# command: "rm /var/lib/apt/lists/* -vf" | ||
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. Could be expanded to a |
||
|
||
- name: "update all packages" | ||
apt: | ||
upgrade: "yes" | ||
update_cache: true | ||
cache_valid_time: 100 | ||
|
||
- name: "configure unattended-upgrades" | ||
template: | ||
src: "templates/{{ item }}.j2" | ||
dest: "/{{ item }}" | ||
with_items: | ||
- "etc/apt/apt.conf.d/50unattended-upgrades" | ||
notify: | ||
- "systemctl daemon-reload" | ||
|
||
|
29 changes: 29 additions & 0 deletions
29
ansible/templates/etc/apt/apt.cond.d/50unattended-upgrades.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,29 @@ | ||
// {{ ansible_managed }} | ||
|
||
Unattended-Upgrade::Allowed-Origins { | ||
{% if unattended_upgrades.security %} | ||
"${distro_id} ${distro_codename}-security"; | ||
{% endif %} | ||
{% if unattended_upgrades.all %} | ||
|
||
"${distro_id} stable"; | ||
"${distro_id} ${distro_codename}-updates"; | ||
"LP-PPA-certbot-certbot:${distro_codename}"; | ||
"yarn:stable"; | ||
{% endif %} | ||
}; | ||
|
||
Unattended-Upgrade::Package-Blacklist { }; | ||
|
||
// Do automatic removal of new unused dependencies after the upgrade | ||
// (equivalent to apt-get autoremove) | ||
Unattended-Upgrade::Remove-Unused-Dependencies "true"; | ||
|
||
// 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" | ||
Unattended-Upgrade::Automatic-Reboot-Time "04:30"; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This was a temporary fix to make it work on OSX, I'll revert this line.