Skip to content
This repository has been archived by the owner on Jun 25, 2023. It is now read-only.

Commit

Permalink
Add unattended_only_on_ac_power and install powermgmt-base (#76)
Browse files Browse the repository at this point in the history
Co-authored-by: Samuel Mutel <[email protected]>
  • Loading branch information
smutel and Samuel Mutel authored Apr 29, 2021
1 parent 38d05af commit d3eeca8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ On some hosts you may find that the unattended-upgrade's cronfile `/etc/cron.dai
* Default: `[]`
* `unattended_dl_limit`: Limit the download speed in kb/sec using apt bandwidth limit feature.
* Default: disabled
* `unattended_only_on_ac_power`: Download and install upgrades only on AC power. It will also install the debian package `powermgmt-base`.
* Default: false

## Origins Patterns

Expand Down
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,8 @@ unattended_dpkg_options: []

# Use apt bandwidth limit feature, this example limits the download speed to 70kb/sec
#unattended_dl_limit: 70

# Unattended-Upgrade::OnlyOnACPower
# Download and install upgrades only on AC power
# (i.e. skip or gracefully stop updates on battery)
unattended_only_on_ac_power: false
8 changes: 8 additions & 0 deletions tasks/unattended-upgrades.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
include_vars: "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
when: (ansible_distribution == "Debian") and (ansible_distribution_release == "wheezy")

- name: install powermgmt-base
apt:
pkg:
state: present
cache_valid_time: "{{ unattended_cache_valid_time }}"
update_cache: yes
when: unattended_only_on_ac_power

- name: install unattended-upgrades
apt:
pkg: unattended-upgrades
Expand Down
4 changes: 4 additions & 0 deletions templates/unattended-upgrades.j2
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,7 @@ Dpkg::Options {
// speed to 70kb/sec
Acquire::http::Dl-Limit "{{ unattended_dl_limit }}";
{% endif %}

// Download and install upgrades only on AC power
// (i.e. skip or gracefully stop updates on battery)
Unattended-Upgrade::OnlyOnACPower "{{ unattended_only_on_ac_power }}";

0 comments on commit d3eeca8

Please sign in to comment.