Skip to content

Commit

Permalink
Add task to register database in rman catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
bartowl committed Apr 18, 2023
1 parent 14df63c commit d15684c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/rman_catalog_register.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- "added task to REGISTER DATABASE in Rman Catalog (oravirt#334)"
6 changes: 6 additions & 0 deletions roles/oradb_rman/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ rman_catalog_param: "{% if item.0.rman_wallet is defined and item.0.rman_wallet
{%- if item.0.rman_user is defined %}-c {{ item.0.rman_user }}/{{ dbpasswords[item.0.rman_tnsalias][item.0.rman_user] | default(item.0.rman_password) }}@{{ item.0.rman_tnsalias }}
{%- endif %}
{%- endif %}"
rman_register_connect: >-
{%- if item.rman_wallet is defined -%}
/@{{ item.rman_tnsalias }}
{%- else -%}
{{ item.rman_user }}/{{ dbpasswords[item.rman_tnsalias][item.rman_user] | default(item.rman_password) }}@{{ item.rman_tnsalias }}
{%- endif -%}
20 changes: 20 additions & 0 deletions roles/oradb_rman/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,26 @@
tags:
- wallet

- name: Register Database in RMAN Catalog
become_user: "{{ oracle_user }}"
ansible.builtin.shell:
cmd: "$ORACLE_HOME/bin/rman target / catalog $CONNECTSTRING"
stdin: "REGISTER DATABASE;\n"
environment:
ORACLE_HOME: "{{ db_homes_config[item.home]['oracle_home'] }}"
ORACLE_SID: "{{ item.oracle_db_name }}"
CONNECTSTRING: "{{ rman_register_connect }}"
TNS_ADMIN: "{{ rman_tns_admin }}"
with_items:
- "{{ oracle_databases | selectattr('rman_tnsalias', 'defined') }}"
loop_control:
label: "{{ item.oracle_db_name | default('') }}"
register: rman_catalog_register
failed_when: '"RMAN-" in rman_catalog_register.stdout and "RMAN-20002" not in rman_catalog_register.stdout'
changed_when: '"RMAN-20002" not in rman_catalog_register.stdout'
tags:
- rmanregister

# the following task is usefull for configuration of rman-parameters during setup of RMAN
# It's also possible to execute the 1st Level0-Backup after setup, but be aware to configure the RMAN before starting a backup
# The execution isn't done in async mode!
Expand Down

0 comments on commit d15684c

Please sign in to comment.