Variable Definition Question

All, I’m new to Ansible so forgive me if this is already answered as I was unable to find a solution with my research.

I have an application which uses a Java properties file (/usr/local/app/app.properties) which contains key/value pairs like so:

THRESHOLD=75
NUM_THREADS=3
REAPER_COUNT=1

The application requires some environment setup which is currently performed by a shell script that I’m converting over to an Ansible playbook. I would like to reference the value of these properties in the tasks for the playbook like normal e.g.

  • shell: app_setup {{ THRESHOLD }}

but can’t seem to figure out a way to do so. I have tried the following to register the value of a property like so (which works):

  • shell: grep THRESHOLD /usr/local/app/app.properties | cut -d “=” -f2
    register: THRESHOLD

But the above requires me to remember to use {{ THRESHOLD.stdout }} every time which I would like to avoid as I’m sure to forget this when used over time. I looked at the Lookups options in the documentation but do not see a way to use it to accomplish what I would like. Is there a way to register an Ansible variable from the value of a straight forward key/value file?

You should probably define all the variables for the properties file instead, and maybe consider ansible templating the properties file as an ansible template to avoid dual entry.