diff --git a/changelogs/fragments/55741-apt-names-strip-whitespaces.yaml b/changelogs/fragments/55741-apt-names-strip-whitespaces.yaml new file mode 100644 index 0000000000..a7884ec150 --- /dev/null +++ b/changelogs/fragments/55741-apt-names-strip-whitespaces.yaml @@ -0,0 +1,2 @@ +bugfixes: + - apt - strip whitespaces in package names (https://github.com/ansible/ansible/issues/55741) diff --git a/lib/ansible/modules/packaging/os/apt.py b/lib/ansible/modules/packaging/os/apt.py index 3f488fcb2a..41c3bc5b67 100644 --- a/lib/ansible/modules/packaging/os/apt.py +++ b/lib/ansible/modules/packaging/os/apt.py @@ -1129,7 +1129,7 @@ def main(): force=force_yes, dpkg_options=p['dpkg_options']) unfiltered_packages = p['package'] or () - packages = [package for package in unfiltered_packages if package != '*'] + packages = [package.strip() for package in unfiltered_packages if package != '*'] all_installed = '*' in unfiltered_packages latest = p['state'] == 'latest'