diff --git a/changelogs/fragments/apt_rpm_typefix.yml b/changelogs/fragments/apt_rpm_typefix.yml new file mode 100644 index 0000000000..72f185e667 --- /dev/null +++ b/changelogs/fragments/apt_rpm_typefix.yml @@ -0,0 +1,2 @@ +bugfixes: + - apt_rpm - fix ``package`` type from ``str`` to ``list`` to fix invoking with list of packages (https://github.com/ansible-collections/community.general/issues/143). diff --git a/plugins/modules/packaging/os/apt_rpm.py b/plugins/modules/packaging/os/apt_rpm.py index 86cd4d4599..e5156605fe 100644 --- a/plugins/modules/packaging/os/apt_rpm.py +++ b/plugins/modules/packaging/os/apt_rpm.py @@ -17,10 +17,13 @@ short_description: apt_rpm package manager description: - Manages packages with I(apt-rpm). Both low-level (I(rpm)) and high-level (I(apt-get)) package manager binaries required. options: - pkg: + package: description: - - name of package to install, upgrade or remove. + - list of packages to install, upgrade or remove. required: true + aliases: [ name, pkg ] + type: list + elements: str state: description: - Indicates the desired package state. @@ -41,6 +44,13 @@ EXAMPLES = ''' pkg: foo state: present +- name: Install packages foo and bar + apt_rpm: + pkg: + - foo + - bar + state: present + - name: Remove package foo apt_rpm: pkg: foo @@ -146,7 +156,7 @@ def main(): argument_spec=dict( state=dict(type='str', default='installed', choices=['absent', 'installed', 'present', 'removed']), update_cache=dict(type='bool', default=False, aliases=['update-cache']), - package=dict(type='str', required=True, aliases=['name', 'pkg']), + package=dict(type='list', elements='str', required=True, aliases=['name', 'pkg']), ), ) @@ -158,7 +168,7 @@ def main(): if p['update_cache']: update_package_db(module) - packages = p['package'].split(',') + packages = p['package'] if p['state'] in ['installed', 'present']: install_packages(module, packages)