From a10e017d6e90b5a064fb4ae142f416c4f00ea21c Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Mon, 21 Oct 2013 16:39:18 +0200 Subject: [PATCH] apt: autoinstall python-apt if not available --- library/packaging/apt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/packaging/apt b/library/packaging/apt index 6ab2017186..28c933b694 100644 --- a/library/packaging/apt +++ b/library/packaging/apt @@ -322,7 +322,13 @@ def main(): ) if not HAS_PYTHON_APT: - module.fail_json(msg="Could not import python modules: apt, apt_pkg. Please install python-apt package.") + try: + module.run_command('apt-get install python-apt -y -q') + global apt, apt_pkg + import apt + import apt_pkg + except: + module.fail_json(msg="Could not import python modules: apt, apt_pkg. Please install python-apt package.") global APTITUDE_CMD APTITUDE_CMD = module.get_bin_path("aptitude", False)