mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 14:41:23 -07:00
Better handling of package groups in pacman module
This commit is contained in:
parent
ac8b171da4
commit
876fe06290
1 changed files with 20 additions and 1 deletions
|
@ -267,6 +267,25 @@ def check_packages(module, pacman_path, packages, state):
|
||||||
module.exit_json(changed=False, msg="package(s) already %s" % state)
|
module.exit_json(changed=False, msg="package(s) already %s" % state)
|
||||||
|
|
||||||
|
|
||||||
|
def expand_package_groups(module, pacman_path, pkgs):
|
||||||
|
expanded = []
|
||||||
|
|
||||||
|
for pkg in pkgs:
|
||||||
|
cmd = "%s -Sgq %s" % (pacman_path, pkg)
|
||||||
|
rc, stdout, stderr = module.run_command(cmd, check_rc=False)
|
||||||
|
|
||||||
|
if rc == 0:
|
||||||
|
# A group was found matching the name, so expand it
|
||||||
|
for name in stdout.split('\n'):
|
||||||
|
name = name.strip()
|
||||||
|
if name:
|
||||||
|
expanded.append(name)
|
||||||
|
else:
|
||||||
|
expanded.append(pkg)
|
||||||
|
|
||||||
|
return expanded
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
|
@ -305,7 +324,7 @@ def main():
|
||||||
upgrade(module, pacman_path)
|
upgrade(module, pacman_path)
|
||||||
|
|
||||||
if p['name']:
|
if p['name']:
|
||||||
pkgs = p['name']
|
pkgs = expand_package_groups(module, pacman_path, p['name'])
|
||||||
|
|
||||||
pkg_files = []
|
pkg_files = []
|
||||||
for i, pkg in enumerate(pkgs):
|
for i, pkg in enumerate(pkgs):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue