Skip to content

Commit

Permalink
WIP update pgd (#596)
Browse files Browse the repository at this point in the history
* fix setup_pgd tests

* add setup for pgd cli

* update linting on random errors not in pgd

* update ansible-lint 6.20.1

* update yamllint

* revert

* update repos testing and validation

* update dbt2 packages for validation and testing

* update readme

* update default pgd-cli setting

* update pgd readme
  • Loading branch information
hannahms authored Oct 13, 2023
1 parent 53a6e65 commit b2e51e8
Show file tree
Hide file tree
Showing 32 changed files with 437 additions and 263 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ currently supports the following ansible roles:
| [tuning](roles/tuning/README.md) | The tuning role configures the system and Postgres instances for optimal performances. Most of the configuration values are calculated automatically from available resources found on the system. |
| [init_dbserver](roles/init_dbserver/README.md) | Initialize the EPAS/PostgreSQL cluster (data) directory. |
| [install_dbserver](roles/install_dbserver/README.md) | Install EPAS/PostgreSQL database server packages. |
| [install_from_source](roles/install_from_source/README.md) | Dowload and install software from source. |
| [manage_cnpg](roles/manage_cnpg/README.md) | Manage CloudNativePG/EDB Postgres for Kubernetes clusters and covers common tasks. |
| [manage_dbserver](roles/manage_dbserver/README.md) | Manage EPAS/PostgreSQL clusters and covers common tasks. |
| [manage_pgbouncer](roles/manage_pgbouncer/README.md) | Manage PgBouncer pools list and users. |
| [manage_pgpool2](roles/manage_pgpool2/README.md) | Manage Pgpool-II settings and users. |
| [manage_touchstone_tools](roles/manage_touchstone_tools/README.md) | Manage touchstone tools functions to enable collection and processing of system and database statistics. |
| [manage_operating_system](roles/manage_operating_system/README.md) | Manage operating system settings. |
| [remove_cloudnativepg_sandbox](roles/remove_cloudnativepg_sandbox/README.md) | Remove CloudNativePG Sandbox from Kubernetes cluster. |
| [remove_cloudnativepostgres_sandbox](roles/remove_cloudnativepostgres_sandbox/README.md) | Remove CloudNative Postgres Sandbox from Kubernetes cluster. |
| [setup_cloudnativepg_sandbox](roles/setup_cloudnativepg_sandbox/README.md) | Setup CloudNativePG Sandbox from Kubernetes cluster. |
Expand All @@ -48,15 +50,17 @@ currently supports the following ansible roles:
| [setup_pgbackrest](roles/setup_pgbackrest/README.md) | Set up EPAS/PostgreSQL backups with pgBackRest. |
| [setup_pgbackrestserver](roles/setup_pgbackrestserver/README.md) | Set up pgBackRest server for Postgres backups and recovery. |
| [setup_pgbouncer](roles/setup_pgbouncer/README.md) | Set up PgBouncer connection pooler. |
| [setup_etcd](roles/setup_etcd/README.md) | Set up etcd for patroni cluster. |
| [setup_patroni](roles/setup_patroni/README.md) | Set up for patroni managed cluster. |
| [setup_haproxy](roles/setup_haproxy/README.md) | Set up HaProxy load balancer for Patroni cluster . |
| [setup_etcd](roles/setup_etcd/README.md) | Set up etcd for Patroni cluster. |
| [setup_patroni](roles/setup_patroni/README.md) | Set up for Patroni managed cluster. |
| [setup_pgd](roles/setup_pgd/README.md) | Set up PGD HA cluster. |
| [setup_pgpool2](roles/setup_pgpool2/README.md) | Set up Pgpool-II connection pooler/load balancer. |
| [setup_replication](roles/setup_replication/README.md) | Set up the data replication (synchronous/asynchronous). |
| [setup_repmgr](roles/setup_repmgr/README.md) | Set up Repmgr for PostgreSQL HA cluster. |
| [setup_repo](roles/setup_repo/README.md) | Set up the EDB, PostgreSQL Community and EPEL repositories. |
| [setup_touchstone_tools](roles/setup_touchstone_tools/README.md) | Set up additional packages and software for characterizing system performance. |
| [manage_dbpatches](roles/manage_dbpatches/README.md) | Manage applying patches on dbservers part of EFM cluster. |

| [tuning](roles/tuning/README.md) | Configure system and Postgres instances for optimal performance. |

## Pre-Requisites

Expand Down
1 change: 1 addition & 0 deletions roles/manage_dbserver/tasks/validate_manage_dbserver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ansible.builtin.stat:
path: "{{ pg_user_home }}/.pgpass"
register: pgpass_stat
become: true
become_user: "{{ pg_owner }}"

- name: Check if .psqlrc file was created properly
Expand Down
1 change: 0 additions & 1 deletion roles/setup_dbt2/tasks/dbt2_install_packages_client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
- tmux
- fuse
- fuse-libs
- rsync
- sysstat
state: present
when: ansible_os_family == "RedHat"
Expand Down
1 change: 0 additions & 1 deletion roles/setup_dbt2/tasks/dbt2_install_packages_db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
- tmux
- fuse
- fuse-libs
- rsync
- sysstat
state: present
when: ansible_os_family == "RedHat"
Expand Down
10 changes: 5 additions & 5 deletions roles/setup_dbt2/tasks/validate_setup_dbt2.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
# validate dbt2 db packages installation
- name: Set dbt2_db_package_list
- name: Set dbt2_db_pkg_list
ansible.builtin.set_fact:
dbt2_db_package_list: ['perf', 'rsync', 'tmux', 'fuse', 'fuse-libs', 'sysstat']
dbt2_db_pkg_list: ['perf', 'rsync', 'tmux', 'fuse', 'fuse-libs', 'sysstat', 'dejavu-fonts-common', 'fontconfig']

- name: Gather the package facts
ansible.builtin.package_facts:
strategy: "all"

- name: Check that all packages in dbt2_db_package_list has been installed
- name: Check that all packages in dbt2_db_pkg_list has been installed
ansible.builtin.assert:
that:
- "{{ ansible_facts.packages[package] }} is defined"
fail_msg: "Package {{ package }} has not been installed."
success_msg: "Package {{ package }} has been installed."
loop: "{{ dbt2_db_package_list }}"
loop: "{{ dbt2_db_pkg_list }}"
loop_control:
loop_var: package

Expand Down Expand Up @@ -58,6 +58,6 @@
# reset variables
- name: Reset variables
ansible.builtin.set_fact:
dbt2_db_package_list: null
dbt2_db_pkg_list: null
dbt2_path_stat: null
user_query_result: null
10 changes: 5 additions & 5 deletions roles/setup_dbt2_client/tasks/validate_setup_dbt2_client.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
# validate dbt2 client packages installation
- name: Set dbt2_client_package_list
- name: Set dbt2_client_pkg_list
ansible.builtin.set_fact:
dbt2_client_package_list: ['perf', 'rsync', 'tmux', 'fuse', 'fuse-libs', 'sysstat']
dbt2_client_pkg_list: ['perf', 'rsync', 'tmux', 'fuse', 'fuse-libs', 'sysstat', 'dejavu-fonts-common', 'fontconfig']

- name: Gather the package facts
ansible.builtin.package_facts:
strategy: "all"

- name: Check that all packages in dbt2_client_package_list has been installed
- name: Check that all packages in dbt2_client_pkg_list has been installed
ansible.builtin.assert:
that:
- "{{ ansible_facts.packages[package] }} is defined"
fail_msg: "Package {{ package }} has not been installed."
success_msg: "Package {{ package }} has been installed."
loop: "{{ dbt2_client_package_list }}"
loop: "{{ dbt2_client_pkg_list }}"
loop_control:
loop_var: package

Expand Down Expand Up @@ -56,6 +56,6 @@
# reset variables
- name: Reset variables
ansible.builtin.set_fact:
dbt2_client_package_list: null
dbt2_client_pkg_list: null
dbt2_path_client_stat: null
dbt2_client_sudo_res: null
10 changes: 5 additions & 5 deletions roles/setup_dbt2_driver/tasks/validate_setup_dbt2_driver.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
# validate dbt2 driver packages installation
- name: Set dbt2_driver_package_list
- name: Set dbt2_driver_pkg_list
ansible.builtin.set_fact:
dbt2_driver_package_list: ['perf', 'rsync', 'tmux', 'fuse', 'fuse-libs', 'sysstat']
dbt2_driver_pkg_list: ['perf', 'rsync', 'tmux', 'fuse', 'fuse-libs', 'sysstat', 'dejavu-fonts-common', 'fontconfig']

- name: Gather the package facts
ansible.builtin.package_facts:
strategy: "all"

- name: Check that all packages in dbt2_driver_package_list has been installed
- name: Check that all packages in dbt2_driver_pkg_list has been installed
ansible.builtin.assert:
that:
- "{{ ansible_facts.packages[package] }} is defined"
fail_msg: "Package {{ package }} has not been installed."
success_msg: "Package {{ package }} has been installed."
loop: "{{ dbt2_driver_package_list }}"
loop: "{{ dbt2_driver_pkg_list }}"
loop_control:
loop_var: package

Expand Down Expand Up @@ -56,6 +56,6 @@
# reset variables
- name: Reset variables
ansible.builtin.set_fact:
dbt2_driver_package_list: null
dbt2_driver_pkg_list: null
dbt2_path_driver_stat: null
dbt2_driver_sudo_res: null
60 changes: 33 additions & 27 deletions roles/setup_pgd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,49 +57,61 @@ Name of PGD cluster to be initialized.

Hostname of local node.

The rest of the variables can be configured and are available in the:
### `setup_pgd_cli`

* [roles/setup_pgd/defaults/main.yml](./defaults/main.yml)
* [roles/setup_pgd/vars/PG_RedHat.yml](./vars/PG_RedHat.yml)
* [roles/setup_pgd/vars/EPAS_RedHat.yml](./vars/EPAS_RedHat.yml)
When `true`, the PGD CLI will be installed and configured. Default: `false`.

### `PGD Commit Scopes Configuration`
### `pgd_commit_scopes`

See examples for PGD Commit Scopes available at: [EDB PGD v5](https://www.enterprisedb.com/docs/pgd/5/durability/commit-scopes/).
Sets either CAMO or group commit PGD commit scopes to be configured.
[For more information on PGD Commit Scopes and the caveats you need to consider before implementing,
please refer to the documentation.](https://www.enterprisedb.com/docs/pgd/5/durability/commit-scopes/).

The code below is part of the [roles/setup_pgd/defaults/main.yml](./defaults/main.yml), and
example for configuring two PGD commit scopes is listed below.
For each commit scope, you need to set the:
* `cs_name` - name of the commit scope
* `cs_type` - type of commit scope. Options are `CAMO` or `GROUP_COMMIT`.
* `parent_group` - name of the top level group the member nodes belong to, usually `pgd_cluster_name`.
* `cs_origin_node_group` - name of the subgroup to be created that each node in `member_nodes` will join.
* `member_nodes` - list of hostnames of nodes that will be part of the commit scope.
* `default_group_cs` - flag to set the commit scope as the default commit scope for the `cs_origin_node_group`.
* `cs_rule` - the commit scope rule to be applied to the commit scope. This must be correctly formatted and valid.

The configuration requirements for PGD through the configuration setting variables are:
1. The length of the `member_nodes` for a `camo` commit scope is exactly `two`
2. No node in `member_nodes` for either commit scope can belong to the other commit scope
3. All nodes in `member_nodes` must belong to a `parent_group`
The commit scope configuration requirements are:
1. CAMO and group commit are incompatible with each another. Only one can be enabled per cluster.
2. When `cs_type: CAMO`, only two member data nodes, also referred to as a CAMO pair, can be present.
3. Each host can only be a part of at most one commit scope.
4. The `cs_rule` parameter must be: valid, correctly formatted, and adhere to the correct syntax

COMMIT AT MOST ONCE SCOPE - CAMO
```yaml
# CAMO example
pgd_commit_scopes:
- cs_name: 'camo_scope_1'
cs_type: 'CAMO'
parent_group: 'pgd_cluster'
cs_origin_node_group: 'pgd_two_nodes'
member_nodes: ['edb-primary1', 'edb-primary2']
cs_origin_node_group: 'pgd_camo_group_1'
member_nodes: ['pgd1', 'pgd2']
default_group_cs: true
cs_rule: "ALL ( pgd_two_nodes ) ON visible CAMO DEGRADE ON (timeout=500s) TO ASYNC"
cs_rule: "ALL (pgd_camo_group_1) ON visible CAMO DEGRADE ON (timeout=500s) TO ASYNC"
```
GROUP COMMIT SCOPE
```yaml
# group commit example
pgd_commit_scopes:
- cs_name: 'groupcommit_scope_1'
cs_type: 'GROUP_COMMIT'
parent_group: 'pgd_cluster'
cs_origin_node_group: 'pgd_remaining_nodes'
member_nodes: ['edb-primary3']
cs_origin_node_group: 'pgd_gc_group_1'
member_nodes: ['pgd1', 'pgd2', 'pgd3', 'pgd4']
default_group_cs: true
cs_rule: "ALL ( pgd_remaining_nodes ) GROUP COMMIT"
cs_rule: "ANY 2 (pgd_gc_group_1) GROUP COMMIT"
```
The rest of the variables can be configured and are available in the:
* [roles/setup_pgd/defaults/main.yml](./defaults/main.yml)
* [roles/setup_pgd/vars/PG_RedHat.yml](./vars/PG_RedHat.yml)
* [roles/setup_pgd/vars/EPAS_RedHat.yml](./vars/EPAS_RedHat.yml)
Host Variables
--------------
Expand Down Expand Up @@ -130,8 +142,6 @@ This role does not have any dependencies, but package repositories should have b
configured beforehand with the `setup_repo` role. At least one lead primary must exist
and a database cluster must be initialized on that node.



Example Playbook
----------------

Expand Down Expand Up @@ -195,11 +205,6 @@ Below is an example of how to include the `setup_pgd` role:
pg_version: 15 # Change the version of Postgres you want to install
pg_type: "EPAS" # Change the pg_type to EPAS if EDB Advanced Server is needed
repo_token: "XXXXXXXXX" # EDB repo 2.0 token
edb_enable_tde: false # Enable TDE
edb_key_unwrap_cmd: "" # EDB Unwrap commad to decrypt EDB master key. Use can use KMS command to get the real key
edb_key_wrap_cmd: "" # EDB Key wrap command to encrypt EDB master key. User can also use KMS commands to get the key
edb_master_key: "" # EDB master key for TDE encryption
edb_secure_master_key: "" # EDB key or passphrase to encrypt EDB master key
install_pgd: true # Install PGD flag for installing PGD
pgd_version: 5 # Postgres Distributed version
enable_pgdg_repo: true # flag/variable for enabling PGD repo
Expand All @@ -222,6 +227,7 @@ All the variables are available at:
* [roles/setup_pgd/defaults/main.yml](./defaults/main.yml)
* [roles/setup_pgd/vars/PG_RedHat.yml](./vars/PG_RedHat.yml)
* [roles/setup_pgd/vars/EPAS_RedHat.yml](./vars/EPAS_RedHat.yml)
* [roles/setup_pgd/vars/edb-ssl.yml](./vars/edb-ssl.yml)

License
-------
Expand Down
11 changes: 4 additions & 7 deletions roles/setup_pgd/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,13 @@ pg_database: "postgres"
pg_owner: "postgres"
pg_group: "postgres"

# postgres superuser
pg_random_password: true

# Local path to SSL server key and certificate to be sent to the server
# if empty, they are generated
pg_ssl_key_file: ""
pg_ssl_cert_file: ""
pg_ssl_ca_file: ""
pg_ssl_crl_file: ""

# Input variables
input_user: ""
input_password: ""

# PGD variable
pgd_version: 5
install_pgd: false
Expand All @@ -80,6 +73,10 @@ pgd_replication_user_password: ""
pgd_cluster_name: "pgd_cluster"
pgd_local_node_name: "{{ inventory_hostname | regex_replace('[^a-zA-Z0-9_]', '_') }}"
initdb_executed: true
# to enable pgd-cli with connections strings to pgd cluster, set true
setup_pgd_cli: false
# if placed elsewhere, you will need to use the -f or --config-file flag on a pgd command
pgd_cli_config_file: "/etc/edb/pgd-cli/pgd-cli-config.yml"

# HBA variable
pg_allow_ip_addresses: []
Expand Down
Loading

0 comments on commit b2e51e8

Please sign in to comment.