I am trying to orchestrate a database replication setup. This means I need to read configuration details from the master node, and apply this on the slave to facilitate the replication setup.
I try to read a configuration value, which works (master has ‘primary’ set to true):
- name: get audit file dest from database
action: “shell export ORACLE_SID={{ oracle_sid }}; export ORACLE_HOME={{ oracle_home }}; printf "set head off\nselect value from v\$parameter where name = ‘audit_file_dest’;" | $ORACLE_HOME/bin/sqlplus -S / as sysdba | grep -v ^$”
when: primary
register: audit_file_dest
Then I try to apply the value on the slave (slave has ‘standby’ set to true):
- name: create audit file dest on standby
file: path={{ audit_file_dest.stdout }} state=directory
when: standby
This is how the execution looks like:
TASK: [get audit file dest from database] *************************************
skipping: [192.168.39.142]
changed: [192.168.39.139]
TASK: [create audit file dest on standby] *************************************
skipping: [192.168.39.139]
fatal: [192.168.39.142] => One or more undefined variables: ‘dict object’ has no attribute ‘stdout’
When using the debug module, I see the problem:
TASK: [debug var=audit_file_dest] *********************************************
ok: [192.168.39.142] => {
“audit_file_dest”: {
“changed”: false,
“skipped”: true
}
}
ok: [192.168.39.139] => {
“audit_file_dest”: {
“changed”: true,
“cmd”: “export ORACLE_SID=test; export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1; printf "set head off\nselect value from v\$parameter where name = ‘audit_file_dest’;" | $ORACLE_HOME/bin/sqlplus -S / as sysdba | grep -v ^$”,
“delta”: “0:00:00.035030”,
“end”: “2014-12-24 15:54:41.230344”,
“invocation”: {
“module_args”: “export ORACLE_SID=test; export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1; printf "set head off\nselect value from v\$parameter where name = ‘audit_file_dest’;" | $ORACLE_HOME/bin/sqlplus -S / as sysdba | grep -v ^$”,
“module_name”: “shell”
},
“rc”: 0,
“start”: “2014-12-24 15:54:41.195314”,
“stderr”: “”,
“stdout”: “/u01/app/oracle/admin/test/adump”,
“stdout_lines”: [
“/u01/app/oracle/admin/test/adump”
],
“warnings”:
}
}
Because I try to use the variable on an host on which the variable was not filled, there is not stdout for it.
How can I simply obtain a value on one host for use on another? In this case I would love to make the registered variable contents global.
It can’t be that this is a unique situation? Or is there another way that I should do this?
Thanks