diff --git a/changelogs/fragments/3526-pkgng-add-integration-tests.yml b/changelogs/fragments/3526-pkgng-add-integration-tests.yml index 53648082da..4c407d7694 100644 --- a/changelogs/fragments/3526-pkgng-add-integration-tests.yml +++ b/changelogs/fragments/3526-pkgng-add-integration-tests.yml @@ -1,3 +1,4 @@ bugfixes: - 'pkgng - `name=* state=latest` check for upgrades did not count "Number of packages to be reinstalled" as a `changed` action, giving incorrect results in both regular and check mode' - 'pkgng - PR #3393 (https://github.com/ansible-collections/community.general/pull/3393) broke `check_mode` so that the module always reports `not changed`; fix regression so module reports number of upgrade or install actions that would be performed' + - 'pkgng - The module will now convert a single space- or comma-separated name parameter to a list. The documentation had given wrong examples in which multiple space- or comma-separated packages were specified in the `name` parameter, rather than using correct YAML list syntax. `pkgng` module documentation has also been updated' diff --git a/plugins/modules/packaging/os/pkgng.py b/plugins/modules/packaging/os/pkgng.py index 27aceaba0b..0abcf80121 100644 --- a/plugins/modules/packaging/os/pkgng.py +++ b/plugins/modules/packaging/os/pkgng.py @@ -113,12 +113,16 @@ EXAMPLES = ''' - name: Annotate package foo and bar community.general.pkgng: - name: foo,bar + name: + - foo + - bar annotation: '+test1=baz,-test2,:test3=foobar' - name: Remove packages foo and bar community.general.pkgng: - name: foo,bar + name: + - foo + - bar state: absent # "latest" support added in 2.7 @@ -476,6 +480,12 @@ def main(): msgs.append(_msg) # Operate on named packages + if len(pkgs) == 1: + # The documentation used to show multiple packages specified in one line + # with comma or space delimiters. That doesn't result in a YAML list, and + # wrong actions (install vs upgrade) can be reported if those + # comma- or space-delimited strings make it to the pkg command line. + pkgs = re.split(r'[,\s]', pkgs[0]) named_packages = [pkg for pkg in pkgs if pkg != '*'] if p["state"] in ("present", "latest") and named_packages: _changed, _msg, _out, _err = install_packages(module, pkgng_path, named_packages,