問題描述
查看 Ansible 中的核心數(shù)據(jù)庫模塊文檔Oracle 模塊.通過 Ansible for Oracle 數(shù)據(jù)庫處理 SQL/PLSQL 部署的最佳方法是什么?
A look at the core database modules in Ansible documentation shows no signs of a module for Oracle. What is the best way to handle SQL/PLSQL deployments via Ansible for Oracle databases?
我們是否希望使用來自 Ansible Galaxy 來處理這個問題?似乎很少有人下載 Galaxy for Oracle 上列出的角色.
Are we expected to use roles from Ansible Galaxy to handle this? Very few people seem to have downloaded roles listed on Galaxy for Oracle.
推薦答案
我創(chuàng)建了一個角色來安裝 apex 5(我首先卸載了 apex 4).我使用像腳本"和外殼"這樣的模塊.我對環(huán)境初始化不太滿意,但我仍在學習.對于任何 SQL/PLSQL 任務,sqlplus 都是正確的工具.(也許 SQLcl 可以做得更好..?)
I have created a role to install apex 5 (where I first uninstall apex 4). I use modules like 'script' and 'shell'. I am not too happy about environment initialization but I am still learning. For any SQL/PLSQL task, sqlplus is the right tool. (perhaps SQLcl can do better..?)
- 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
這篇關于使用 Ansible playbook 運行 Oracle SQL 腳本的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!