Reputation: 167
I am trying to fetch the variables which are stored in a variables.sh file like following in an Ansible playbook:
INSTALL_JBOSS=Y export INSTALL_JBOSS
INSTALL_DSS=Y export INSTALL_DSS
INSTALL_ESB=Y export INSTALL_ESB
INSTALL_JMS=N export INSTALL_JMS . . . .
In my playbook which is in yaml I am using the vars like this: <{{zipfile}}> where zipfile is the name of the variable. Usually thats how the variable values are implemented in a playbook. Now I want to use the value of the variable INSTALL_JBOSS which is 'Y' in the playbook but if I use {{INSTALL_JBOSS}} it doesn't recognize the value as its stored in a .sh file. On the other hand when I use the variables defined in a yaml file with "vars_files" option I can easily use them with this {{}}. But i cant do the same with a .sh file.
This .sh file has environment variables which I want to use in my playbook.
When I try to use a .sh file in var_files option and run the playbook, it gives the following error: ERROR! variable files must contain either a dictionary of variables, or a list o f dictionaries.
Any ideas?
Thanks
Upvotes: 0
Views: 190
Reputation: 2823
The above variable file can't be used directly in ansible as it is based on the shell syntax for variable sourcing.
My suggestion would be to use shell module source this file and do what you want to do.
Upvotes: 1