oravirt / ansible-oracle-modules

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

Getting: "The cx_Oracle module is required.", even though all requirements are satisfied #116

Closed serpro69 closed 4 years ago

serpro69 commented 4 years ago

Hi,

I'm facing getting an error when running the modules:

"The cx_Oracle module is required. 'pip install cx_Oracle' should do the trick. If cx_Oracle is installed, make sure ORACLE_HOME & LD_LIBRARY_PATH is set

I have the cx_Oracle installed:

$ pip install cx_Oracle                                                                                                                                                                                                    
Requirement already satisfied: cx_Oracle in ./.virtualenvs/oci/lib/python3.6/site-packages (7.2.3)

ORACLE_HOME and LD_LIBRARY_PATH are also set:

$ echo $ORACLE_HOME                                                                                                                                                                                                        
/opt/oracle/instantclient_19_3
$ echo $LD_LIBRARY_PATH                                                                                                                                                                                                   
/opt/oracle/instantclient_19_3

I have tested the connection to db with sqlplus and that works fine as well.

I can import cx_Oracle from the cli:

$ python       

Python 3.6.8 (default, Oct  7 2019, 12:59:55)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>> print(cx_Oracle.version)
7.2.3
>>>

But for some reason this fails when used from the ansible module. I thought the python virtual environment might be the reason but I tried installing cx_Oracle outside the venv and it still fails with the same error. Though I have a hunch it's something to do with the virtual env. Do you know what am I doing wrong here? Thanks.

serpro69 commented 4 years ago

Well my thought was correct, the cx_Oracle has to be installed for /usr/bin/python. Is there any way to make it work with virtualenv?

tdavison784 commented 4 years ago

Hi Sergio,

You can make it work with the venv by pointing ansibles python interpreter to it. You can do this as an extra var or in the inventory file as well.

ansible-playbook -i inventory site.yml -e “ansible_python_interpreter=path/to/venv/python”

On Wed, Nov 20, 2019 at 09:14 Sergio Pro notifications@github.com wrote:

Well my thought was correct, the cx_Oracle has to be installed for /usr/bin/python. Is there any way to make it work with virtualenv?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/oravirt/ansible-oracle-modules/issues/116?email_source=notifications&email_token=AHY4VPY7DS42AEX7UEO3JRDQUVH6RA5CNFSM4JPTWTVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEESJ3XI#issuecomment-556047837, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHY4VPYNNXJBAIRLWEZWWIDQUVH6RANCNFSM4JPTWTVA .

serpro69 commented 4 years ago

Thanks @tdavison784, will try that. I have tried setting that var from playbook, but that didn't work (maybe because of variable precedence). Haven't thought to set it from command line though. I suppose the issue can be closed since this is unrelated to the ansible-oracle-modules