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
Need ansible.builtin.dpkg_selections to hold package even if not already installed #83087
Comments
Files identified in the description: If these files are incorrect, please update the |
I'm not sure this is true, in my tests |
@bcoca Thank you for your quick reply! I haven't tried using |
I might have been a bit premature since my debian based distros are pretty updated and there is no Python2 available, so its 'non existant', but i kept testing other cases, of which i've found 4:
I'll push a fix for this last case. |
This would also be fairly trivial to implement with just running - name: Get list of packages on hold
command: apt-mark showhold
register: apt_mark_hold
changed_when: false
- name: Set hold for python2.7-minimal
command: apt-mark hold python2.7-minimal
when: '"python2.7-minimal" not in apt_mark_hold.stdout' |
Same problem with the elasticsearch ansible role (yes, I know, old one, but afaik there isn't another better, so...):
this fails too with "Failed to find package 'elasticsearch' to perform selection 'install'." when no elasticsearch package is installed because initial install (some years ago) was flawless and since then was only "checked", probably it's an old "bug/feature" in ansible, glad that at least one person had the same issue. I agree that it's kind of unusual to hold/unhold a non-existent package, but it worked (not sure that the package name should be a t least a debian package or any string would match ok). |
i've been testing this and sadly i get different results on different versions of Debian and Debian derivatives. Some allow any package name to be held w/o error, so it won't catch misspellings, other versions ONLY allow packages they recognize so they need to be in the local cache. I'm not sure we should bypass this behavior as it opens up many doors to user error and complexity in tracking the different underlying responses from the tool. |
Summary
When I try to use ansible.builtin.dpkg_selections to put a hold on python2.7-minimal (or any python2.7 package) in Ubuntu 22.04.4 it fails. This appears to be related to dpkg_selections: Check if package exists before selection operation. I would expect dpkg_selections to be able to put holds on any package in the repos regardless of whether it is installed or not, similar to how
apt-mark hold
works manually. My goal is to prevent the installation of python2.7.Issue Type
Bug Report
Component Name
dpkg_selections
Ansible Version
Configuration
OS / Environment
Both the control machine and the target are Ubuntu 22.04.4
Steps to Reproduce
Vars:
Play:
Expected Results
I expect the package python2.7-minimal to be held even if it's not installed, similar to how
apt-mark hold python2.7-minimal
works.Actual Results
Code of Conduct
The text was updated successfully, but these errors were encountered: