From 800ca63de68816fb7c46446b38f827935e4e4d15 Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Wed, 24 Apr 2013 12:02:05 +0200 Subject: [PATCH] enforce no enteractiveness installing pkg with apt use the same env vars and dpkg options as for the upgrade function also link check mode to --simulate option when installing a pkg fixes #2763 --- library/apt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/library/apt b/library/apt index 01cab4bff3e..bd47037446f 100644 --- a/library/apt +++ b/library/apt @@ -154,15 +154,18 @@ def install(m, pkgspec, cache, upgrade=False, default_release=None, install_reco else: force_yes = '' - cmd = "%s --option Dpkg::Options::=--force-confold -q -y %s install %s" % (APT_GET_CMD, force_yes, packages) + if m.check_mode: + check_arg = '--simulate' + else: + check_arg = '' + + cmd = "%s %s -y %s %s %s install %s" % (APT_ENVVARS, APT_GET_CMD, DPKG_OPTIONS, force_yes, check_arg, packages) + if default_release: cmd += " -t '%s'" % (default_release,) if not install_recommends: cmd += " --no-install-recommends" - if m.check_mode: - m.exit_json(changed=True) - rc, out, err = m.run_command(cmd) if rc: m.fail_json(msg="'apt-get install %s' failed: %s" % (packages, err))