Skip to content

Commit

Permalink
add setup for pgd cli
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahms committed Sep 26, 2023
1 parent 7c444f9 commit 7879ebc
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
7 changes: 3 additions & 4 deletions roles/setup_pgd/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ 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 +76,9 @@ pgd_replication_user_password: ""
pgd_cluster_name: "pgd_cluster"
pgd_local_node_name: "{{ inventory_hostname | regex_replace('[^a-zA-Z0-9_]', '_') }}"
initdb_executed: true
setup_pgd_cli: true
# 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
24 changes: 24 additions & 0 deletions roles/setup_pgd/tasks/pgd_setup_cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
- name: Create directory for {{ pgd_cli_config_file }}
ansible.builtin.file:
path: "{{ pgd_cli_config_file | dirname }}"
state: directory
owner: "{{ pg_owner }}"
group: "{{ pg_group }}"
mode: "0700"
become: true

- name: Create pgd-cli config file
ansible.builtin.template:
src: ./templates/pgd-cli-config.yml.template
dest: "{{ pgd_cli_config_file }}"
owner: "{{ pg_owner }}"
group: "{{ pg_group }}"
mode: "0700"
become: true

- name: Install edb-pgd-cli
ansible.builtin.package:
name: "edb-pgd{{ pgd_version }}-cli"
state: present
become: true
7 changes: 7 additions & 0 deletions roles/setup_pgd/tasks/setup_pgd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@
- name: Configure SSL if not exists
ansible.builtin.import_tasks: pg_ssl_config.yml

- name: Setup pgd-cli if setup_pgd_cli
ansible.builtin.include_tasks: pgd_setup_cli.yml
when:
- not validate_only|bool
- not remove_only|bool
- setup_pgd_cli|bool

- name: Include tasks to setup commit scopes
ansible.builtin.include_tasks: pgd_commit_scopes.yml
when:
Expand Down
2 changes: 0 additions & 2 deletions roles/setup_pgd/tasks/validate_setup_pgd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,9 @@
ansible.builtin.assert:
that:
- _pgd_local_node_created|int == 1

fail_msg: "Local PGD node wasn't created successfully"
success_msg: "Local PGD node created successfully"


- name: Verify PGD local node is created or not
ansible.builtin.assert:
that:
Expand Down
6 changes: 6 additions & 0 deletions roles/setup_pgd/templates/pgd-cli-config.yml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cluster:
name: {{ pgd_cluster_name }}
endpoints:
{% for item in pgd_cluster_nodes %}
- "host={{ item.inventory_hostname if use_hostname else item.private_ip }} port={{ pg_port }} user={{ pgd_replication_user }} dbname={{ pgd_cluster_database }}"
{% endfor %}

0 comments on commit 7879ebc

Please sign in to comment.