From 287daf99788ff39dd9376b6c4acb8fe0353fa78e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Romain=20Tarti=C3=A8re?= Date: Mon, 6 Sep 2021 11:31:41 -1000 Subject: [PATCH] (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. --- tasks/init.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tasks/init.rb b/tasks/init.rb index 237da9b..86367d9 100755 --- a/tasks/init.rb +++ b/tasks/init.rb @@ -8,7 +8,13 @@ require 'puppet' def apt_get(action) cmd = ['apt-get', action] cmd << '-y' if ['upgrade', 'dist-upgrade', 'autoremove'].include?(action) - ENV['DEBIAN_FRONTEND'] = 'noninteractive' if ['upgrade', 'dist-upgrade'].include?(action) + if ['upgrade', 'dist-upgrade'].include?(action) + ENV['DEBIAN_FRONTEND'] = 'noninteractive' + cmd << '-o' + cmd << 'Dpkg::Options="--force-confdef"' + cmd << '-o' + cmd << 'Dpkg::Options="--force-confold"' + end stdout, stderr, status = Open3.capture3(*cmd) raise Puppet::Error, stderr if status != 0 { status: stdout.strip } -- 2.45.2