Running a select statement as script using oracle_sql module

12 views
Skip to first unread message

Anand Solomon

unread,
Jan 25, 2020, 10:04:57 AM1/25/20
to Ansible Development
Hi,
I am trying to run a sql script which has simple select statement. (select username from dba_users). Will oracle_sql module run a "Select" statement and returns the results ?

My playbook is 

    - name: Script will creates Oracle DBA IDs and Profiles on AWS RDS.
      oracle_sql:
        username: "{{user}}"
        password: "{{password}}"
        service_name: "{{sname}}"
        port: "{{prt}}"
        host: "{{host}}"
        script: "/home/ansible/Compliance.sql"
      environment: "{{oracle_env}}"
      register: query_result
      connection: local

If I run the sql statement as sql: "select username from dba_users", it works. The same sql statement if I run script: /home/ansible/Compliance.sql. It is not working.


I am getting "{"changed": false, "msg": "Something went wrong while executing sql - ORA-00972: identifier is too long sql: \"Finished running script /home/ansible/Compliance.sql \\nContents: \\nselect username\\\n  \\ from dba_users\""}

The debug output is as below:

TASK [Display the query results] ************************************************************************************************************************************************************************************************************
ok: [22.174.101.30] => (item=msg.stdout) => {
    "msg": {
        "changed": true,
        "failed": false,
        "msg": "Finished running script /home/ansible/Compliance.sql \nContents: \nselect username from dba_users"
    }
}

Tom Davison

unread,
Jan 25, 2020, 10:08:27 AM1/25/20
to Ansible Development
Hi Anand,

I just answered the issue on the ansible oracle module github repo. Please see that answer. 

Anand Solomon

unread,
Jan 25, 2020, 9:37:05 PM1/25/20
to Ansible Development
Thank you so much.
Reply all
Reply to author
Forward
0 new messages