5

查看 Ansible文档中的核心数据库模块,没有发现任何 Oracle 模块的迹象。通过 Ansible for Oracle 数据库处理 SQL/PLSQL 部署的最佳方式是什么?

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

4

2 回答 2

1

我创建了一个角色来安装 apex 5(我首先卸载 apex 4)。我使用像“脚本”和“外壳”这样的模块。我对环境初始化不太满意,但我仍在学习。对于任何 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
于 2016-12-27T21:26:58.203 回答
0

我不确定这是否与您的问题有关,但我最初是在寻找 Ansible 模块来启动/停止并获取 Oracle 数据库的状态。我找不到任何合适的东西,所以我编写了自己的 ansible 模块。模块使您能够定义标准接口,对任务有 OK/Failed/Changed 响应,同时执行尽可能多的低级活动/命令(这样它们比简单的 shell/命令模块更灵活) )。我编写的模块是幂等的——它们不会尝试启动已经启动的数据库,也不会尝试停止已经停止的数据库。如果停止/停止功能不成功,它会返回 Failed 和 stdout/stderr。

除了 Oracle 数据库,我还编写了模块来为业务对象和 Weblogic 服务提供接口。这些模块是重要的前期工作,但一旦它们稳定,它们就可以用于各种剧本。

我还没有查看 Galaxy 是否还有其他类似的东西,不幸的是,由于我的客户/合同的性质,我不确定我是否可以共享我们开发的模块。我只是想我会提供这个作为你探索的可能途径。

于 2020-05-29T14:24:24.257 回答