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 6/2.13] apt module segmentation fault on package removal #79452
Comments
Files identified in the description: If these files are incorrect, please update the |
Tested Ansible 7/2.14 today. Same result:
|
Ok, after like 4 hours of troubleshooting this, I can confirm that this was introduced by 4a62c4e The line(s) that cause the failure is: ansible/lib/ansible/modules/apt.py Lines 505 to 509 in 3723c42
Effectively, I'm not going to look any deeper into why the The
At a minimum, this seems to resolve the problem: diff --git a/lib/ansible/modules/apt.py b/lib/ansible/modules/apt.py
index ba0aed050d..22207ec160 100644
--- a/lib/ansible/modules/apt.py
+++ b/lib/ansible/modules/apt.py
@@ -568,6 +568,9 @@ def package_status(m, pkgname, version_cmp, version, default_release, cache, sta
# assume older version of python-apt is installed
package_is_installed = pkg.isInstalled
+ if not package_is_installed and state == 'remove':
+ return False, None, None, False
+
version_best = package_best_match(pkgname, version_cmp, version, default_release, cache._cache)
version_is_installed = False
version_installable = None Although I haven't taken the time, nor do I plan to, verify any negative side effects of this change. At this point, this is available for anyone else who wants to take this on, to evaluate a fix, and into the potential cause in more depth than I already have. |
I have tried the fix idea against some of our Jessie and Stretch hosts that were affected by the issue: Looks good so far. |
Thank you @sivel, I confirm this fix works for Debian buster hosts. |
Works for me as well @sivel |
I can confirm ansible [core 2.13.2] via pip on Debian Bullseye: segfault on package removal The fix works for me also @sivel thank you :) |
Is there anything holding up merging this fix? |
on ansible 2.15.0 and 2.15.3 (pip), Debian bookworm I am not able to reproduce this behavior anymore : everything works fine. |
I'm on Manjaro and firing against a variety of Debian/Ubuntu hosts, on Ubuntu 18.04 the same issue can be observed. The solution from @sivel is working, so I stick with it for now. Thank you Systemwide Ansible
venv/pip
error is the same on both versions:
|
I can also confirm that issue with:
I apply the role on a Debian Buster. The task fails with:
Error:
The patch of @sivel also works for me so far (= Edit: Add host |
Summary
When moving from Ansible 5/2.12 to 6/2.13 we encountered the
apt
module running into a segmentation fault when package state "absent" was used to remove packages that are no longer installed. The issue occurred on target hosts running on Debian 8 (Jessie), 9 (Stretch) and 10 (Buster).We managed to re-create the issue on Vagrant and after some testing came the conclusion that these conditions must be met to produce the error:
The package were not purged but just removed using "absent".
The apt sources list file that defined the repo the package came from is no longer present on the system
The packages involved have "depends" relationship between them
The sample playbook below re-creates the aforementioned conditions using packages from the publicly available Zabbix repository. Originally, the issue occurred using company internal packages, but once we figured out what might go wrong, we managed to re-produce it :-).
Some other things we found while toying with this:
Issue Type
Bug Report
Component Name
apt
Ansible Version
Configuration
OS / Environment
Debian 8 (Jessie)
Debian 9 (Stretch)
Debian 10 (Buster)
Steps to Reproduce
Expected Results
apt
task should yield an "ok" as the packages are gone alreadyActual Results
Code of Conduct
The text was updated successfully, but these errors were encountered: