I want to decide whether to reinstall an existing minikube if it has a version smaller then x.
Target is Debian 12, but my example package (minikube) is not a repository package, but was installed manually. Therefore package_facts (bein my first idea) apparently is the wrong hammer here.
I can extract the current version with a bash command minikube version | head -n1 | tail -n1 | cut -d ' ' -f 3 | sed 's/v//'.
This will allow you to run your own APT based repo, if you then add the package version you wish to have and configure the repo on all your target hosts, you can use ‘normal’ update playbooks to update your systems.
A word of caution if you’re running shell pipelines with things like “… | head -n 1 | …” and you also “set -o pipefail” as one is supposed to do. Some programs (I’m looking at you, “tar -tvf”) will fail when a downstream “head” quits listening after having seen sufficient data. And that will cause your pipeline to fail (even though it does what you want it to), and that will cause your task to fail.
“sed” on the other hand has the courtesy to absorb all the incoming data even if you’re only addressing the first line(s). We learned this the hard way, er, so you don’t have to.
You’re welcome!