klewan.ansible_role_oracle_manage_dbstate
Ansibleロール: oracle-manage-dbstate
Oracleデータベースの状態を管理します(起動/シャットダウン)。
対応OS:
- RedHat
- CentOS
- OracleLinux
要件
このロールはoracle
ロールを使用します。
次の変数を定義する必要があります:
oracle_manage_dbstate_oracle_home
-> ORACLE_HOMEoracle_manage_dbstate_oracle_sid
-> ORACLE_SIDoracle_manage_dbstate_command
-> 起動/シャットダウンコマンドとオプション
ロール変数
使用可能な変数は以下に示されています。デフォルト値も含まれています(defaults/main.yml
を参照):
# ORACLE_HOME
oracle_manage_dbstate_oracle_home:
# ORACLE_SID
oracle_manage_dbstate_oracle_sid:
# 実行する起動/シャットダウンコマンド
oracle_manage_dbstate_command: # 'oracle_manage_dbstate_commands'を参照
# 受け入れ可能な起動/シャットダウンコマンド
oracle_manage_dbstate_commands:
- 'SHUTDOWN IMMEDIATE'
- 'STARTUP'
- 'STARTUP NOMOUNT'
- 'STARTUP MOUNT'
- 'STARTUP RESTRICT'
- 'STARTUP MOUNT RESTRICT'
- 'STARTUP UPGRADE'
# 起動/シャットダウンコマンドが有効であることを確認
oracle_manage_dbstate_verify_command: true
# sqlplusコマンドの出力を表示
oracle_manage_dbstate_print_command_output: false
# sqlplusエラーを処理する(例: 'whenever sqlerror exit 1'を実行)
oracle_manage_dbstate_handle_sqlplus_errors: true
# sqlplusエラー処理コマンド
oracle_manage_dbstate_sqlplus_sqlerror_command: "{% if oracle_manage_dbstate_handle_sqlplus_errors %}whenever sqlerror exit 1{% else %}{% endif %}"
例 Playbook
- name: Oracleデータベースの状態を管理します(データベースをマウント)
hosts: ora-servers
gather_facts: true
become: true
become_user: '{{ oracle_user }}'
tasks:
- import_role:
name: oracle-gatherinfo-gi
tags:
- oracle-gatherinfo-gi
- import_role:
name: oracle-gatherinfo-databases
tags:
- oracle-gatherinfo-databases
- include_role:
name: oracle-manage-dbstate
vars:
oracle_manage_dbstate_oracle_home: '{{ _oracle_homes_backup_outer_item.oracle_home }}'
oracle_manage_dbstate_oracle_sid: '{{ _oracle_homes_backup_outer_item.instance_name }}'
oracle_manage_dbstate_command: "STARTUP MOUNT"
oracle_manage_dbstate_handle_sqlplus_errors: true
with_items:
- "{{ oracle_databases }}"
loop_control:
label: "[ORACLE_HOME: {{ _oracle_homes_backup_outer_item.oracle_home }}]"
loop_var: _oracle_homes_backup_outer_item
when: _oracle_homes_backup_outer_item.instance_name == 'ORCL'
tags:
- oracle-manage-dbstate
vars/main.yml
やgroup_vars/..
またはhost_vars/..
の中:
#-------------------------------------------------
# ロール 'oracle-manage-dbstate' の変数を上書き
#-------------------------------------------------
# sqlplusコマンドの出力を表示
oracle_manage_dbstate_print_command_output: true
# sqlplusエラーを処理する(例: 'whenever sqlerror exit 1'を実行)
oracle_manage_dbstate_handle_sqlplus_errors: false
ライセンス
GPLv3 - GNU一般公衆ライセンスv3.0
著者情報
このロールは2018年にKrzysztof Lewandowskiによって作成されました。