On 06.12.2017 12:13, Python Guru wrote:
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
---
var: firstname
var1: '{{ var }}_lastname'
test.yml
---
- hosts: localhost
tasks:
- include_vars: vars.yml
- debug: var=var
- debug: var=var1
$ ansible-playbook test.yml
PLAY [localhost] ******************
TASK [include_vars] ***************
ok: [localhost]
TASK [debug] **********************
ok: [localhost] => {
"var": "firstname"
}
TASK [debug] **********************
ok: [localhost] => {
"var1": "firstname_lastname"
}
--
Kai Stian Olstad
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/20d4881929b9fedc586eae8c494b7385%40olstad.com.
For more options, visit https://groups.google.com/d/optout.