(maint) Set DEBIAN_FRONTEND=noninteractive on upgrade
authorRomain Tartière <romain@blogreen.org>
Wed, 25 Aug 2021 01:22:51 +0000 (15:22 -1000)
committerRomain Tartière <romain@blogreen.org>
Wed, 25 Aug 2021 01:26:16 +0000 (15:26 -1000)
When upgrading Debian packages, the system sometimes what to prompt the
user about what action to perform.  Since a tasks is supposed to be
non-interactive, we should disable such prompts.

This help when updating some packages, e.g. postfix.

tasks/init.rb

index 43053128a25dbd1edad4a4f041424df26c17f338..237da9b0b66c60a1e03aa855f5edb2a2268d4f8a 100755 (executable)
@@ -8,6 +8,7 @@ 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)
   stdout, stderr, status = Open3.capture3(*cmd)
   raise Puppet::Error, stderr if status != 0
   { status: stdout.strip }