From d19b5d149f61820fe464c347456a36d5951720aa Mon Sep 17 00:00:00 2001 From: bartowl Date: Wed, 16 Aug 2023 17:53:10 +0200 Subject: [PATCH] fix to enable removal of old jobs --- .../fragments/273_oradb_rman_absent_fix.yml | 3 +++ roles/oradb_rman/tasks/main.yml | 27 ++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/273_oradb_rman_absent_fix.yml diff --git a/changelogs/fragments/273_oradb_rman_absent_fix.yml b/changelogs/fragments/273_oradb_rman_absent_fix.yml new file mode 100644 index 000000000..a7ace2f57 --- /dev/null +++ b/changelogs/fragments/273_oradb_rman_absent_fix.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "oradb_rman: better handle rman_jobs with state: absent (oravirt#374)" \ No newline at end of file diff --git a/roles/oradb_rman/tasks/main.yml b/roles/oradb_rman/tasks/main.yml index 21f46451d..c86dc78a6 100644 --- a/roles/oradb_rman/tasks/main.yml +++ b/roles/oradb_rman/tasks/main.yml @@ -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: @@ -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 @@ -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 }}" @@ -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