使用 Ansible playbook 运行 Oracle SQL 脚本

Running Oracle SQL scripts with Ansible playbook(使用 Ansible playbook 运行 Oracle SQL 脚本)
本文介绍了使用 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 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

SQL to Generate Periodic Snapshots from Transactions Table(用于从事务表生成定期快照的SQL)
MyBatis support for multiple databases(MyBatis支持多个数据库)
Oracle 12c SQL: Missing column Headers in result(Oracle 12c SQL:结果中缺少列标题)
SQL query to find the number of customers who shopped for 3 consecutive days in month of January 2020(查询2020年1月连续购物3天的客户数量)
How to get top 10 data weekly (This week, Previous week, Last month, 2 months ago, 3 month ago)(如何每周获取前十大数据(本周、前一周、上个月、2个月前、3个月前))
Select the latest record for an Id per day - Oracle pl sql(选择每天ID的最新记录-Oracle pl SQL)