Skip to content

Commit 58f0a60

Browse files
bartowlRendanic
authored andcommitted
Add task to register database in rman catalog
1 parent 14df63c commit 58f0a60

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
minor_changes:
3+
- "added task to REGISTER DATABASE in Rman Catalog (oravirt#336)"

roles/oradb_rman/defaults/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,11 @@ rman_catalog_param: "{% if item.0.rman_wallet is defined and item.0.rman_wallet
3939
{%- 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 }}
4040
{%- endif %}
4141
{%- endif %}"
42+
rman_register_connect: "\
43+
{%- if item.rman_wallet is defined -%}\
44+
/@{{ item.rman_tnsalias }}\
45+
{%- else -%}\
46+
{{ item.rman_user -}}/\
47+
{{ dbpasswords[item.rman_tnsalias][item.rman_user] | default(item.rman_password) -}}\
48+
@{{ item.rman_tnsalias }}\
49+
{%- endif -%}"

roles/oradb_rman/tasks/main.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,26 @@
266266
tags:
267267
- wallet
268268

269+
- name: Register Database in RMAN Catalog
270+
become_user: "{{ oracle_user }}"
271+
ansible.builtin.shell:
272+
cmd: "$ORACLE_HOME/bin/rman target / catalog $CONNECTSTRING"
273+
stdin: "REGISTER DATABASE;\n"
274+
environment:
275+
ORACLE_HOME: "{{ db_homes_config[item.home]['oracle_home'] }}"
276+
ORACLE_SID: "{{ item.oracle_db_name }}"
277+
CONNECTSTRING: "{{ rman_register_connect }}"
278+
TNS_ADMIN: "{{ rman_tns_admin }}"
279+
with_items:
280+
- "{{ oracle_databases | selectattr('rman_tnsalias', 'defined') }}"
281+
loop_control:
282+
label: "{{ item.oracle_db_name | default('') }}"
283+
register: rman_catalog_register
284+
failed_when: '"RMAN-" in rman_catalog_register.stdout and "RMAN-20002" not in rman_catalog_register.stdout'
285+
changed_when: '"RMAN-20002" not in rman_catalog_register.stdout'
286+
tags:
287+
- rmanregister
288+
269289
# the following task is usefull for configuration of rman-parameters during setup of RMAN
270290
# It's also possible to execute the 1st Level0-Backup after setup, but be aware to configure the RMAN before starting a backup
271291
# The execution isn't done in async mode!

0 commit comments

Comments
 (0)