Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions postgres/server/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,12 @@ postgresql-pg_hba:
# Create the empty file before managing to overcome the limitation of check_cmd
- onlyif: test -f {{ pg_hba_path }} || touch {{ pg_hba_path }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer needed since we are going to remove check_cmd parameter. Same applies for the pg_ident.

# Make a local backup before the file modification
- check_cmd: >-
salt-call --local file.copy
{{ pg_hba_path }} {{ pg_hba_path ~ postgres.config_backup }} remove_existing=true
{%- endif %}
{%- else %}
- replace: False
{%- endif %}
- prereq:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we must wrap this with {%- if postgres.config_backup %} ... {%- endif %} statements, instead of onlyif and check_cmd, because no need to trigger backup if it was disabled.

- file: backup_pg_hba
- require:
- file: postgresql-config-dir
- watch_in:
Expand All @@ -192,14 +191,12 @@ postgresql-pg_ident:
{%- if postgres.config_backup %}
# Create the empty file before managing to overcome the limitation of check_cmd
- onlyif: test -f {{ pg_ident_path }} || touch {{ pg_ident_path }}
# Make a local backup before the file modification
- check_cmd: >-
salt-call --local file.copy
{{ pg_ident_path }} {{ pg_ident_path ~ postgres.config_backup }} remove_existing=true
{%- endif %}
{%- else %}
- replace: False
{%- endif %}
- prereq:
- file: backup_pg_ident
- require:
- file: postgresql-config-dir
{%- if postgres.prepare_cluster.run %}
Expand All @@ -214,6 +211,18 @@ postgresql-pg_ident:
- service: postgresql-running
{%- endif %}

backup_pg_ident:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like above, we need the if statement here. These states also should be applied only when postgres.config_backup variable would contain any meaningful value.

file.copy:
- name: {{ pg_ident_path ~ postgres.config_backup }}
- source: {{ pg_ident_path }}
- force: true

backup_pg_hba:
file.copy:
- name: {{ pg_hba_path ~ postgres.config_backup }}
- source: {{ pg_hba_path }}
- force: true

{%- for name, tblspace in postgres.tablespaces|dictsort() %}

postgresql-tablespace-dir-{{ name }}:
Expand Down