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 trying to install, for various reasons, but mainly to be able to verify that installation is necessary and allowed before actually executing the installer. Both installer package and installation contain an INI-file which contains component versions as options (component_name=version
).
What is the proper way in Ansible to read some option(s) from some INI-file on remote node? As far as I understand:
ini_file
-module is meant for modifying target file, which is not what I want to do.- ini lookup is meant for files on controller, not on remote nodes.
I can see two possibilities here:
- Use
fetch
-module to get file from remote node to controller machine, then use ini lookup. - Use
command
orshell
-module, parse INI file using grep/sed/awk and register output.
The first option seems unnecessarily clumsy (although I do realize I may think about it in the wrong way). Second one seems a bit clumsy from another point of view (yet another INI-file parsing method), but I may be wrong here too. Right now I am leaning on the latter, but I can't help thinking that there must be an easier and more elegant way.