Variable Definition Question

42 views
Skip to first unread message

Jamal B

unread,
Oct 24, 2014, 1:59:48 PM10/24/14
to ansible...@googlegroups.com
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?

Michael DeHaan

unread,
Oct 24, 2014, 8:03:33 PM10/24/14
to ansible...@googlegroups.com
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.



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/96087981-b05d-482f-a30a-e9bbeb03715c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages