Closed sosafe-bastian-bretagne closed 6 months ago
Hi :wave: thanks a lot for the very detailed issue report. I hadn't realized that dpkg did this. I think this should be fairly simple to fix by using something like dpkg-query --showformat '${Status} ${Version}\n' --show datadog-agent | grep installed | awk '{print $NF}'
. I'll do some testing and submit a PR when I have something solid.
I faced an issue where in the role code dpkg -s is used to find if the package is installed. Although if the package was installed using apt first, then uninstalled, dpkg will keep the agent in the cache. As the role will skip the install because it only looks for the output of the version and not the status it will still think that the agent is installed:
step to reproduce:
1. install the package (add repo and apt install ...)
2. uninstall the package using apt:
3. verify that dpkg still show the version despite package being uninstalled:
this time you can see that its uninstalled
as a result when running the role the following will happen:
Proposed solution: instead of checking only the version it could check the status too?