mirror of
https://github.com/saltstack-formulas/postgres-formula.git
synced 2025-04-16 09:40:26 +00:00
Merge pull request #149 from vutny/fix-148
Resolve #148: workaround `prereq` causing infinite recursion
This commit is contained in:
commit
9a455e4714
1 changed files with 10 additions and 13 deletions
|
@ -82,7 +82,8 @@ postgresql-conf:
|
||||||
{{ postgres.postgresconf|indent(8) }}
|
{{ postgres.postgresconf|indent(8) }}
|
||||||
- show_changes: True
|
- show_changes: True
|
||||||
- append_if_not_found: True
|
- append_if_not_found: True
|
||||||
- backup: {{ postgres.config_backup }}
|
{#- Detect empty values (none, '') in the config_backup #}
|
||||||
|
- backup: {{ postgres.config_backup|default(false, true) }}
|
||||||
- require:
|
- require:
|
||||||
- file: postgresql-config-dir
|
- file: postgresql-config-dir
|
||||||
- watch_in:
|
- watch_in:
|
||||||
|
@ -92,18 +93,6 @@ postgresql-conf:
|
||||||
|
|
||||||
{%- set pg_hba_path = salt['file.join'](postgres.conf_dir, 'pg_hba.conf') %}
|
{%- set pg_hba_path = salt['file.join'](postgres.conf_dir, 'pg_hba.conf') %}
|
||||||
|
|
||||||
postgresql-pg_hba-backup:
|
|
||||||
file.copy:
|
|
||||||
- name: {{ pg_hba_path ~ postgres.config_backup }}
|
|
||||||
- source: {{ pg_hba_path }}
|
|
||||||
- force: True
|
|
||||||
- user: {{ postgres.user }}
|
|
||||||
- group: {{ postgres.group }}
|
|
||||||
- mode: 600
|
|
||||||
- onlyif: test -f {{ pg_hba_path }}
|
|
||||||
- prereq:
|
|
||||||
- file: postgresql-pg_hba
|
|
||||||
|
|
||||||
postgresql-pg_hba:
|
postgresql-pg_hba:
|
||||||
file.managed:
|
file.managed:
|
||||||
- name: {{ pg_hba_path }}
|
- name: {{ pg_hba_path }}
|
||||||
|
@ -115,6 +104,14 @@ postgresql-pg_hba:
|
||||||
- template: jinja
|
- template: jinja
|
||||||
- defaults:
|
- defaults:
|
||||||
acls: {{ postgres.acls }}
|
acls: {{ postgres.acls }}
|
||||||
|
{%- if postgres.config_backup %}
|
||||||
|
# Create the empty file before managing to overcome the limitation of check_cmd
|
||||||
|
- onlyif: test -f {{ pg_hba_path }} || touch {{ pg_hba_path }}
|
||||||
|
# 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 %}
|
{%- else %}
|
||||||
- replace: False
|
- replace: False
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
Loading…
Add table
Reference in a new issue