From ce4509fb89a23b55f411a57da0c5e1a3b37265c2 Mon Sep 17 00:00:00 2001 From: Thilo Solbrig Date: Mon, 14 Oct 2024 16:17:04 +0200 Subject: [PATCH] Extracting SGA and processes parameters from oracle_databases and oracle_asm_instance improved --- changelogs/fragments/sga_calculation.yml | 3 ++ .../tasks/aggregate_processes.yml | 9 +--- roles/orahost_meta/tasks/aggregate_sgas.yml | 24 +--------- roles/orahost_meta/tasks/main.yml | 47 +++++++++++-------- 4 files changed, 35 insertions(+), 48 deletions(-) create mode 100644 changelogs/fragments/sga_calculation.yml diff --git a/changelogs/fragments/sga_calculation.yml b/changelogs/fragments/sga_calculation.yml new file mode 100644 index 000000000..cca41ae76 --- /dev/null +++ b/changelogs/fragments/sga_calculation.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "orahost_meta: Applying 'lower' filter to oracle_databases+oracle_asm_instance converts list to string (oravirt#484)" diff --git a/roles/orahost_meta/tasks/aggregate_processes.yml b/roles/orahost_meta/tasks/aggregate_processes.yml index 6a6d6d324..89bd1b184 100644 --- a/roles/orahost_meta/tasks/aggregate_processes.yml +++ b/roles/orahost_meta/tasks/aggregate_processes.yml @@ -1,15 +1,10 @@ --- -- name: aggregate_processes | Pick processes parameter - ansible.builtin.set_fact: - __orahost_oracle_database_processes: | - {{ (__orahost_oracle_database.init_parameters | selectattr('name', 'equalto', 'processes'))[0].value }} - - name: aggregate_processes | Sum up processes ansible.builtin.set_fact: oracle_databases_processes_sum: | - {{ (oracle_databases_processes_sum | default(0) | int) + (__orahost_oracle_database_processes | int) }} + {{ (oracle_databases_processes_sum | default(0) | int) + (__orahost_oracle_database_processes.value | int) }} - name: aggregate_processes | Calc max processes ansible.builtin.set_fact: oracle_databases_processes_max: >- - {{ [(oracle_databases_processes_max | default(0) | int), (__orahost_oracle_database_processes | int)] | max }} + {{ [(oracle_databases_processes_max | default(0) | int), (__orahost_oracle_database_processes.value | int)] | max }} diff --git a/roles/orahost_meta/tasks/aggregate_sgas.yml b/roles/orahost_meta/tasks/aggregate_sgas.yml index b81e1c449..c7127535d 100644 --- a/roles/orahost_meta/tasks/aggregate_sgas.yml +++ b/roles/orahost_meta/tasks/aggregate_sgas.yml @@ -1,30 +1,10 @@ --- -- name: aggregate_sgas | Reset __orahost_oracle_database_sga - ansible.builtin.set_fact: - __orahost_oracle_database_sga: "0" - -- name: aggregate_sgas | sga_max_size preceeds sga_target - block: - - name: aggregate_sgas | Derive SGA size from sga_max_size - ansible.builtin.set_fact: - __orahost_oracle_database_sga: | - {{ (__orahost_oracle_database.init_parameters - | selectattr('name','equalto', 'sga_max_size'))[0].value | default(0) | human_to_bytes }} - - - name: aggregate_sgas | Derive SGA size from sga_target - ansible.builtin.set_fact: - __orahost_oracle_database_sga: | - {{ (__orahost_oracle_database.init_parameters - | selectattr('name','equalto', 'sga_target'))[0].value | default(0) | human_to_bytes }} - when: - - __orahost_oracle_database_sga == "0" - - name: aggregate_sgas | Sum up SGAs ansible.builtin.set_fact: oracle_databases_sga_sum: | - {{ (oracle_databases_sga_sum | default(0) | int) + (__orahost_oracle_database_sga | int) }} + {{ (oracle_databases_sga_sum | default(0) | int) + (__orahost_oracle_database_sga.value | human_to_bytes | int) }} - name: aggregate_sgas | Calc max SGA ansible.builtin.set_fact: oracle_databases_sga_max: | - {{ [(oracle_databases_sga_max | default(0) | int), (__orahost_oracle_database_sga | int)] | max }}" + {{ [(oracle_databases_sga_max | default(0) | int), (__orahost_oracle_database_sga.value | human_to_bytes | int)] | max }}" diff --git a/roles/orahost_meta/tasks/main.yml b/roles/orahost_meta/tasks/main.yml index 99076f734..01b6bbd1a 100644 --- a/roles/orahost_meta/tasks/main.yml +++ b/roles/orahost_meta/tasks/main.yml @@ -37,29 +37,38 @@ {{ (__orahost_kdump_state.status.ActiveState == 'active') | ternary(0, 1) }} - name: Calculate SGA aggregates - ansible.builtin.include_tasks: aggregate_sgas.yml - loop: | - {{ (( oracle_databases | default ([]) | selectattr('init_parameters','defined') ) - + ( oracle_asm_instance | default ([]) )) | lower }} - loop_control: - loop_var: __orahost_oracle_database - label: >- - oracle_db_name: {{ __orahost_oracle_database.oracle_db_name | default('') }} - when: - "'sga_target' in __orahost_oracle_database.init_parameters | map(attribute='name') or - 'sga_max_size' in __orahost_oracle_database.init_parameters | map(attribute='name') " + block: + - name: Extract SGA parameters, choose sga_max_size over sga_target if both are definied + ansible.builtin.set_fact: + __orahost_oracle_database_sgas: >- + {{ (__orahost_oracle_database_sgas | default([])) + + (( __orahost_oracle_database_init_parameter | selectattr('name', 'match', '^(?i)sga_max_size$') ) | length > 0 ) + | ternary(__orahost_oracle_database_init_parameter | selectattr('name', 'match', '^(?i)sga_max_size$'), + __orahost_oracle_database_init_parameter | selectattr('name', 'match', '^(?i)sga_target$')) }} + loop: >- + {{ ((oracle_databases | default([])) + (oracle_asm_instance | default([]))) + | map(attribute='init_parameters', default=[]) }} + loop_control: + loop_var: __orahost_oracle_database_init_parameter + when: (__orahost_oracle_database_init_parameter | selectattr('name', 'match', '^(?i)(sga_target|sga_max_size)$')) | length > 0 + + - name: Aggregate SGAs + ansible.builtin.include_tasks: aggregate_sgas.yml + loop: "{{ __orahost_oracle_database_sgas }}" + loop_control: + loop_var: __orahost_oracle_database_sga + label: "{{ __orahost_oracle_database_sga.name + ': ' + __orahost_oracle_database_sga.value }}" - name: Calculate processes aggregates ansible.builtin.include_tasks: aggregate_processes.yml - loop: | - {{ (( oracle_databases | default ([]) | selectattr('init_parameters','defined') ) - + ( oracle_asm_instance | default ([]) )) | lower }} + loop: >- + {{ ((oracle_databases | default([])) + (oracle_asm_instance | default([]))) + | map(attribute='init_parameters', default=[]) + | flatten + | selectattr('name', 'match', '^(?i)processes$') }} loop_control: - loop_var: __orahost_oracle_database - label: >- - oracle_db_name: {{ __orahost_oracle_database.oracle_db_name | default('') }} - when: - "'processes' in __orahost_oracle_database.init_parameters | map(attribute='name')" + loop_var: __orahost_oracle_database_processes + label: "{{ __orahost_oracle_database_processes.name + ': ' + __orahost_oracle_database_processes.value | string }}" - name: Count number of instances (including ASM) ansible.builtin.set_fact: