From 370290a7d76fe9faead1d39211d6367528d32c84 Mon Sep 17 00:00:00 2001 From: dougortiz Date: Thu, 24 Aug 2023 13:52:41 -0600 Subject: [PATCH] Updated roles: init_dbserver, and setup_pgd. All tasks related to: PGD, PGD CAMO, and PGD GROUP COMMIT SCOPES --- roles/init_dbserver/tasks/init_dbserver.yml | 14 --- roles/init_dbserver/tasks/setup_tde.yml | 2 +- .../tasks/validate_init_dbserver.yml | 2 +- roles/init_dbserver/tasks/verify_tde_vars.yml | 4 +- roles/setup_pgd/README.md | 2 - roles/setup_pgd/defaults/main.yml | 100 ++++-------------- .../pgd_camo_commitscope_configuration.yml | 96 +++-------------- roles/setup_pgd/tasks/pgd_commit_scopes.yml | 23 ++++ .../pgd_group_commitscope_configuration.yml | 84 --------------- .../pgd_parallel_processes_parameters.yml | 8 -- roles/setup_pgd/tasks/rm_pgd.yml | 12 --- roles/setup_pgd/tasks/setup_pgd.yml | 62 ++--------- roles/setup_pgd/tasks/setup_tde.yml | 2 +- .../tasks/verify_commitscope_settings.yml} | 22 ---- roles/setup_pgd/tasks/verify_tde_vars.yml | 4 +- 15 files changed, 76 insertions(+), 361 deletions(-) create mode 100644 roles/setup_pgd/tasks/pgd_commit_scopes.yml rename roles/{init_dbserver/tasks/verify_pgd_settings.yml => setup_pgd/tasks/verify_commitscope_settings.yml} (63%) diff --git a/roles/init_dbserver/tasks/init_dbserver.yml b/roles/init_dbserver/tasks/init_dbserver.yml index 35cb062e8..03bcfa473 100644 --- a/roles/init_dbserver/tasks/init_dbserver.yml +++ b/roles/init_dbserver/tasks/init_dbserver.yml @@ -51,14 +51,6 @@ - hostvars[inventory_hostname].pgd.use_physical_backup is defined - hostvars[inventory_hostname].pgd.use_physical_backup|bool -- name: Import PGD verify tasks - ansible.builtin.import_tasks: verify_pgd_settings.yml - when: - - validate_only|bool or use_validation|bool - - not remove_only|bool - - install_pgd - - pgd_commit_scopes | length > 0 - - name: Force cleanup based on force_initdb ansible.builtin.include_tasks: rm_initdb.yml when: > @@ -112,9 +104,3 @@ - validate_only|bool or use_validation|bool - not remove_only|bool - run_initdb - -- name: Import PGD validate tasks - ansible.builtin.import_tasks: validate_pgd_settings.yml - when: - - validate_only|bool or use_validation|bool - - not remove_only|bool diff --git a/roles/init_dbserver/tasks/setup_tde.yml b/roles/init_dbserver/tasks/setup_tde.yml index bfae22586..511b8d1a3 100644 --- a/roles/init_dbserver/tasks/setup_tde.yml +++ b/roles/init_dbserver/tasks/setup_tde.yml @@ -9,7 +9,7 @@ become: true when: - edb_master_key|length > 0 - - pg_data not in edb_master_key_location + - edb_master_key_location not in pg_data - name: Store edb_master_key in a secure location ansible.builtin.copy: diff --git a/roles/init_dbserver/tasks/validate_init_dbserver.yml b/roles/init_dbserver/tasks/validate_init_dbserver.yml index 544c7f051..5fa781334 100644 --- a/roles/init_dbserver/tasks/validate_init_dbserver.yml +++ b/roles/init_dbserver/tasks/validate_init_dbserver.yml @@ -67,7 +67,7 @@ ansible.builtin.wait_for: port: "{{ pg_port }}" state: started - msg: "Port {{ pg_port }} is listening." + msg: "Port {{ pg_port }} is not listening." become: true - name: Check pg_unix_socket_directories socket diff --git a/roles/init_dbserver/tasks/verify_tde_vars.yml b/roles/init_dbserver/tasks/verify_tde_vars.yml index ced442903..56306a96c 100644 --- a/roles/init_dbserver/tasks/verify_tde_vars.yml +++ b/roles/init_dbserver/tasks/verify_tde_vars.yml @@ -1,7 +1,7 @@ --- -- name: Verify edb_key_wrap_cmd and edb_key_unwrap_cmd +- name: Verify edb_key_wrap_cmd is defined or not ansible.builtin.fail: - msg: "edb_key_wrap_cmd and edb_key_unwrap_cmd are must for initializing a cluster with TDE" + msg: "edb_key_wrap_cmd and edb_key_unwrap_cmd are must for initializing a cluster" when: edb_key_wrap_cmd|length < 1 or edb_key_unwrap_cmd|length < 1 - name: Verify edb_master_key and edb_secure_master_key diff --git a/roles/setup_pgd/README.md b/roles/setup_pgd/README.md index 4df66057f..0bea989d3 100644 --- a/roles/setup_pgd/README.md +++ b/roles/setup_pgd/README.md @@ -130,8 +130,6 @@ Dependencies This role does not have any dependencies, but package repositories should have been configured beforehand with the `setup_repo` role. At least one lead primary must exist and a database cluster must be initialized on that node. -======= - diff --git a/roles/setup_pgd/defaults/main.yml b/roles/setup_pgd/defaults/main.yml index 0933a3547..99aed98e2 100644 --- a/roles/setup_pgd/defaults/main.yml +++ b/roles/setup_pgd/defaults/main.yml @@ -34,7 +34,6 @@ pass_dir: "~/.edb" pg_local_wal_archive_dir: "" edb_audit_directory: "" - # unix socket domain directories pg_unix_socket_directories: - "/var/run/postgresql" @@ -92,24 +91,8 @@ pgd_cluster_nodes: [] local_node_dsn: "" lead_primary_dsn: "" -etc_hosts_lists: [] - -supported_os: - - CentOS7 - - CentOS8 - - RedHat7 - - RedHat8 - - Rocky8 - - AlmaLinux8 - - OracleLinux7 - -supported_pg_type: - - EPAS - - PG - -supported_pg_version: - - 14 - - 15 +# For CAMO Commit Scopes +max_prepared_transactions: 100 # The following parameters must be configured in the 'pgd_commit_scopes' list # the values below are examples and should be adjusted to your requirements @@ -129,63 +112,26 @@ supported_pg_version: # - member_nodes: ['edb-primary3'] # - default_group_cs: true # - cs_rule: "ALL ( pgd_remaining_nodes ) GROUP COMMIT" -supported_pgd_version: - - 5 +pgd_commit_scopes: "" -<<<<<<< HEAD -<<<<<<< HEAD -# For CAMO Commit Scopes -max_prepared_transactions: 100 +etc_hosts_lists: [] -pgd_commit_scopes: "" -======= -pgd_commit_scopes: - - cs_name: 'camo_scope_1' - cs_type: 'CAMO' # either camo or group_commit - parent_group: 'pgd_cluster' # this group is present in cluster - cs_origin_node_group: 'pgd_two_nodes' # this group may or may not be present - member_nodes: ['edb-primary1', 'edb-primary2'] - default_group_cs: true # don't make mandatory, default('false') if not present in array - cs_rule: "ALL ( pgd_two_nodes ) ON visible CAMO DEGRADE ON (timeout=500s) TO ASYNC" - - cs_name: 'groupcommit_scope_1' - cs_type: 'GROUP_COMMIT' - parent_group: 'pgd_cluster' - cs_origin_node_group: 'pgd_remaining_nodes' - member_nodes: ['edb-primary3'] - default_group_cs: false - cs_rule: "ALL ( pgd_remaining_nodes ) GROUP COMMIT" ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) -======= -# The following parameters must be configured in the 'pgd_commit_scopes' list -# the values below are examples and should be adjusted to your requirements -# for CAMO -# - cs_type: 'CAMO' -# for GROUP_COMMIT -# - cs_type: 'GROUP_COMMIT' -# for CAMO -# - cs_name: 'camo_scope_1' -# for GROUP_COMMIT -# - cs_name: 'group_commit_scope_1' -# - parent_group: 'pgd_cluster' -# for CAMO -# - cs_origin_node_group: 'pgd_two_nodes' -# for GROUP_COMMIT -# - cs_origin_node_group: 'pgd_gc_nodes' -# for CAMO -# - member_nodes: ['edb-primary1', 'edb-primary2'] -# for GROUP_COMMIT -# - member_nodes: ['edb-primary3'] -# - default_group_cs: true -# for CAMO -# - cs_rule: "ALL ( pgd_two_nodes ) ON visible CAMO DEGRADE ON (timeout=500s) TO ASYNC" -# for GROUP_COMMIT -# - cs_rule: "ALL ( pgd_remaining_nodes ) GROUP COMMIT" -pgd_commit_scopes: - - cs_name: '' - cs_type: '' - parent_group: '' - cs_origin_node_group: '' - member_nodes: [''] - default_group_cs: true - cs_rule: "" ->>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.) +supported_os: + - CentOS7 + - CentOS8 + - RedHat7 + - RedHat8 + - Rocky8 + - AlmaLinux8 + - OracleLinux7 + +supported_pg_type: + - EPAS + - PG + +supported_pg_version: + - 14 + - 15 + +supported_pgd_version: + - 5 diff --git a/roles/setup_pgd/tasks/pgd_camo_commitscope_configuration.yml b/roles/setup_pgd/tasks/pgd_camo_commitscope_configuration.yml index e70a8b73c..331c89bb9 100644 --- a/roles/setup_pgd/tasks/pgd_camo_commitscope_configuration.yml +++ b/roles/setup_pgd/tasks/pgd_camo_commitscope_configuration.yml @@ -6,11 +6,7 @@ tasks_from: execute_sql_scripts vars: pg_query: -<<<<<<< HEAD - query: "SELECT COUNT(1) FROM bdr.node_group WHERE node_group_name = '{{ item.parent_group }}'" -======= - - query: "SELECT COUNT(1) FROM bdr.node_group WHERE node_group_name = '{{ pgd_commit_scopes[0].parent_group }}'" ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) db: "{{ pgd_cluster_database }}" - name: Store status of existence of PGD parent group @@ -23,11 +19,7 @@ tasks_from: execute_sql_scripts vars: pg_query: -<<<<<<< HEAD - query: "SELECT COUNT(1) FROM bdr.node_group WHERE node_group_name = '{{ item.cs_origin_node_group }}'" -======= - - query: "SELECT COUNT(1) FROM bdr.node_group WHERE node_group_name = '{{ pgd_commit_scopes[0].cs_origin_node_group }}'" ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) db: "{{ pgd_cluster_database }}" - name: Store status of existence of PGD commit scope origin node group @@ -40,27 +32,15 @@ tasks_from: execute_sql_scripts vars: pg_query: -<<<<<<< HEAD - query: "SELECT bdr.create_node_group(node_group_name := '{{ item.cs_origin_node_group }}', parent_group_name := '{{ item.parent_group }}', -======= - - query: "SELECT bdr.create_node_group(node_group_name := '{{ pgd_commit_scopes[0].cs_origin_node_group }}', - parent_group_name := '{{ pgd_commit_scopes[0].parent_group }}', ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) join_node_group := false )" db: "{{ pgd_cluster_database }}" ignore_query_execution_error: false when: -<<<<<<< HEAD - inventory_hostname == item.member_nodes[0] - _pgd_camo_originnodegroup_exists|int == 0 and _pgd_camo_parentgroup_exists|int == 1 - - item.cs_type == 'CAMO' -======= - - inventory_hostname == pgd_commit_scopes[0].member_nodes[0] - - _pgd_camo_originnodegroup_exists|int == 0 and _pgd_camo_parentgroup_exists|int == 1 - - pgd_commit_scopes[0].cs_type == 'CAMO' ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) - name: Run query to re-check if PGD CAMO commit scope origin node group ansible.builtin.include_role: @@ -68,32 +48,21 @@ tasks_from: execute_sql_scripts vars: pg_query: -<<<<<<< HEAD - query: "SELECT COUNT(1) FROM bdr.node_group WHERE node_group_name = '{{ item.cs_origin_node_group }}'" -======= - - query: "SELECT COUNT(1) FROM bdr.node_group WHERE node_group_name = '{{ pgd_commit_scopes[0].cs_origin_node_group }}'" ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) db: "{{ pgd_cluster_database }}" - name: Store status of existence of PGD commit scope origin node group ansible.builtin.set_fact: _pgd_camo_originnodegroup_exists: "{{ sql_query_output.results[0].query_result[0].count | int }}" -<<<<<<< HEAD # FIX ME: Get 'join' to work -======= ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) - name: Switch primary node towards PGD node sub group with two nodes when CAMO ansible.builtin.include_role: name: manage_dbserver tasks_from: execute_sql_scripts vars: pg_query: -<<<<<<< HEAD - query: "SELECT bdr.switch_node_group(node_group_name := '{{ item.cs_origin_node_group }}', -======= - - query: "SELECT bdr.switch_node_group(node_group_name := '{{ pgd_commit_scopes[0].cs_origin_node_group }}', ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) wait_for_completion := true )" db: "{{ pgd_cluster_database }}" @@ -101,13 +70,7 @@ when: - inventory_hostname == node - _pgd_camo_originnodegroup_exists|int == 1 and _pgd_camo_parentgroup_exists|int == 1 -<<<<<<< HEAD - - item.cs_type == 'CAMO' loop: "{{ item.member_nodes }}" -======= - - pgd_commit_scopes[0].cs_type == 'CAMO' - loop: "{{ pgd_commit_scopes[0].member_nodes }}" ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) loop_control: loop_var: node @@ -119,28 +82,16 @@ throttle: 1 vars: pg_query: -<<<<<<< HEAD - query: "SELECT bdr.add_commit_scope(commit_scope_name := '{{ item.cs_name }}', origin_node_group := '{{ item.cs_origin_node_group }}', rule := '{{ item.cs_rule }}' -======= - - query: "SELECT bdr.add_commit_scope(commit_scope_name := '{{ pgd_commit_scopes[0].cs_name }}', - origin_node_group := '{{ pgd_commit_scopes[0].cs_origin_node_group }}', - rule := '{{ pgd_commit_scopes[0].cs_rule }}' ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) )" db: "{{ pgd_cluster_database }}" ignore_query_execution_error: false when: -<<<<<<< HEAD - inventory_hostname == node - _pgd_camo_originnodegroup_exists|int == 1 and _pgd_camo_parentgroup_exists|int == 1 loop: "{{ item.member_nodes }}" -======= - - inventory_hostname == node - - _pgd_camo_originnodegroup_exists|int == 1 and _pgd_camo_parentgroup_exists|int == 1 - loop: "{{ pgd_commit_scopes[0].member_nodes }}" ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) loop_control: loop_var: node @@ -150,11 +101,7 @@ tasks_from: execute_sql_scripts vars: pg_query: -<<<<<<< HEAD - query: "SELECT COUNT(1) FROM bdr.commit_scopes WHERE commit_scope_name = '{{ item.cs_name }}'" -======= - - query: "SELECT COUNT(1) FROM bdr.commit_scopes WHERE commit_scope_name = '{{ pgd_commit_scopes[0].cs_name }}'" ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) db: "{{ pgd_cluster_database }}" - name: Store status of existence of PGD CAMO commit scope @@ -169,25 +116,13 @@ throttle: 1 vars: pg_query: -<<<<<<< HEAD - query: "SELECT bdr.alter_node_group_option(node_group_name := '{{ item.cs_origin_node_group }}', config_key := 'default_commit_scope', config_value := '{{ item.cs_name }}' -======= - - query: "SELECT bdr.alter_node_group_option(node_group_name := '{{ pgd_commit_scopes[0].cs_origin_node_group }}', - config_key := 'default_commit_scope', - config_value := '{{ pgd_commit_scopes[0].cs_name }}' ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) )" db: "{{ pgd_cluster_database }}" ignore_query_execution_error: false when: -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.) - - item.default_group_cs|bool - - item.cs_type|string == 'CAMO' - _pgd_camoscope_exists|int == 1 and _pgd_camo_originnodegroup_exists|int == 1 - name: Configure BDR 'default_streaming_mode' to off @@ -205,30 +140,25 @@ db: "{{ pgd_cluster_database }}" ignore_query_execution_error: false when: - - item.default_group_cs|bool - - item.cs_type|string == 'CAMO' - _pgd_camoscope_exists|int == 1 and _pgd_camo_originnodegroup_exists|int == 1 - name: ALTER max_prepared_transactions - community.postgresql.postgresql_query: - query: >- - ALTER SYSTEM SET max_prepared_transactions = '{{ max_prepared_transactions }}' - port: "{{ pg_port }}" - db: "{{ pg_database }}" - login_user: "{{ pg_owner }}" - login_unix_socket: "{{ pg_unix_socket_directories[0] }}" - autocommit: true - no_log: "{{ disable_logging }}" - become: true - become_user: "{{ pg_owner }}" + ansible.builtin.include_role: + name: manage_dbserver + tasks_from: execute_sql_scripts + apply: + throttle: 1 + vars: + pg_query: + - query: "ALTER SYSTEM SET max_prepared_transactions = '{{ max_prepared_transactions }}'" + db: "{{ pg_database }}" + autocommit: true + ignore_query_execution_error: false + when: + - _pgd_camoscope_exists|int == 1 and _pgd_camo_originnodegroup_exists|int == 1 - name: Restart the pg service ansible.builtin.systemd: name: "{{ pg_service }}" state: restarted become: true -======= - - pgd_commit_scopes[0].default_group_cs|bool == true - - pgd_commit_scopes[0].cs_type|string == 'CAMO' - - _pgd_camoscope_exists|int == 1 and _pgd_camo_originnodegroup_exists|int == 1 ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) diff --git a/roles/setup_pgd/tasks/pgd_commit_scopes.yml b/roles/setup_pgd/tasks/pgd_commit_scopes.yml new file mode 100644 index 000000000..6156779a2 --- /dev/null +++ b/roles/setup_pgd/tasks/pgd_commit_scopes.yml @@ -0,0 +1,23 @@ +--- +# since we know only one is populated based on verify_pgd_settings in init_dbserver +# set both and only enter the one that is populated +- name: Filter items based on cs_type + set_fact: + filtered_items_camo: "{{ pgd_commit_scopes | selectattr('cs_type', 'equalto', 'CAMO') | list }}" + filtered_items_group_commit: "{{ pgd_commit_scopes | selectattr('cs_type', 'equalto', 'GROUP_COMMIT') | list }}" + +- name: Include tasks to setup CAMO + ansible.builtin.include_tasks: pgd_camo_commitscope_configuration.yml + loop: "{{ filtered_items_camo }}" + loop_control: + label: "{{ item.cs_name }}" + when: + - filtered_items_camo|length > 0 + +- name: Include tasks to setup GROUP_COMMIT + ansible.builtin.include_tasks: pgd_group_commitscope_configuration.yml + loop: "{{ filtered_items_group_commit }}" + loop_control: + label: "{{ item.cs_name }}" + when: + - filtered_items_group_commit|length > 0 diff --git a/roles/setup_pgd/tasks/pgd_group_commitscope_configuration.yml b/roles/setup_pgd/tasks/pgd_group_commitscope_configuration.yml index 4761af745..2f6479eb1 100644 --- a/roles/setup_pgd/tasks/pgd_group_commitscope_configuration.yml +++ b/roles/setup_pgd/tasks/pgd_group_commitscope_configuration.yml @@ -1,32 +1,12 @@ --- # Group Commit Scope -<<<<<<< HEAD -======= -- name: Run query to check if PGD group commit scope exists - ansible.builtin.include_role: - name: manage_dbserver - tasks_from: execute_sql_scripts - vars: - pg_query: - - query: "SELECT COUNT(1) FROM bdr.node_group WHERE node_group_name = '{{ pgd_commit_scopes[1].cs_name }}'" - db: "{{ pgd_cluster_database }}" - -- name: Store status of existence of PGD group commit scope - ansible.builtin.set_fact: - _pgd_groupcommitscope_exists: "{{ sql_query_output.results[0].query_result[0].count | int }}" - ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) - name: Run query to check if PGD group commit scope origin node group ansible.builtin.include_role: name: manage_dbserver tasks_from: execute_sql_scripts vars: pg_query: -<<<<<<< HEAD - query: "SELECT COUNT(1) FROM bdr.node_group WHERE node_group_name = '{{ item.cs_origin_node_group }}'" -======= - - query: "SELECT COUNT(1) FROM bdr.node_group WHERE node_group_name = '{{ pgd_commit_scopes[1].cs_origin_node_group }}'" ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) db: "{{ pgd_cluster_database }}" - name: Store status of existence of PGD commit scope origin node group @@ -39,11 +19,7 @@ tasks_from: execute_sql_scripts vars: pg_query: -<<<<<<< HEAD - query: "SELECT COUNT(1) FROM bdr.node_group WHERE node_group_name = '{{ item.parent_group }}'" -======= - - query: "SELECT COUNT(1) FROM bdr.node_group WHERE node_group_name = '{{ pgd_commit_scopes[1].parent_group }}'" ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) db: "{{ pgd_cluster_database }}" - name: Store status of existence of PGD group commit parent group @@ -56,27 +32,15 @@ tasks_from: execute_sql_scripts vars: pg_query: -<<<<<<< HEAD - query: "SELECT bdr.create_node_group(node_group_name := '{{ item.cs_origin_node_group }}', parent_group_name := '{{ item.parent_group }}', -======= - - query: "SELECT bdr.create_node_group(node_group_name := '{{ pgd_commit_scopes[1].cs_origin_node_group }}', - parent_group_name := '{{ pgd_commit_scopes[1].parent_group }}', ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) join_node_group := false )" db: "{{ pgd_cluster_database }}" ignore_query_execution_error: false when: -<<<<<<< HEAD - inventory_hostname == item.member_nodes[0] - _pgd_groupcommit_originnodegroup_exists|int == 0 and _pgd_groupcommit_parentgroup_exists|int == 1 - - item.cs_type == 'GROUP_COMMIT' -======= - - inventory_hostname == pgd_commit_scopes[1].member_nodes[0] - - _pgd_groupcommit_originnodegroup_exists|int == 0 and _pgd_groupcommit_parentgroup_exists|int == 1 - - pgd_commit_scopes[1].cs_type == 'GROUP_COMMIT' ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) - name: Run query to re-check if PGD group commit scope origin node group ansible.builtin.include_role: @@ -84,32 +48,21 @@ tasks_from: execute_sql_scripts vars: pg_query: -<<<<<<< HEAD - query: "SELECT COUNT(1) FROM bdr.node_group WHERE node_group_name = '{{ item.cs_origin_node_group }}'" -======= - - query: "SELECT COUNT(1) FROM bdr.node_group WHERE node_group_name = '{{ pgd_commit_scopes[1].cs_origin_node_group }}'" ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) db: "{{ pgd_cluster_database }}" - name: Store status of existence of PGD commit scope origin node group ansible.builtin.set_fact: _pgd_groupcommit_originnodegroup_exists: "{{ sql_query_output.results[0].query_result[0].count | int }}" -<<<<<<< HEAD # FIX ME: Get 'join' to work -======= ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) - name: Switch node towards PGD node sub group when Group Commit ansible.builtin.include_role: name: manage_dbserver tasks_from: execute_sql_scripts vars: pg_query: -<<<<<<< HEAD - query: "SELECT bdr.switch_node_group(node_group_name := '{{ item.cs_origin_node_group }}', -======= - - query: "SELECT bdr.switch_node_group(node_group_name := '{{ pgd_commit_scopes[1].cs_origin_node_group }}', ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) wait_for_completion := true )" db: "{{ pgd_cluster_database }}" @@ -117,13 +70,7 @@ when: - inventory_hostname == node - _pgd_groupcommit_originnodegroup_exists|int == 1 -<<<<<<< HEAD - - item.cs_type == 'GROUP_COMMIT' loop: "{{ item.member_nodes }}" -======= - - pgd_commit_scopes[1].cs_type == 'GROUP_COMMIT' - loop: "{{ pgd_commit_scopes[1].member_nodes }}" ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) loop_control: loop_var: node @@ -135,20 +82,13 @@ throttle: 1 vars: pg_query: -<<<<<<< HEAD - query: "SELECT bdr.add_commit_scope(commit_scope_name := '{{ item.cs_name }}', origin_node_group := '{{ item.cs_origin_node_group }}', rule := '{{ item.cs_rule }}' -======= - - query: "SELECT bdr.add_commit_scope(commit_scope_name := '{{ pgd_commit_scopes[1].cs_name }}', - origin_node_group := '{{ pgd_commit_scopes[1].cs_origin_node_group }}', - rule := '{{ pgd_commit_scopes[1].cs_rule }}' ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) )" db: "{{ pgd_cluster_database }}" ignore_query_execution_error: false when: -<<<<<<< HEAD - inventory_hostname == node - _pgd_groupcommit_originnodegroup_exists|int == 1 loop: "{{ item.member_nodes }}" @@ -168,14 +108,6 @@ ansible.builtin.set_fact: _pgd_groupcommitscope_exists: "{{ sql_query_output.results[0].query_result[0].count | int }}" -======= - - inventory_hostname == node - - _pgd_groupcommit_originnodegroup_exists|int == 1 - loop: "{{ pgd_commit_scopes[1].member_nodes }}" - loop_control: - loop_var: node - ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) - name: Configure PGD Cluster default Group Commit Scope ansible.builtin.include_role: name: manage_dbserver @@ -184,25 +116,14 @@ throttle: 1 vars: pg_query: -<<<<<<< HEAD - query: "SELECT bdr.alter_node_group_option(node_group_name := '{{ item.cs_origin_node_group }}', config_key := 'default_commit_scope', config_value := '{{ item.cs_name }}' -======= - - query: "SELECT bdr.alter_node_group_option(node_group_name := '{{ pgd_commit_scopes[1].cs_origin_node_group }}', - config_key := 'default_commit_scope', - config_value := '{{ pgd_commit_scopes[1].cs_name }}' ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) )" db: "{{ pgd_cluster_database }}" ignore_query_execution_error: false when: -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.) - item.default_group_cs|bool - - item.cs_type|string == 'GROUP_COMMIT' - _pgd_groupcommitscope_exists|int == 1 and _pgd_groupcommit_originnodegroup_exists|int == 1 - name: Restart the pg service @@ -210,8 +131,3 @@ name: "{{ pg_service }}" state: restarted become: true -======= - - pgd_commit_scopes[1].default_group_cs|bool == true - - pgd_commit_scopes[1].cs_type|string == 'GROUP_COMMIT' - - _pgd_camoscope_exists|int == 1 and _pgd_camo_originnodegroup_exists|int == 1 ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) diff --git a/roles/setup_pgd/tasks/pgd_parallel_processes_parameters.yml b/roles/setup_pgd/tasks/pgd_parallel_processes_parameters.yml index 12bfddb02..27d2c1a30 100644 --- a/roles/setup_pgd/tasks/pgd_parallel_processes_parameters.yml +++ b/roles/setup_pgd/tasks/pgd_parallel_processes_parameters.yml @@ -51,15 +51,7 @@ - name: Calculate required setting for max_worker_processes ansible.builtin.set_fact: -<<<<<<< HEAD -<<<<<<< HEAD _base_max_worker_processes: "{{ (_num_pgd_nodes | int + 1*8 + 2*2 + 2 *( _num_pgd_nodes | int-1 )) + _twice_pgd_nodes | int }}" -======= - _base_max_worker_processes: "{{ (_num_pgd_nodes | int + 1*8 + 2*2 + 2 *( _num_pgd_nodes | int - 1 )) + _twice_pgd_nodes | int }}" ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) -======= - _base_max_worker_processes: "{{ (_num_pgd_nodes | int + 1*8 + 2*2 + 2 *( _num_pgd_nodes | int-1 )) + _twice_pgd_nodes | int }}" ->>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.) - name: Evaluate the current setting of max_worker_processes, max_replication_slots and max_wal_senders ansible.builtin.set_fact: diff --git a/roles/setup_pgd/tasks/rm_pgd.yml b/roles/setup_pgd/tasks/rm_pgd.yml index 926a69ac0..3c35fba82 100644 --- a/roles/setup_pgd/tasks/rm_pgd.yml +++ b/roles/setup_pgd/tasks/rm_pgd.yml @@ -12,10 +12,6 @@ block: - name: Gather PGD node information with state ansible.builtin.include_tasks: verify_pgd_node_group.yml -<<<<<<< HEAD -======= - ->>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.) - name: Part node from PGD cluster ansible.builtin.include_role: name: manage_dbserver @@ -36,10 +32,6 @@ - _pgd_extension_exists == 1 - _pgd_local_node_created == 1 - _pgd_cluster_group_joined == 1 -<<<<<<< HEAD -======= - ->>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.) - name: Drop node from PGD cluster ansible.builtin.include_role: name: manage_dbserver @@ -58,10 +50,6 @@ - _pgd_extension_exists == 1 - _pgd_local_node_created == 1 - _pgd_cluster_group_joined == 1 -<<<<<<< HEAD -======= - ->>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.) - name: Drop database in PGD Node ansible.builtin.include_role: name: manage_dbserver diff --git a/roles/setup_pgd/tasks/setup_pgd.yml b/roles/setup_pgd/tasks/setup_pgd.yml index 883e91ff8..d2a84b6d3 100644 --- a/roles/setup_pgd/tasks/setup_pgd.yml +++ b/roles/setup_pgd/tasks/setup_pgd.yml @@ -19,6 +19,13 @@ msg: "PGD version {{ pgd_version }} is not supported" when: pgd_version|int not in supported_pgd_version +- name: Import PGD verify commit setstings tasks + ansible.builtin.import_tasks: verify_commitscope_settings.yml + when: + - not validate_only|bool + - not remove_only|bool + - pgd_commit_scopes | length > 0 + - name: Verify TDE parameters based on the version and pg_type ansible.builtin.include_tasks: verify_tde_vars.yml when: @@ -102,61 +109,12 @@ - name: Configure SSL if not exists ansible.builtin.import_tasks: pg_ssl_config.yml -<<<<<<< HEAD -======= -- name: Import validate tasks - ansible.builtin.import_tasks: validate_setup_pgd.yml +- name: Include tasks to setup commit scopes + ansible.builtin.include_tasks: pgd_commit_scopes.yml when: - - validate_only|bool or use_validation|bool - -# setup oidentd authentication -- name: Start service oidentd, if not started - ansible.builtin.service: - name: oidentd - state: started - ->>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.) -- name: Filter items based on cs_type 'CAMO' - set_fact: - filtered_items_camo: "{{ pgd_commit_scopes | selectattr('cs_type', 'equalto', 'CAMO') | list }}" - -- name: Display elements of each filtered 'CAMO' item - ansible.builtin.include_tasks: pgd_camo_commitscope_configuration.yml - loop: "{{ filtered_items_camo }}" - loop_control: - label: "{{ item.cs_name }}" - -- name: Filter items based on cs_type 'GROUP_COMMIT' - set_fact: - filtered_items_group_commit: "{{ pgd_commit_scopes | selectattr('cs_type', 'equalto', 'GROUP_COMMIT') | list }}" - -- name: Display elements of each filtered 'GROUP_COMMIT' item - ansible.builtin.include_tasks: pgd_group_commitscope_configuration.yml - loop: "{{ filtered_items_group_commit }}" - loop_control: - label: "{{ item.cs_name }}" + - pgd_commit_scopes|length > 0 - name: Import validate tasks ansible.builtin.import_tasks: validate_setup_pgd.yml when: - validate_only|bool or use_validation|bool -<<<<<<< HEAD -======= - -# Exclusive to pgd setup authentication -- name: Start service oidentd, if not started - ansible.builtin.service: - name: oidentd - state: started - -# Configure PGD with commit scopes -- name: Configure PGD with commit scopes - when: - - not validate_only|bool - become: true - block: - - name: Configure PGD Primary and Secondary Nodes for PGD CAMO - ansible.builtin.import_tasks: pgd_camo_commitscope_configuration.yml - - name: Configure for PGD Group Commit - ansible.builtin.import_tasks: pgd_group_commitscope_configuration.yml ->>>>>>> c5b23aa (Added support for camo and group commit scopes. Updated 'README.md' for 'setup_pgd' role. Added tests for pgd configuration settings in 'main.yml' in 'init_dbserver' role.) diff --git a/roles/setup_pgd/tasks/setup_tde.yml b/roles/setup_pgd/tasks/setup_tde.yml index 2bccd8d29..9827ed2c1 100644 --- a/roles/setup_pgd/tasks/setup_tde.yml +++ b/roles/setup_pgd/tasks/setup_tde.yml @@ -9,7 +9,7 @@ become: true when: - edb_master_key|length > 0 - - pg_data not in edb_master_key_location + - edb_master_key_location not in pg_data - name: Store edb_master_key in a secure location ansible.builtin.copy: diff --git a/roles/init_dbserver/tasks/verify_pgd_settings.yml b/roles/setup_pgd/tasks/verify_commitscope_settings.yml similarity index 63% rename from roles/init_dbserver/tasks/verify_pgd_settings.yml rename to roles/setup_pgd/tasks/verify_commitscope_settings.yml index eb1235239..a5aa06570 100644 --- a/roles/init_dbserver/tasks/verify_pgd_settings.yml +++ b/roles/setup_pgd/tasks/verify_commitscope_settings.yml @@ -1,13 +1,4 @@ --- -<<<<<<< HEAD -======= -- name: Check 'pgd_commit_scopes' dictionary length - ansible.builtin.assert: - that: - - pgd_commit_scopes | length > 0 - msg: "The 'pgd_commit_scopes' list should have at least one dictionary." - ->>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.) - name: Check if cs_type is consistent and the sampe 'cs_type' across the entire list ansible.builtin.assert: that: @@ -35,21 +26,8 @@ msg: "Duplicates found in member_nodes_array" when: has_duplicates -- name: Count true values in default_group_cs - ansible.builtin.set_fact: - true_count: "{{ pgd_commit_scopes | map(attribute='default_group_cs') | select('equalto', true) | list | count }}" - -- name: Fail if more than one true value in default_group_cs - ansible.builtin.fail: - msg: "More than one true value found in default_group_cs" - when: true_count | int > 1 - - name: Check default_group_cs -<<<<<<< HEAD ansible.builtin.assert: -======= - assert: ->>>>>>> abab58a (Added checks for 'pgd_commit_scopes' list. Removed 'streaming' and 'max_prepared' for GROUP COMMIT SCOPE.) that: - pgd_commit_scopes | map(attribute='default_group_cs') | select("equalto", true) | list | count > 0 fail_msg: "At least one 'default_group_cs' value should be set to true." diff --git a/roles/setup_pgd/tasks/verify_tde_vars.yml b/roles/setup_pgd/tasks/verify_tde_vars.yml index ced442903..56306a96c 100644 --- a/roles/setup_pgd/tasks/verify_tde_vars.yml +++ b/roles/setup_pgd/tasks/verify_tde_vars.yml @@ -1,7 +1,7 @@ --- -- name: Verify edb_key_wrap_cmd and edb_key_unwrap_cmd +- name: Verify edb_key_wrap_cmd is defined or not ansible.builtin.fail: - msg: "edb_key_wrap_cmd and edb_key_unwrap_cmd are must for initializing a cluster with TDE" + msg: "edb_key_wrap_cmd and edb_key_unwrap_cmd are must for initializing a cluster" when: edb_key_wrap_cmd|length < 1 or edb_key_unwrap_cmd|length < 1 - name: Verify edb_master_key and edb_secure_master_key