From a39b593c32eb54a0138f5a1d571c0537b90c82e2 Mon Sep 17 00:00:00 2001 From: Thomas Rossetto Date: Fri, 22 Mar 2019 16:29:05 +0100 Subject: [PATCH 1/2] Use copy state instead of salt-call --- postgres/server/init.sls | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/postgres/server/init.sls b/postgres/server/init.sls index d9a54097..028dfc2f 100644 --- a/postgres/server/init.sls +++ b/postgres/server/init.sls @@ -164,14 +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 }} # 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 %} - require: + - file: backup_pg_hba - file: postgresql-config-dir - watch_in: - service: postgresql-running @@ -192,15 +190,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 %} - require: + - file: backup_pg_ident - file: postgresql-config-dir {%- if postgres.prepare_cluster.run %} - cmd: postgresql-cluster-prepared @@ -214,6 +209,18 @@ postgresql-pg_ident: - service: postgresql-running {%- endif %} +backup_pg_ident: + 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 }}: From bfc08defe7fb591533fa88e19dfb2fddfc5319db Mon Sep 17 00:00:00 2001 From: Thomas Rossetto Date: Wed, 3 Apr 2019 17:30:15 +0200 Subject: [PATCH 2/2] Use prereq insted of require --- postgres/server/init.sls | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/postgres/server/init.sls b/postgres/server/init.sls index 028dfc2f..56ea6ed1 100644 --- a/postgres/server/init.sls +++ b/postgres/server/init.sls @@ -168,8 +168,9 @@ postgresql-pg_hba: {%- else %} - replace: False {%- endif %} - - require: + - prereq: - file: backup_pg_hba + - require: - file: postgresql-config-dir - watch_in: - service: postgresql-running @@ -194,8 +195,9 @@ postgresql-pg_ident: {%- else %} - replace: False {%- endif %} - - require: + - prereq: - file: backup_pg_ident + - require: - file: postgresql-config-dir {%- if postgres.prepare_cluster.run %} - cmd: postgresql-cluster-prepared