Write dynmaic variables in variable file and load into playbooks

Need suggestion on how to deal the below scenario, as i am working on a story about Oracle EBS clone,

for the Existing shell script project uses different conf files, where it exports the number of variables to linux environment to use it later dynamically in the scripts.

Ex:

target_master.conf looks like this in the existing shell script project

export LSID=echo ${TARGET_SID} | tr '[A-Z]' '[a-z]'
export TARGET_ORACLE_HOME=${DBBASEDIR}/base/product/oh1
export DBCONTEXTNAME=${TARGET_SID}_${DBSERVER}
export TNS_ADMIN=${TARGET_ORACLE_HOME}/network/admin/${DBCONTEXTNAME}
export INVENTORYDIR=${DBBASEDIR}/oraInventory

export DBFILEPATH=/u05/${LSID}/data

export LOGFILEPATH=/u02/${LSID}/redo

export ARCHLOGDEST=/u06/${LSID}/arc
#AP

export APCONTEXTNAME=${TARGET_SID}_${APSERVER}
export APINVDIR=${APBASEDIR}/oraInventory

The highlighted variables are exported and also used dynamically. As to store these variables, i
thought of going with variable(ex.yml) files keeping under vars folder according to ansible standards,
but in ansible how can i declare variables to get over this dynamic replacing of values.

I tried doing like below:

target_master.yml

TARGET_ORACLE_HOME: {{DBBASEDIR}}/base/product/oh1

TNS_ADMIN: {{TARGET_ORACLE_HOME}} /network/admin/ {{DBCONTEXTNAME}}

i tried googling it but not enough solutions to figure it out.

How can i make a n number of variables available for the ansible project and how can i dynamically assign
as i was trying to do as above.

ex:

var: firstname

var1: {{ var }}_lastname

The output of var1 should be like firstname_lastname. will this be possible, if yes, please suggest me.

Need suggestion on how to deal the below scenario, as i am working on a
story about Oracle EBS clone,
for the Existing shell script project uses different conf files, where it
exports the number of variables to linux environment to use it later
dynamically in the scripts.

Ex:
target_master.conf looks like this in the existing shell script project

export LSID=`echo ${TARGET_SID} | tr '[A-Z]' '[a-z]'`
export *TARGET_ORACLE_HOME*=${DBBASEDIR}/base/product/oh1
export *DBCONTEXTNAME*=${TARGET_SID}_${DBSERVER}
export TNS_ADMIN=${*TARGET_ORACLE_HOME*}/network/admin/${*DBCONTEXTNAME*}
export INVENTORYDIR=${DBBASEDIR}/oraInventory
export DBFILEPATH=/u05/${LSID}/data
export LOGFILEPATH=/u02/${LSID}/redo
export ARCHLOGDEST=/u06/${LSID}/arc
#AP
export APCONTEXTNAME=${TARGET_SID}_${APSERVER}
export APINVDIR=${APBASEDIR}/oraInventory

The highlighted variables are exported and also used dynamically. As to
store these variables, i
thought of going with variable(ex.yml) files keeping under vars folder
according to ansible standards,
but in ansible how can i declare variables to get over this dynamic
replacing of values.

I tried doing like below:

target_master.yml

*TARGET_ORACLE_HOME*: {{DBBASEDIR}}/base/product/oh1
TNS_ADMIN: {{*TARGET_ORACLE_HOME}*} /network/admin/ {{*DBCONTEXTNAME*}}

When { comes after a colon you need to put all of it in single or double quotes.

i tried googling it but not enough solutions to figure it out.

How can i make a n number of variables available for the ansible project
and how can i dynamically assign
as i was trying to do as above.

ex:

var: firstname
var1: {{ var }}_lastname

The output of var1 should be like firstname_lastname. will this be
possible, if yes, please suggest me.

It's difficult to give any pointer since you have not provided any error messages or explaining what's not working
By the way, this works:

vars.yml

Hi,

Whatever you said is working and i’m happy to see that it’s working. but what if i want to load the variable file into a ansible variable and then start taking out each variable
from the var file.

My Var file:

name: APPSERVER
var2: ‘{{ name }}_PROD’

My Playbook:

It looks like it changes behavior when name: is used on include_vars.

  - debug: var=stuff
This will fail

  - debug: var=vars['stuff']
This will work

Both of them should have worked so it must be a bug.

And when using name in the include_vars the variables doesn't get expanded.
I guess this is also a bug since it works without the name:.

so, how can i achieve the above thing then.