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

Ansible apt module unable to remove packages not in CURSTATE_INSTALLED #81154

Open
1 task done
ZachOldham opened this issue Jun 29, 2023 · 3 comments
Open
1 task done
Labels
affects_2.16 feature This issue/PR relates to a feature request. module This issue/PR relates to a module. P3 Priority 3 - Approved, No Time Limitation verified This issue has been verified/reproduced by maintainer

Comments

@ZachOldham
Copy link

ZachOldham commented Jun 29, 2023

Summary

The apt module never attempts to remove packages that are in a state other than CURSTATE_INSTALLED according to apt_pkg. This means that packages in any of CURSTATE_UNPACKED, CURSTATE_HALF_CONFIGURED, CURSTATE_HALF_INSTALLED, or CURSTATE_CONFIG_FILES cannot be removed using the ansible apt module.

All possible states can be seen here, and the state check can be seen here.

This was an issue for us as we had a package with a bad post install script that left the package in CURSTATE_HALF_CONFIGURED and were then unable to remove that package with ansible, and were forced to directly invoke apt remove via the ansible command module.

It may be unexpected behavior by ansible to remove packages in these other states, but at least having a configuration option so that it is possible to remove them would be greatly beneficial.

Issue Type

Feature Idea

Component Name

apt

Additional Information

Adding a configuration option to the apt module to allow removal of packages in these other states would allow packages that were badly installed to be removed by the ansible apt module. Currently, we have to update our playbook to use the ansible command module to directly run apt remove on this package in order to cover the case where the package is badly installed. It would be much better if we could natively use the apt module to accomplish this.

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibot
Copy link
Contributor

ansibot commented Jun 29, 2023

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.

click here for bot help

@ansibot ansibot added affects_2.16 feature This issue/PR relates to a feature request. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. labels Jun 29, 2023
@bcoca bcoca added P3 Priority 3 - Approved, No Time Limitation and removed needs_triage Needs a first human triage before being processed. labels Jun 29, 2023
@s-hertel
Copy link
Contributor

s-hertel commented Jul 5, 2023

@ZachOldham The purge option handles this, can you verify? has_files is true here https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/apt.py#L939 if /var/lib/dpkg/info/package_name.list can be read, which dpkg creates when processing the archive.

needs_info

@ansibot ansibot added the needs_info This issue requires further information. Please answer any outstanding questions. label Jul 5, 2023
@s-hertel s-hertel added the needs_verified This issue needs to be verified/reproduced by maintainer label Jul 6, 2023
@ZachOldham
Copy link
Author

@s-hertel It seems that the purge option does generally work for this, but it does not work for our specific use case. We do not want to remove the package configuration files or logs, and purge does remove them. I suppose that is probably not an issue for most people who run into this issue, and purge would probably work for them, so this may be a more niche feature request than I originally thought. We would, however, still like to see this config option.

@ansibot ansibot removed the needs_info This issue requires further information. Please answer any outstanding questions. label Jul 7, 2023
@s-hertel s-hertel added verified This issue has been verified/reproduced by maintainer and removed needs_verified This issue needs to be verified/reproduced by maintainer labels Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.16 feature This issue/PR relates to a feature request. module This issue/PR relates to a module. P3 Priority 3 - Approved, No Time Limitation verified This issue has been verified/reproduced by maintainer
Projects
None yet
Development

No branches or pull requests

4 participants