diff --git a/library/packaging/apt b/library/packaging/apt
index 37856074c96..a882c43c4aa 100644
--- a/library/packaging/apt
+++ b/library/packaging/apt
@@ -151,25 +151,26 @@ def package_status(m, pkgname, version, cache, state):
         if state == 'install':
             m.fail_json(msg="No package matching '%s' is available" % pkgname)
         else:
-            return False, False
+            return False, False, False
+    has_files = len(pkg.installed_files) > 0
     if version:
         try :
-            return pkg.is_installed and fnmatch.fnmatch(pkg.installed.version, version), False
+            return pkg.is_installed and fnmatch.fnmatch(pkg.installed.version, version), False, has_files
         except AttributeError:
             #assume older version of python-apt is installed
-            return pkg.isInstalled and fnmatch.fnmatch(pkg.installedVersion, version), False
+            return pkg.isInstalled and fnmatch.fnmatch(pkg.installedVersion, version), False, has_files
     else:
         try :
-            return pkg.is_installed, pkg.is_upgradable
+            return pkg.is_installed, pkg.is_upgradable, has_files
         except AttributeError:
             #assume older version of python-apt is installed
-            return pkg.isInstalled, pkg.isUpgradable
+            return pkg.isInstalled, pkg.isUpgradable, has_files
 
 def install(m, pkgspec, cache, upgrade=False, default_release=None, install_recommends=True, force=False):
     packages = ""
     for package in pkgspec:
         name, version = package_split(package)
-        installed, upgradable = package_status(m, name, version, cache, state='install')
+        installed, upgradable, has_files = package_status(m, name, version, cache, state='install')
         if not installed or (upgrade and upgradable):
             packages += "'%s' " % package
 
@@ -203,8 +204,8 @@ def remove(m, pkgspec, cache, purge=False):
     packages = ""
     for package in pkgspec:
         name, version = package_split(package)
-        installed, upgradable = package_status(m, name, version, cache, state='remove')
-        if installed:
+        installed, upgradable, has_files = package_status(m, name, version, cache, state='remove')
+        if installed or (has_files and purge):
             packages += "'%s' " % package
 
     if len(packages) == 0: