In Ansible, when I need to read properties from a Java properties file (.properties
), I do something like:
- name: Read properties
set_fact:
myProp1: {{ lookup('ini', 'myProp1 type=properties file=/path/to/file.properties }}
myProp2: {{ lookup('ini', 'myProp2 type=properties file=/path/to/file.properties }}
But, as Ansible documentation says:
Lookups occur on the local computer, not on the remote computer.
How can I do it if the properties file is located in remote target host? I can't use include_vars, since my properties file has Java properties file format.
As you observed,
lookup
is local. One possible solution is I used which may not work in all situations is to fetch it locally and then call lookup. Make sure you read about fetch module before attempting this:CAUTION: This is just a workaround, not a solution.