From dba0023940f632962f4581fd92a13aa7c7cebafb Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Thu, 19 Mar 2015 14:54:59 -0700 Subject: [PATCH] Add missing import of apt.debfile In cases when the python-apt package is not installed, ansible will attempt to install it. After this attempt, it tries to import the needed apt modules, but forgets to import the apt.debfile module. The result is that playbooks that use the dpkg argument on a machine that does not initially have the python-apt package available will fail with the following error AttributeError: 'module' object has no attribute 'debfile' This patch adds the appropriate import to the apt module to ensure that necessary libraries are available in cases when the dpkg argument is being used on a system that does not initially have the python-apt package installed --- packaging/os/apt.py | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/os/apt.py b/packaging/os/apt.py index 8730e22e35d..98fe79d624d 100644 --- a/packaging/os/apt.py +++ b/packaging/os/apt.py @@ -523,6 +523,7 @@ def main(): module.run_command('apt-get update && apt-get install python-apt -y -q', use_unsafe_shell=True, check_rc=True) global apt, apt_pkg import apt + import apt.debfile import apt_pkg except ImportError: module.fail_json(msg="Could not import python modules: apt, apt_pkg. Please install python-apt package.")