I am writing an Ansible role that installs and updates some specific enterprise software. I would like to compare the installed version (if it is installed) to the one I am
Seems like a use case for facts.d.
Write a shell or Python script that inspects those ini files and dumps required fields as JSON object to stdout.
Place this script into /etc/ansible/facts.d/custom_soft.fact
and make it executable.
Then you can use these facts as follows:
- shell: install_custom_soft.sh
when: ansible_local.custom_soft.component_ver | int > 4
If your ini files are very simple, you may do the job even without script, just make a link like this:
ln -s /etc/custom_soft/config.ini /etc/ansible/facts.d/custom_soft.fact
and all config.ini keys will be available to Ansible via ansible_local.custom_soft
variable.
P.S. Despite the name "local facts" this should be done on remote machine.