Skip to content

Commit

Permalink
2.7: yum/dnf: fail when space separated string of names (#47109) (#47414
Browse files Browse the repository at this point in the history
)

* yum/dnf: fail when space separated string of names (#47109)

* yum/dnf: fail when space separated string of names

* Groups allow spaces in names

(cherry picked from commit e8b6864)

* Add changelog
  • Loading branch information
mkrizek authored and abadger committed Oct 22, 2018
1 parent d130c16 commit 57c2563
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- yum/dnf - fail when space separated string of names (https://github.com/ansible/ansible/pull/47109)
9 changes: 9 additions & 0 deletions lib/ansible/module_utils/yumdnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ def __init__(self, module):
self.enablerepo = self.listify_comma_sep_strings_in_list(self.enablerepo)
self.exclude = self.listify_comma_sep_strings_in_list(self.exclude)

# Fail if someone passed a space separated string
# https://github.com/ansible/ansible/issues/46301
if any((' ' in name and '@' not in name for name in self.names)):
module.fail_json(
msg='It appears that a space separated string of packages was passed in '
'as an argument. To operate on several packages, pass a comma separated '
'string of packages or a list of packages.'
)

def listify_comma_sep_strings_in_list(self, some_list):
"""
method to accept a list of strings as the parameter, find any strings
Expand Down
5 changes: 3 additions & 2 deletions lib/ansible/modules/packaging/os/dnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
options:
name:
description:
- "A list of package names, or package specifier with version, like C(name-1.0)
- "A package name or package specifier with version, like C(name-1.0).
When using state=latest, this can be '*' which means run: dnf -y update.
You can also pass a url or a local path to a rpm file."
You can also pass a url or a local path to a rpm file.
To operate on several packages this can accept a comma separated string of packages or a list of packages."
required: true
aliases:
- pkg
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/modules/packaging/os/yum.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
See the C(allow_downgrade) documentation for caveats with downgrading packages.
- When using state=latest, this can be C('*') which means run C(yum -y update).
- You can also pass a url or a local path to a rpm file (using state=present).
To operate on several packages this can accept a comma separated list of packages or (as of 2.0) a list of packages.
To operate on several packages this can accept a comma separated string of packages or (as of 2.0) a list of packages.
aliases: [ pkg ]
exclude:
description:
Expand Down

0 comments on commit 57c2563

Please sign in to comment.