oravirt / ansible-oracle-modules

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

The problem of cx_Oracle #148

Closed HCLDREAM closed 4 years ago

HCLDREAM commented 4 years ago

Hi! I would like to know why my playbook execution failed, is it convenient for me to see the specific reason? my cx_Oracle has been installed. Looking forward to your reply. image

HCLDREAM commented 4 years ago

Supplement my main.yml image

duhlig commented 4 years ago

Hi Hcldream,

you need the cx_Oracle on the controlled host, not on the controller. Please check and report.

Kind Regards, Dietmar

HCLDREAM commented 4 years ago

cx_Oracle is the Python library that is used to manipulate the database and work with Oracle clients. What is the use of it being installed on a Oracle server? @duhlig

oravirt commented 4 years ago

The module uses cx_Oracle to connect to the database. For this specific module, the task can be executed on the controller or the database server, so that's up to you. If you're executing on the controller you need to specify delegate_to: localhost in the task, or use connection: local at the playbook level. If you want to run it on the database server you need to install cx_Oracle.

HCLDREAM commented 4 years ago

Thank you very much, the problem has been solved, I have not set delegate_to:localhost @oravirt

duhlig commented 4 years ago

@HCLDREAM: Although your problem has already been solved I'd like to answer. My first reply was to short and incomplete. This is how ansible works: The playbook and the roles are "executed" on the controller. The module (e.g. oracle_sql) usually gets copied to the controlled host and executed there. That's why you need Python on the controlled host and every Python library that is included in the Ansible module (e.g. cx_Oracle). If it's not necessary or not desirable to run the module on the controlled host (because for instance cx_Oracle does the net connection itself) you can delegate the execution of the module to another machine (localhost in most cases). This was Mikael's hint I forgot in my first reply.

Kind regards, Dietmar