From b950f9456ad6c5fd7d42d23cbc4a952ac06a25b0 Mon Sep 17 00:00:00 2001
From: Alan Grosskurth <code@alan.grosskurth.ca>
Date: Mon, 5 Aug 2013 15:20:45 -0700
Subject: [PATCH] apt: Run remove commands noninteractively

I'm seeing ansible hang when trying to remove a package, and the hung
process is `whiptail` like in #2763. It looks like we only use
`APT_ENVVARS` and `DPKG_OPTIONS` for the `apt` commands in install()
and upgrade(). This change uses them in remove() as well, which fixes
the hang.
---
 library/packaging/apt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/library/packaging/apt b/library/packaging/apt
index d93835f5ae6..27c0ca4f920 100644
--- a/library/packaging/apt
+++ b/library/packaging/apt
@@ -218,7 +218,7 @@ def remove(m, pkgspec, cache, purge=False):
             purge = '--purge'
         else:
             purge = ''
-        cmd = "%s -q -y %s remove %s" % (APT_GET_CMD, purge,packages)
+        cmd = "%s %s -q -y %s %s remove %s" % (APT_ENVVARS, APT_GET_CMD, DPKG_OPTIONS, purge, packages)
 
         if m.check_mode:
             m.exit_json(changed=True)