I would like to include some ansible “when” conditions based on if a software package is greater than a value, ie when a package is greater than 8.2, perform a task such as stop a service, uninstall the package, copy a file, install a new version of the package
I have the below which shows the version of a package called “Double” if found
The results appear as this → ansible_facts.packages[‘Double’][0].version: 8.2.2
name: Gather the Package facts
package_facts:
manager: auto
tags:
dt-check
name: “Double Found result”
debug: var=ansible_facts.packages[‘Double’][0].version
when: “‘Double’ in ansible_facts.packages”
register: dtversion
tags:
dt-check
debug:
var: dtversion
tags:
dt-check
name: “Double Not-found result”
debug:
msg: “Double NOT found”
when: “‘Double’ not in ansible_facts.packages”
register: notfound
tags:
dt-check
debug:
var: notfound
tags:
dt-check
Thanks in advance for any ideas that you may suggest to me