Running Oracle SQL scripts with Ansible playbook(使用 Ansible playbook 运行 Oracle SQL 脚本)
问题描述
查看 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?
我们是否希望使用来自 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.
推荐答案
我创建了一个角色来安装 apex 5(我首先卸载了 apex 4).我使用像脚本"和外壳"这样的模块.我对环境初始化不太满意,但我仍在学习.对于任何 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 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Ansible playbook 运行 Oracle SQL 脚本
基础教程推荐
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 无法解决整理冲突 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 在 SQL 中连接多个表 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
