diff --git a/CHANGELOG.md b/CHANGELOG.md index b5399b76..ad357fe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This file is used to list changes made in each version of the apt cookbook. ## Unreleased +- Added attribute to control OnlyOnACPower unattended upgrades setting. + ## 7.5.22 - *2024-05-02* ## 7.5.21 - *2024-05-02* diff --git a/README.md b/README.md index f30360c5..6311f82e 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,7 @@ To pull just security updates, set `origins_patterns` to something like `["origi - `['apt']['unattended_upgrades']['random_sleep']` - Wait a random number of seconds up to this value before running daily periodic apt actions. System default is 1800 seconds (30 minutes). - `['apt']['unattended_upgrades']['syslog_enable']` - Enable logging to syslog. Defaults to false. - `['apt']['unattended_upgrades']['syslog_facility']` - Specify syslog facility. Defaults to 'daemon'. +- `['apt']['unattended_upgrades']['only_on_ac_power']` - Download and install upgrades only on AC power. Default is true. - `['apt']['unattended_upgrades']['dpkg_options']` An array of dpkg options to be used specifically only for unattended upgrades. Defaults to `[]` which will prevent it from being rendered from the template in the resulting file. ### Configuration for APT diff --git a/attributes/default.rb b/attributes/default.rb index 102f4e51..6bdaddd4 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -50,6 +50,7 @@ default['apt']['unattended_upgrades']['random_sleep'] = nil default['apt']['unattended_upgrades']['syslog_enable'] = false default['apt']['unattended_upgrades']['syslog_facility'] = 'daemon' +default['apt']['unattended_upgrades']['only_on_ac_power'] = true default['apt']['unattended_upgrades']['dpkg_options'] = [] diff --git a/templates/50unattended-upgrades.erb b/templates/50unattended-upgrades.erb index a183e63c..537c2a24 100644 --- a/templates/50unattended-upgrades.erb +++ b/templates/50unattended-upgrades.erb @@ -118,7 +118,7 @@ Dpkg::Options { // Download and install upgrades only on AC power // (i.e. skip or gracefully stop updates on battery) -// Unattended-Upgrade::OnlyOnACPower "true"; +Unattended-Upgrade::OnlyOnACPower "<%= node['apt']['unattended_upgrades']['only_on_ac_power'] ? 'true' : 'false' %>"; // Download and install upgrades only on non-metered connection // (i.e. skip or gracefully stop updates on a metered connection)