Skip to content

Commit

Permalink
Support passing dpkg options (voxpupuli#251)
Browse files Browse the repository at this point in the history
* Support passing dpkg options

* Formatting

Co-authored-by: Kenyon Ralph <[email protected]>

---------

Co-authored-by: Kenyon Ralph <[email protected]>
  • Loading branch information
deric and kenyon authored Oct 19, 2024
1 parent 0bb7581 commit 37694ca
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ altering some of the default settings.
* `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`.
* `allow_downgrade` (`undef`): Allow package downgrade if Pin-Priority exceeds 1000. Default is `false`.
* `dpkg_options` (`[]`): Pass options to `dpkg`

Force dpkg to keep the old configuration files:

```puppet
class { 'unattended_upgrades':
dpkg_options => ['--force-confold'],
}
## Limitations
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
Optional[Boolean] $only_on_ac_power = undef,
Optional[Boolean] $whitelist_strict = undef,
Optional[Boolean] $allow_downgrade = undef,
Array[String[1]] $dpkg_options = [],
) inherits unattended_upgrades::params {
# apt::conf settings require the apt class to work
include apt
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 @@ -78,6 +78,7 @@
only_on_ac_power: false,
whitelist_strict: true,
allow_downgrade: false,
dpkg_options: ['--force-confold', '--force-confdef'],
}
end

Expand Down Expand Up @@ -147,6 +148,8 @@
%r{Unattended-Upgrade::OnlyOnACPower "false";}
).with_content(
%r{Unattended-Upgrade::Allow-downgrade "false";}
).with_content(
%r{DPkg::Options\s+\{\n\s+"--force-confold";\n\s+"--force-confdef";\n\};}
)
end

Expand Down
8 changes: 8 additions & 0 deletions templates/unattended-upgrades.erb
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,11 @@ Unattended-Upgrade::OnlyOnACPower "<%= @only_on_ac_power %>";
// Allow package downgrade if Pin-Priority exceeds 1000
Unattended-Upgrade::Allow-downgrade "<%= @allow_downgrade %>";
<%- end -%>
<%- unless @dpkg_options.empty? -%>
DPkg::Options {
<% @dpkg_options.each do |opt| -%>
"<%= opt %>";
<%- end -%>
};
<%- end -%>

0 comments on commit 37694ca

Please sign in to comment.