oracle_user module error expecting cx_oracle in DB server

63 views
Skip to first unread message

Anand Solomon

unread,
Jan 25, 2020, 10:07:40 AM1/25/20
to Ansible Project
I am trying to create oracle user using oracle_user module in a RDS server. Here is my playbook

- hosts: all
  vars:
    oracle_home: /home/ansible/instantclient_12_2
    user: SYSDBA
    password: ******
    prt: "1521"
    hostname: "RDS Instance"
    sname: TESTDB
    oracle_env:
      ORACLE_HOME: "{{oracle_home}}"
      LD_LIBRARY_PATH: "{{oracle_home}}"
      PATH: "{{oracle_home}}"

  vars_files:
    - vault-pass.yml

  tasks:
    - name: This playbook will create the user.
      oracle_user:
        oracle_home: /home/ansible/instantclient_12_2
        user: "{{user}}"
        password: "{{password}}"
        service_name: "{{sname}}"
        port: "{{prt}}"
        hostname: "{{hostname}}"
        schema: *****
        schema_password: ****
        default_tablespace: USERS
#        state: present
        grants: "'create session', create any table'"
      environment: "{{oracle_env}}"

This fails with below error
FAILED! => {"changed": false, "msg": "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"}

DO we need to have cx_oracle installed in the target server too? I had this same issue with oracle_sql module too, but I used "connection: local" to enforced the playbook to look at the local cx_oracle install. This is not working in oracle_user module.

Dick Visser

unread,
Jan 25, 2020, 5:17:44 PM1/25/20
to ansible...@googlegroups.com
Hi

Ansible doesn’t have such a module, so I assume this is a 3rd party module?
In that case you might have more luck asking the module’s authors for support. 


--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c1c30471-934e-42e2-9e2b-991c1e57db87%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Anand Solomon

unread,
Jan 28, 2020, 12:05:16 PM1/28/20
to Ansible Project
Hi,
I am using oracle_sql module and running a sql script. The sql script contains comments. The playbook fails because "
FAILED! => {"changed": false, "msg": "Something went wrong while executing sql - ORA-00911: invalid character sql: 

Is there a way I can keep the comments and execute the sql script ?


On Saturday, January 25, 2020 at 5:17:44 PM UTC-5, Dick Visser wrote:
Hi

Ansible doesn’t have such a module, so I assume this is a 3rd party module?
In that case you might have more luck asking the module’s authors for support. 

To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.

Stefan Hornburg (Racke)

unread,
Jan 28, 2020, 12:18:33 PM1/28/20
to ansible...@googlegroups.com
On 1/28/20 6:05 PM, Anand Solomon wrote:
> Hi,
> I am using oracle_sql module and running a sql script. The sql script contains comments. The playbook fails because "
> FAILED! => {"changed": false, "msg": "Something went wrong while executing sql - ORA-00911: invalid character sql: 
>
> Is there a way I can keep the comments and execute the sql script ?
>

I suppose you could filter out the comments. How does your SQL script looks like?

Regards
Racke
> <javascript:>.
> <https://groups.google.com/d/msgid/ansible-project/c1c30471-934e-42e2-9e2b-991c1e57db87%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> Sent from a mobile device - please excuse the brevity, spelling and punctuation.
>
> --
> 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
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

Anand Solomon

unread,
Jan 28, 2020, 12:31:12 PM1/28/20
to Ansible Project
My sql script will look like

/* #######################################################################################################################################
# Program       : xxxx.sql
# Programmer    : xxxxx
# Date          : xxxxx
# Usage         : xxxx
# Revisions     : xxxxx
# Dependencies  :
#                 1. Sqlplus Binaries.
#
# Notes         : Script will creates Oracle packages on AWS RDS.
# Author        : xxxx
#                 Creates change passwords and lock a/c's 
#                 after the user is done .

####################################################################################################################################### */

Stefan Hornburg (Racke)

unread,
Jan 28, 2020, 12:34:00 PM1/28/20
to ansible...@googlegroups.com
On 1/28/20 6:31 PM, Anand Solomon wrote:
> My sql script will look like
>
> /*
> #######################################################################################################################################
> # Program       : xxxx.sql
> # Programmer    : xxxxx
> # Date          : xxxxx
> # Usage         : xxxx
> # Revisions     : xxxxx
> # Dependencies  :
> #                 1. Sqlplus Binaries.
> #
> # Notes         : Script will creates Oracle packages on AWS RDS.
> # Author        : xxxx
> #                 Creates change passwords and lock a/c's 
> #                 after the user is done .
>
> #######################################################################################################################################
> */
>

So where is the SQL code?

Regards
Racke
> <https://groups.google.com/d/msgid/ansible-project/c1c30471-934e-42e2-9e2b-991c1e57db87%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/ansible-project/c1c30471-934e-42e2-9e2b-991c1e57db87%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> >
> >     --
> >     Sent from a mobile device - please excuse the brevity, spelling and punctuation.
> >
> > --
> > 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
> > ansible...@googlegroups.com <javascript:> <mailto:ansible-proje...@googlegroups.com <javascript:>>.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com>
> >
> <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>
> --
> 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
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/fdee5e94-0ada-4be3-8fb2-72bccbcb7c80%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/fdee5e94-0ada-4be3-8fb2-72bccbcb7c80%40googlegroups.com?utm_medium=email&utm_source=footer>.
signature.asc

Anand Solomon

unread,
Jan 28, 2020, 1:05:38 PM1/28/20
to Ansible Project
It goes soon after the comments

 /* 
 ####################################################################################################################################### 
 # Program       : xxxx.sql 
 # Programmer    : xxxxx 
 # Date          : xxxxx 
 # Usage         : xxxx 
 # Revisions     : xxxxx 
 # Dependencies  : 
 #                 1. Sqlplus Binaries. 
 # 
 # Notes         : Script will creates Oracle packages on AWS RDS. 
 # Author        : xxxx 
 #                 Creates change passwords and lock a/c's  
 #                 after the user is done . 
####################################################################################################################################### 
 */ 
set serveroutput on;
select username from dba_users;
/
..
>     > ansible...@googlegroups.com <javascript:> <mailto:ansible-project+unsub...@googlegroups.com <javascript:>>.
>     > To view this discussion on the web visit
>     > https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com
>     <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com>
>     >
>     <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com?utm_medium=email&utm_source=footer
>     <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
>
>     --
>     Ecommerce and Linux consulting + Perl and web application programming.
>     Debian and Sympa administration. Provisioning with Ansible.
>
> --
> 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

Stefan Hornburg (Racke)

unread,
Jan 28, 2020, 3:38:06 PM1/28/20
to ansible...@googlegroups.com
On 1/28/20 7:05 PM, Anand Solomon wrote:
> It goes soon after the comments
>
>  /* 
>  ####################################################################################################################################### 
>  # Program       : xxxx.sql 
>  # Programmer    : xxxxx 
>  # Date          : xxxxx 
>  # Usage         : xxxx 
>  # Revisions     : xxxxx 
>  # Dependencies  : 
>  #                 1. Sqlplus Binaries. 
>  # 
>  # Notes         : Script will creates Oracle packages on AWS RDS. 
>  # Author        : xxxx 
>  #                 Creates change passwords and lock a/c's  
>  #                 after the user is done . 
> ####################################################################################################################################### 
>  */ 
> set serveroutput on;
> select username from dba_users;
> /
> ..

Hello Anand,

given that this text is in the variable "sql", you can use the following filter:

{{sql | regex_replace('/\\*([\\s\\S]*)\\*/', '') | trim() }}

The result would be:

set serveroutput on;
select username from dba_users;

I found out that you have to use [\\s\\S]* instead of the more straightforward .* as .* doesn't match newlines.
> >     > ansible...@googlegroups.com <javascript:> <mailto:ansible-proje...@googlegroups.com <javascript:>
> <javascript:>>.
> >     > To view this discussion on the web visit
> >     > https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com>
> >     <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com>>
> >     >
> >    
> <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com?utm_medium=email&utm_source=footer>
>
> >    
> <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com?utm_medium=email&utm_source=footer>>>.
>
> >
> >
> >
> >     --
> >     Ecommerce and Linux consulting + Perl and web application programming.
> >     Debian and Sympa administration. Provisioning with Ansible.
> >
> > --
> > 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
> > ansible...@googlegroups.com <javascript:> <mailto:ansible-proje...@googlegroups.com <javascript:>>.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/ansible-project/fdee5e94-0ada-4be3-8fb2-72bccbcb7c80%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/fdee5e94-0ada-4be3-8fb2-72bccbcb7c80%40googlegroups.com>
> >
> <https://groups.google.com/d/msgid/ansible-project/fdee5e94-0ada-4be3-8fb2-72bccbcb7c80%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/ansible-project/fdee5e94-0ada-4be3-8fb2-72bccbcb7c80%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>
> --
> 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
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/d9b7e7bb-8a8e-4469-96a4-8b9412abf7f6%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/d9b7e7bb-8a8e-4469-96a4-8b9412abf7f6%40googlegroups.com?utm_medium=email&utm_source=footer>.
signature.asc

Anand Solomon

unread,
Jan 30, 2020, 9:43:45 AM1/30/20
to Ansible Project
Hi,
Thank you so much. I made this work by commenting with -- instead of #

Thank you for your help.
>     >     > ansible...@googlegroups.com <javascript:> <mailto:ansible-project+unsub...@googlegroups.com <javascript:>
>     <javascript:>>.
>     >     > To view this discussion on the web visit
>     >     > https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com
>     <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com>
>     >     <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com
>     <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com>>
>     >     >
>     >    
>     <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com?utm_medium=email&utm_source=footer
>     <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com?utm_medium=email&utm_source=footer>
>
>     >    
>     <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com?utm_medium=email&utm_source=footer
>     <https://groups.google.com/d/msgid/ansible-project/7afeb9ff-12e0-4f4f-b4fc-0a86d515a694%40googlegroups.com?utm_medium=email&utm_source=footer>>>.
>
>     >
>     >
>     >
>     >     --
>     >     Ecommerce and Linux consulting + Perl and web application programming.
>     >     Debian and Sympa administration. Provisioning with Ansible.
>     >
>     > --
>     > 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
>     > ansible...@googlegroups.com <javascript:> <mailto:ansible-project+unsub...@googlegroups.com <javascript:>>.
>     > To view this discussion on the web visit
>     > https://groups.google.com/d/msgid/ansible-project/fdee5e94-0ada-4be3-8fb2-72bccbcb7c80%40googlegroups.com
>     <https://groups.google.com/d/msgid/ansible-project/fdee5e94-0ada-4be3-8fb2-72bccbcb7c80%40googlegroups.com>
>     >
>     <https://groups.google.com/d/msgid/ansible-project/fdee5e94-0ada-4be3-8fb2-72bccbcb7c80%40googlegroups.com?utm_medium=email&utm_source=footer
>     <https://groups.google.com/d/msgid/ansible-project/fdee5e94-0ada-4be3-8fb2-72bccbcb7c80%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
>
>     --
>     Ecommerce and Linux consulting + Perl and web application programming.
>     Debian and Sympa administration. Provisioning with Ansible.
>
> --
> 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
Reply all
Reply to author
Forward
0 new messages