Skip to content
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

Support passing dpkg options #251

Merged
merged 2 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 -%>
Loading