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.
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 }