Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package module pass list of packages to apt_rpm that is converted to string as is and not supported #143

Closed
amleshkov opened this issue Apr 9, 2020 · 5 comments · Fixed by #169
Labels
bug This issue/PR relates to a bug has_pr module module

Comments

@amleshkov
Copy link
Contributor

amleshkov commented Apr 9, 2020

SUMMARY

apt_rpm does not support install packages provided as list, only as comma delimited string. So package module does not work with apt_rpm

ISSUE TYPE
  • Bug Report
COMPONENT NAME

apt_rpm

ANSIBLE VERSION
ansible 2.8.8

CONFIGURATION

OS / ENVIRONMENT
STEPS TO REPRODUCE

Use simple playbook that install list of packages on Altlinux

- name: install packages
  package:
    name:
        - nginx
        - vim
EXPECTED RESULTS

Packages succesfully installed by invoking apt_rpm

ACTUAL RESULTS
TASK [install_packages : install packages] *************************************
fatal: [host-1]: FAILED! => changed=false
  msg: |-
    'apt-get -y install  'vim']' failed: E: Regex compilation error - Unmatched [ or [^

It is because:

[WARNING]: The value ['nginx', 'vim'] (type list) in a string field was converted to u"['nginx', 'librdkafka']" (type string). If this does not look like what you expect, quote the entire value to ensure it does not change.
@felixfontein
Copy link
Collaborator

The module expects a string, not a list as its param. It's probably better to fix the param type from str to list and make sure lists are handled correctly.

@amleshkov
Copy link
Contributor Author

The module expects a string, not a list as its param. It's probably better to fix the param type from str to list and make sure lists are handled correctly.

Changing type break behavior of existing playbooks with single package name provided in module

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added affects_2.10 bug This issue/PR relates to a bug has_pr module module labels Apr 9, 2020
@felixfontein
Copy link
Collaborator

Changing type break behavior of existing playbooks with single package name provided in module

That's true in general, but not in this case: type: list also accepts strings, and splits them by commas to create a list. Since the module currently does this manually, the behavior does not change for existing correct use-cases. What does change is that now the module will also work when lists are passed.

@ansibullbot
Copy link
Collaborator

amleshkov added a commit to amleshkov/community.general that referenced this issue Jun 3, 2020
felixfontein added a commit that referenced this issue Jun 17, 2020
* Fixes #143, change package parameter from str to list

* remove uneccessary splitting

* add changelog fragment

* fix parameter-list-no-elements validation

* fix documentation

* Fix changelog

* Fix documetation, add example with list of packages

* Update changelogs/fragments/apt_rpm_typefix.yml

Co-authored-by: Alexander Leshkov <lam@arenadata.io>
Co-authored-by: Felix Fontein <felix@fontein.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug has_pr module module
Projects
None yet
3 participants