Skip to content

Commit

Permalink
Merge pull request #255 from mlibrary/metered
Browse files Browse the repository at this point in the history
Add skip_updates_on_metered_connection option
  • Loading branch information
smortex authored Dec 23, 2024
2 parents 9037488 + 5ec3813 commit f40854f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ altering some of the default settings.
* `syslog_enable` (`undef`): Enable logging to syslog. Default is False.
* `syslog_facility` (`undef`): Specify syslog facility. Default is `daemon`.
* `only_on_ac_power` (`undef`): Download and install upgrades only on AC power. Default is `true`.
* `skip_updates_on_metered_connection` (`undef`): Download and install upgrades only on non-metered connection. Default is `true`.
* `allow_downgrade` (`undef`): Allow package downgrade if Pin-Priority exceeds 1000. Default is `false`.
* `dpkg_options` (`[]`): Pass options to `dpkg`

Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
Optional[Boolean] $syslog_enable = undef,
Optional[String] $syslog_facility = undef,
Optional[Boolean] $only_on_ac_power = undef,
Optional[Boolean] $skip_updates_on_metered_connection = undef,
Optional[Boolean] $whitelist_strict = undef,
Optional[Boolean] $allow_downgrade = undef,
Array[String[1]] $dpkg_options = [],
Expand Down
3 changes: 3 additions & 0 deletions spec/classes/unattended_upgrades_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
syslog_enable: true,
syslog_facility: 'daemon',
only_on_ac_power: false,
skip_updates_on_metered_connection: false,
whitelist_strict: true,
allow_downgrade: false,
dpkg_options: ['--force-confold', '--force-confdef'],
Expand Down Expand Up @@ -146,6 +147,8 @@
%r{Unattended-Upgrade::SyslogFacility "daemon";}
).with_content(
%r{Unattended-Upgrade::OnlyOnACPower "false";}
).with_content(
%r{Unattended-Upgrade::Skip-Updates-On-Metered-Connections "false";}
).with_content(
%r{Unattended-Upgrade::Allow-downgrade "false";}
).with_content(
Expand Down
6 changes: 6 additions & 0 deletions templates/unattended-upgrades.erb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ Unattended-Upgrade::SyslogFacility "<%= @syslog_facility %>";
Unattended-Upgrade::OnlyOnACPower "<%= @only_on_ac_power %>";
<%- end -%>

<%- unless @skip_updates_on_metered_connection.nil? -%>
// Download and install upgrades only on non-metered connection
// (i.e. skip or gracefully stop updates on a metered connection)
Unattended-Upgrade::Skip-Updates-On-Metered-Connections "<%= @skip_updates_on_metered_connection %>";
<%- end -%>

<%- unless @allow_downgrade.nil? -%>
// Allow package downgrade if Pin-Priority exceeds 1000
Unattended-Upgrade::Allow-downgrade "<%= @allow_downgrade %>";
Expand Down

0 comments on commit f40854f

Please sign in to comment.