-
-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue: #143 also added an example of pgbackrest_conf parameters for configuring local backup.
- Loading branch information
Showing
4 changed files
with
76 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
|
||
- name: Get repo1-path value | ||
set_fact: | ||
repo1_path: "{{ pgbackrest_conf['global'] | selectattr('option', 'equalto', 'repo1-path') | map(attribute='value') | list | first }}" | ||
tags: pgbackrest, pgbackrest_stanza_create | ||
|
||
# Create a stanza locally (if "pgbackrest_repo_host" is not set) | ||
- block: | ||
- name: "Make sure the {{ repo1_path }} directory exists" | ||
file: | ||
path: "{{ repo1_path }}" | ||
state: directory | ||
owner: postgres | ||
group: postgres | ||
mode: 0755 | ||
when: repo1_path | length > 0 | ||
|
||
- name: Create stanza "{{ pgbackrest_stanza }}" | ||
become: true | ||
become_user: postgres | ||
command: "pgbackrest --stanza={{ pgbackrest_stanza }} --no-online stanza-create" | ||
register: stanza_create_result | ||
changed_when: | ||
- stanza_create_result.rc == 0 | ||
- stanza_create_result.stdout is not search("already exists") | ||
when: | ||
- pgbackrest_repo_host | length < 1 | ||
- "'postgres_cluster' in group_names" | ||
tags: pgbackrest, pgbackrest_stanza_create | ||
|
||
# Create a stanza on the dedicated repository host | ||
- block: | ||
- name: "Make sure the {{ repo1_path }} directory exists" | ||
file: | ||
path: "{{ repo1_path }}" | ||
state: directory | ||
owner: "{{ pgbackrest_repo_user }}" | ||
group: "{{ pgbackrest_repo_user }}" | ||
mode: 0755 | ||
when: repo1_path | length > 0 | ||
|
||
- name: Create stanza "{{ pgbackrest_stanza }}" | ||
become: true | ||
become_user: "{{ pgbackrest_repo_user }}" | ||
delegate_to: "{{ groups['pgbackret'][0] }}" | ||
run_once: true | ||
command: "pgbackrest --stanza={{ pgbackrest_stanza }} stanza-create" | ||
register: stanza_create_result | ||
changed_when: | ||
- stanza_create_result.rc == 0 | ||
- stanza_create_result.stdout is not search("already exists") | ||
when: | ||
- pgbackrest_repo_host | length > 0 | ||
- "'pgbackrest' in group_names" | ||
tags: pgbackrest, pgbackrest_stanza_create | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
392dc34
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! That was a lot of code. I thought it was a small task.
Thanks!