ansible oracle模块,使用Ansible playbook运行Oracle SQL脚本

我创建了一个角色来安装apex 5(我首先卸载apex 4).我使用’script’和’shell’之类的模块.我对环境初始化不太满意,但我还在学习.对于任何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 <

connect / as sysdba

@?/apex/apxremov.sql

exit

EOF

你可能感兴趣的:(ansible,oracle模块)