Skip to content

Commit

Permalink
Add Pre-Check Task for the Presence of a pgBackRest Node in the Inven…
Browse files Browse the repository at this point in the history
…tory

This commit introduces a pre-check task in our Ansible playbook that checks if a host is present in the 'pgbackrest' inventory group when the 'pgbackrest_repo_host' variable is defined.

This helps to ensure that the playbook run will not fail due to misconfigured inventory file settings.
  • Loading branch information
vitabaks committed Jul 21, 2023
1 parent f0056bc commit 480dbcc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions roles/pre-checks/tasks/pgbackrest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
- archive_command_item is undefined or archive_command_item.value != pgbackrest_archive_command

# Checking parameters for working with a dedicated pgbackrest server
- name: pgBackRest | Ensure pgbackrest host is in inventory
run_once: true # noqa run-once
ansible.builtin.fail:
msg:
- "The 'pgbackrest_repo_host' variable is set but the 'pgbackrest' group in your inventory is empty."
- "Please add the necessary host to the 'pgbackrest' group in your inventory."
when:
- pgbackrest_repo_host | length > 0
- groups['pgbackrest'] is undefined or groups['pgbackrest'] | length == 0

- name: "pgBackRest | Ensure 'repo1-host' and 'repo1-host-user' are set correctly"
ansible.builtin.set_fact:
pgbackrest_conf:
Expand Down

0 comments on commit 480dbcc

Please sign in to comment.