使用Ansible playbook运行Oracle SQL脚本

Irf*_*n N 5 oracle ansible ansible-playbook ansible-galaxy

查看Ansible 文档中的核心数据库模块,没有显示Oracle模块的迹象.通过Ansible for Oracle数据库处理SQL/PLSQL部署的最佳方法是什么?

我们是否希望使用Ansible Galaxy的角色来处理这个问题?很少有人似乎下载了Galaxy for Oracle上列出的角色.

Bja*_*ndt 1

我创建了一个角色来安装 apex 5(我首先卸载 apex 4)。我使用“script”和“shell”等模块。我对环境初始化不太满意,但我仍在学习。对于任何 SQL/PLSQL 任务,sqlplus 都是正确的工具。(也许 SQLcl 可以做得更好......?)

- name: Determine apex version
  become: yes
  become_user: oracle
  shell: source /etc/profile &&  sqlplus -S / as sysdba @"{{ temp_dir }}/apexver.sql"
  register: apexver
  args:
     executable: /bin/bash
  changed_when: "'APEX_040000' in apexver.stdout"

- name: oracle apex remove
  become: yes
  become_user: oracle
  script: apex_remove.sh {{ item }} 
  with_items: 
    - 'XE'
  ignore_errors: yes
  register: result
  when: "'APEX_040000' in apexver.stdout"

22:18 $ cat apex_remove.sh
#!/bin/sh

# set oracle environment
. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
ORACLE_SID=$1

sqlplus -s /nolog <<EOF
connect / as sysdba
@?/apex/apxremov.sql
exit
EOF
Run Code Online (Sandbox Code Playgroud)