Skip to content

Commit 287daf9

Browse files
committed
(main) Do not prompt on configuration file update
When updating configuration file, apt by default prompt the user for the action to perform. Since we are running in a non-interactive context, skip these prompts: * `--force-confdef` ensure the configuration file is replaced by a newer version in the package if the previous package default configuration file was not modified; * `--force-confold` keep the configuration file as it is if it has been modified compared to the one shipped in the previous version of the package.
1 parent 97f6970 commit 287daf9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tasks/init.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
def apt_get(action)
99
cmd = ['apt-get', action]
1010
cmd << '-y' if ['upgrade', 'dist-upgrade', 'autoremove'].include?(action)
11-
ENV['DEBIAN_FRONTEND'] = 'noninteractive' if ['upgrade', 'dist-upgrade'].include?(action)
11+
if ['upgrade', 'dist-upgrade'].include?(action)
12+
ENV['DEBIAN_FRONTEND'] = 'noninteractive'
13+
cmd << '-o'
14+
cmd << 'Dpkg::Options="--force-confdef"'
15+
cmd << '-o'
16+
cmd << 'Dpkg::Options="--force-confold"'
17+
end
1218
stdout, stderr, status = Open3.capture3(*cmd)
1319
raise Puppet::Error, stderr if status != 0
1420
{ status: stdout.strip }

0 commit comments

Comments
 (0)