Giter Club home page Giter Club logo

Comments (7)

bcoca avatar bcoca commented on July 20, 2024 1

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:

  • package exists, is in dpkg cache and selections are available, action works fine, matches dpkg
  • package does not exist anywhere, action works fine, matches dpkg
  • package exists in repository, but dpkg cache was not updated, so action reacts as if it didnt exist, i think this is still correct and matches dpkg
  • package exists in repo and dpkg cache, but was never in selections, in this case action incorrectly treats as non existant but dpkg itself does work.

I'll push a fix for this last case.

from ansible.

sivel avatar sivel commented on July 20, 2024 1

This would also be fairly trivial to implement with just running apt-mark:

- 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'

from ansible.

bcoca avatar bcoca commented on July 20, 2024 1

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.

from ansible.

ansibot avatar ansibot commented on July 20, 2024

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the component bot command.

from ansible.

bcoca avatar bcoca commented on July 20, 2024

I'm not sure this is true, in my tests dpkg --set-selections fails to hold a package if the name is for an unknown package. I think you are confusing an 'existing' package vs an installed one.

https://wiki.debian.org/Teams/Dpkg/FAQ#set-selections

from ansible.

rclilly avatar rclilly commented on July 20, 2024

@bcoca Thank you for your quick reply! I haven't tried using dpkg --set-selections, only apt-mark hold, which works. If this module uses dpkg, and it can't do this task, then is there a way to accomplish this with the apt module?

from ansible.

alexcernat avatar alexcernat commented on July 20, 2024

Same problem with the elasticsearch ansible role (yes, I know, old one, but afaik there isn't another better, so...):

- name: Debian - unhold elasticsearch version
  become: yes
  dpkg_selections:
    name: "{{ es_package_name }}"
    selection: "install"
  when: not es_version_lock or (installed_es_version.stdout and installed_es_version.stdout != es_version)

this fails too with "Failed to find package 'elasticsearch' to perform selection 'install'." when no elasticsearch package is installed
(debian 12 / ansible-core 2.16.5-1ppa)

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).

from ansible.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.