|
|
|
|
@ -155,6 +155,7 @@ ansible_facts:
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils._text import to_native, to_text
|
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
|
from ansible.module_utils.common.process import get_bin_path
|
|
|
|
|
from ansible.module_utils.facts.packages import LibMgr, CLIMgr, get_all_pkg_managers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -189,6 +190,16 @@ class APT(LibMgr):
|
|
|
|
|
self._cache = self._lib.Cache()
|
|
|
|
|
return self._cache
|
|
|
|
|
|
|
|
|
|
def is_available(self):
|
|
|
|
|
''' we expect the python bindings installed, but if there is apt/apt-get give warning about missing bindings'''
|
|
|
|
|
we_have_lib = super(APT, self).is_available()
|
|
|
|
|
if not we_have_lib:
|
|
|
|
|
for exe in ('apt', 'apt-get'):
|
|
|
|
|
if get_bin_path(exe):
|
|
|
|
|
self.warnings.append('Found "%s" but python bindings are missing, so we cannot get package information.' % exe)
|
|
|
|
|
break
|
|
|
|
|
return we_have_lib
|
|
|
|
|
|
|
|
|
|
def list_installed(self):
|
|
|
|
|
return [pk for pk in self.pkg_cache.keys() if self.pkg_cache[pk].is_installed]
|
|
|
|
|
|
|
|
|
|
@ -299,11 +310,15 @@ def main():
|
|
|
|
|
if manager.is_available():
|
|
|
|
|
found += 1
|
|
|
|
|
packages.update(manager.get_packages())
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
if pkgmgr in module.params['manager']:
|
|
|
|
|
module.warn('Requested package manager %s was not usable by this module: %s' % (pkgmgr, to_text(e)))
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
for warning in getattr(manager, 'warnings', []):
|
|
|
|
|
module.warn(warning)
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
if pkgmgr in module.params['manager']:
|
|
|
|
|
module.warn('Failed to retrieve packages with %s: %s' % (pkgmgr, to_text(e)))
|
|
|
|
|
|