oravirt / ansible-oracle-modules

Oracle modules for Ansible
MIT License
214 stars 160 forks source link

oracle_pdb connect string is invalid #50

Closed willievu closed 6 years ago

willievu commented 6 years ago

When oracle_pdb calls cx_Oracle.makedsn(), it specifies the container database as service_name.

dsn = cx_Oracle.makedsn(host=hostname, port=port, service_name=service_name)

It generates an invalid conn string and causes this error.

"msg": "Could not connect to database - ORA-12514: TNS:listener does not currently know of service requested in connect descriptor, connect descriptor: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=cdb12c)))"

The call to makedsn() should specify the container database as sid, not service_name, like follows.

dsn = cx_Oracle.makedsn(host=hostname, port=port, sid=service_name)

oravirt commented 6 years ago

The problem you seem to have is that your host= is empty. (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=cdb12c)))

This works perfectly fine with service_name=service_name. I use it all the time...

willievu commented 6 years ago

Thanks. I figured out the problem. My SID needs to have the domain name as well, e.g. cdb12c.world.