add alpine apk package manager to package_facts [wip] (#70587)

* add alpine apk package manager to package_facts
pull/70664/head
Julien 4 years ago committed by GitHub
parent e1a33a6a84
commit 57b548598c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- add support for alpine linux 'apk' package manager in package_facts

@ -19,8 +19,9 @@ options:
- The package manager used by the system so we can query the package information.
- Since 2.8 this is a list and can support multiple package managers per system.
- The 'portage' and 'pkg' options were added in version 2.8.
- The 'apk' option was added in version 2.11.
default: ['auto']
choices: ['auto', 'rpm', 'apt', 'portage', 'pkg', 'pacman']
choices: ['auto', 'rpm', 'apt', 'portage', 'pkg', 'pacman', 'apk']
required: False
type: list
strategy:
@ -376,6 +377,28 @@ class PORTAGE(CLIMgr):
return dict(zip(self.atoms, package.split()))
class APK(CLIMgr):
CLI = 'apk'
atoms = ['name', 'version']
def list_installed(self):
rc, out, err = module.run_command([self._cli, 'info', '-v'])
if rc != 0 or err:
raise Exception("Unable to list packages rc=%s : %s" % (rc, err))
return out.splitlines()
def get_package_details(self, package):
raw_pkg_details = {}
for line in package.splitlines():
m = re.match(r"([\w ].*?)-([0-9-\.]+[0-9a-z-\.]*-r[0-9]+)", to_native(line))
if m:
raw_pkg_details['name'] = m.group(1)
raw_pkg_details['version'] = m.group(2)
return raw_pkg_details
def main():
# get supported pkg managers

Loading…
Cancel
Save