使用Ansible剧本运行Oracle SQL脚本 [英] Running Oracle SQL scripts with Ansible playbook
问题描述
看看Ansible 文档中的核心数据库模块没有发现任何迹象. Oracle模块.通过Ansible for Oracle数据库处理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?
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.
推荐答案
我创建了一个角色来安装apex 5(我是在这里首先卸载apex 4).我使用'script'和'shell'之类的模块.我对环境初始化不太满意,但仍在学习中.对于任何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剧本运行Oracle SQL脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!