oravirt / ansible-oracle-modules

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

oracle_pdb generates invalid SQL #51

Closed willievu closed 6 years ago

willievu commented 6 years ago

It is caused by the "copy" clause. After removing it like follows, it works.

createsql += ' file_name_convert = (%s) copy' % (quoted)

createsql += ' file_name_convert = (%s)' % (quoted)

The following is the error.

The full traceback is: File "/tmp/ansible_gSvzei/ansible_module_oracle_pdb.py", line 279, in execute_sql cursor.execute(sql)

fatal: [db]: FAILED! => { "changed": false, "invocation": { "module_args": { "datafile_dest": null, "file_name_convert": "/pdb1/, /cx_oracle_test_1/", "hostname": "", "mode": "****dba", "name": "cx_oracle_test_1", "oracle_home": null, "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "pdb_admin_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "pdb_admin_username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "port": "1521", "save_state": true, "service_name": null, "service_name_convert": null, "sourcedb": "cdb12c", "state": "present", "unplug_dest": null, "user": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" } }, "msg": "Something went wrong while executing sql - ORA-00922: missing or invalid option sql: create pluggable database cx_oracle_test_1 admin user **** identified by **** file_name_convert = ('/pdb1/',' /cx_oracle_test_1/') copy" }

oravirt commented 6 years ago

Can you show me the playbook? Are you just trying to create a new pdb?

I think I added the file_name_convert to be used if you're plugging in a pdb and want to copy the files to a new location. So it is not meant to be used when just creating a new one (I usually use datafile_dest for this) But I can add another check...

willievu commented 6 years ago

Yes I'm trying to create a new pdb.

Here is the playbook:

---  
- hosts: db
  vars:
    hostname: "{{ database_host }}"
    user: sys
    password: "{{ database_admin_password | b64decode }}"
    pdb_name: "cx_oracle_test_1"
  tasks:
    - name: Create pluggable database
      oracle_pdb: 
        name: "{{ pdb_name }}"
        sourcedb: "{{ database_sid }}"
        mode: sysdba
        hostname: "{{ hostname }}"
        user: "{{ user }}"
        password: "{{ password }}"
        pdb_admin_password: sys
        pdb_admin_username: "{{ database_admin_password | b64decode }}"
        file_name_convert: "/pdbseed/,/{{ pdb_name }}/"
oravirt commented 6 years ago

Ok - this should be fixed with https://github.com/oravirt/ansible-oracle-modules/commit/3ce41d872a7fa58c9acf022c0b00d0a9499a3f77. This was a quick fix for this issue, and I'll probably re-visit this solution later on

There are a lot of options that are not implemented yet, and I'll add them when there is a need for them