Skip to content

Commit

Permalink
fix to enable removal of old jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
bartowl authored and Rendanic committed Aug 17, 2023
1 parent defbb29 commit ab223b5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelogs/fragments/273_oradb_rman_absent_fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- "oradb_rman: better handle rman_jobs with state: absent (oravirt#374)"
27 changes: 26 additions & 1 deletion roles/oradb_rman/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
- "{{ oracle_databases }}"
- rman_jobs
- skip_missing: true
when: item.1.state | default('present') == 'present'
loop_control:
label: "oracle_db_name {{ item.0.oracle_db_name | default('') }} job {{ item.1.name | default('') }}"
tags:
Expand Down Expand Up @@ -308,6 +309,7 @@
when:
- item.1.immediate is defined
- item.1.immediate
- item.1.state | default('present') == 'present'
- "((configure_cluster and inventory_hostname == cluster_master) or not configure_cluster )"
tags:
- rmanexecute
Expand Down Expand Up @@ -343,7 +345,7 @@
cron_file: "{{ rman_cronfile }}"
user: "{{ oracle_user }}"
disabled: "{{ item.1.disabled | default(false) }}"
state: "{{ item.1.state | default('present') }}"
state: "present"
day: "{{ item.1.day }}"
weekday: "{{ item.1.weekday }}"
hour: "{{ item.1.hour }}"
Expand All @@ -367,6 +369,29 @@
- item.1.hour is defined
- item.1.minute is defined
- item.1.name is defined
- item.1.state | default('present') == 'present'
tags:
- rmancron

- name: Remove crontab entries for RMAN Backup
ansible.builtin.cron:
name: rman_backup_{{ item.0.oracle_db_name }}_{{ item.1.name }}
cron_file: "{{ rman_cronfile }}"
user: "{{ oracle_user }}"
state: "absent"
# noqa yaml
with_subelements:
- "{{ oracle_databases }}"
- rman_jobs
- skip_missing: true
loop_control:
label: >-
oracle_db_name: {{ item.0.oracle_db_name | default('') }}
state: {{ item.1.state | default('present') }}
when:
- item.1 is defined
- item.1.name is defined
- item.1.state | default('present') == 'absent'
tags:
- rmancron

Expand Down

0 comments on commit ab223b5

Please sign in to comment.