Skip to content

Commit

Permalink
- fix loops
Browse files Browse the repository at this point in the history
- replace match filter with equalto where applicable
  • Loading branch information
bartowl authored and Rendanic committed Mar 6, 2024
1 parent 4484332 commit 659e076
Show file tree
Hide file tree
Showing 23 changed files with 129 additions and 141 deletions.
15 changes: 7 additions & 8 deletions roles/oradb_datapatch/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
state: started
become: true
become_user: "{{ oracle_user }}"
with_items: "{{ oracle_databases | selectattr('state', 'match', 'present') }}"
with_items: "{{ oracle_databases | selectattr('state', 'equalto', 'present') }}"
loop_control:
loop_var: odb
label: >-
Expand All @@ -40,8 +40,8 @@
- name: oradb_datapatch | Run datapatch
opitzconsulting.ansible_oracle.oracle_datapatch:
oracle_home: "{{ _oracle_home_db }}"
db_name: "{{ odb.0.oracle_db_name }}"
db_unique_name: "{{ odb.0.oracle_db_unique_name | default(omit) }}"
db_name: "{{ odb.oracle_db_name }}"
db_unique_name: "{{ odb.oracle_db_unique_name | default(omit) }}"
sid: "{{ odb.oracle_db_instance_name | default(omit) }}"
output: verbose
fail_on_db_not_exist: "{{ oradb_datapatch_fail_on_db_not_exist }}"
Expand All @@ -50,17 +50,16 @@
hostname: "{{ ansible_fqdn }}"
service_name: "{{ _db_service_name }}"
port: "{{ _listener_port_cdb }}"
loop:
- "{{ oracle_databases | selectattr('state', 'match', 'present') | flatten(levels=1) }}"
loop: "{{ oracle_databases | selectattr('state', 'equalto', 'present') }}"
become: true
become_user: "{{ oracle_user }}"
loop_control:
loop_var: odb
label: >-
home: {{ odb.0.home | default('') }}
db_name: {{ odb.0.oracle_db_name | default('') }}"
home: {{ odb.home | default('') }}
db_name: {{ odb.oracle_db_name | default('') }}"
when:
- oracle_databases is defined
- oracle_databases | list | length > 0
- odb.0.state == 'present'
- odb.state == 'present'
tags: datapatch
11 changes: 5 additions & 6 deletions roles/oradb_facts/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
# overwrites ansible_facts from the previous one
- name: Gather Facts from Database
ansible.builtin.include_tasks: db_facts.yml
loop:
- "{{ oracle_databases }}"
loop: "{{ oracle_databases }}"
loop_control:
loop_var: odb
label: >-
db_name: {{ odb[0]['oracle_db_name'] | default('') }}
db_unique_name: {{ odb[0]['oracle_db_unique_name'] | default('') }}
db_name: {{ odb['oracle_db_name'] | default('') }}
db_unique_name: {{ odb['oracle_db_unique_name'] | default('') }}
port: {{ _listener_port_cdb }}
service: {{ _db_service_name }}
state: {{ odb[0]['state'] | default('present') }}
state: {{ odb['state'] | default('present') }}
when:
- odb[0]['state'] | default('present') == 'present'
- odb['state'] | default('present') == 'present'
7 changes: 4 additions & 3 deletions roles/oradb_manage_db/tasks/assert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
quiet: true
fail_msg: "Missing element with listener_name in listener_installed!"
that:
- listener_installed | default([])
| selectattr('listener_name', 'match', odb.listener_name)
| list | length == 1
- >-
listener_installed | default([])
| selectattr('listener_name', 'equalto', odb.listener_name)
| list | length == 1
with_items: "{{ oracle_databases | selectattr('listener_name', 'defined') }}"
register: assert2
loop_control:
Expand Down
4 changes: 2 additions & 2 deletions roles/oradb_manage_grants/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
- opdb.0.state == 'present'
- (opdb.1.grants is defined or opdb.1.object_privs is defined)
- >-
oracle_databases | selectattr('oracle_db_name', 'match', opdb.0.cdb)
oracle_databases | selectattr('oracle_db_name', 'equalto', opdb.0.cdb)
| map(attribute='state') | list | first == 'present'
run_once: "{{ _oraswgi_meta_configure_cluster }}"
become: true
Expand Down Expand Up @@ -147,7 +147,7 @@
- opdb.0.state == 'present'
- (opdb.1.grants is defined or opdb.1.object_privs is defined)
- >-
oracle_databases | selectattr('oracle_db_name', 'match', opdb.0.cdb)
oracle_databases | selectattr('oracle_db_name', 'equalto', opdb.0.cdb)
| map(attribute='state') | list | first == 'present'
run_once: "{{ _oraswgi_meta_configure_cluster }}"
become: true
Expand Down
2 changes: 1 addition & 1 deletion roles/oradb_manage_parameters/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
- opdb.0.state == 'present'
- opdb.1 is defined
- >-
oracle_databases | selectattr('oracle_db_name', 'match', opdb.0.cdb)
oracle_databases | selectattr('oracle_db_name', 'equalto', opdb.0.cdb)
| map(attribute='state') | list | first == 'present'
become: true
become_user: "{{ oracle_user }}"
Expand Down
2 changes: 1 addition & 1 deletion roles/oradb_manage_profiles/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
- opdb.0.state == 'present'
- opdb.1 is defined
- >-
oracle_databases | selectattr('oracle_db_name', 'match', opdb.0.cdb)
oracle_databases | selectattr('oracle_db_name', 'equalto', opdb.0.cdb)
| map(attribute='state') | list | first == 'present'
run_once: "{{ _oraswgi_meta_configure_cluster }}"
become: true
Expand Down
17 changes: 8 additions & 9 deletions roles/oradb_manage_redo/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@
user: "{{ db_user }}"
password: "{{ _db_password_cdb }}"
mode: "{{ db_mode }}"
size: "{{ odb.0.redolog_size }}"
groups: "{{ odb.0.redolog_groups }}"
size: "{{ odb.redolog_size }}"
groups: "{{ odb.redolog_groups }}"
environment: "{{ _oracle_env }}"
run_once: "{{ _oraswgi_meta_configure_cluster }}"
loop:
- "{{ oracle_databases | flatten(levels=1) }}"
loop: "{{ oracle_databases }}"
when:
- oracle_databases is defined
- odb.0.redolog_size is defined
- odb.0.redolog_groups is defined
- odb.0.state == 'present'
- odb.redolog_size is defined
- odb.redolog_groups is defined
- odb.state == 'present'
become_user: "{{ oracle_user }}"
become: true
loop_control:
loop_var: odb
label: >-
service: {{ _db_service_name }}:{{ _listener_port_cdb }}
groups: {{ odb.0.redolog_groups }}
size: {{ odb.0.redolog_size }}
groups: {{ odb.redolog_groups | default('') }}
size: {{ odb.redolog_size | default('') }}
2 changes: 1 addition & 1 deletion roles/oradb_manage_roles/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
- opdb.0.state == 'present'
- opdb.1 is defined
- >-
oracle_databases | selectattr('oracle_db_name', 'match', opdb.0.cdb)
oracle_databases | selectattr('oracle_db_name', 'equalto', opdb.0.cdb)
| map(attribute='state') | list | first == 'present'
loop_control:
loop_var: opdb
Expand Down
Loading

0 comments on commit 659e076

Please sign in to comment.