@@ -84,7 +84,7 @@ postgresql-cluster-prepared:
8484 - pkg: postgresql- server
8585 - file : postgresql- cluster- prepared
8686 - watch_in:
87- - module : postgresql- service - restart
87+ - service : postgresql- running
8888{%- endif % }
8989
9090postgresql- config- dir :
@@ -143,17 +143,10 @@ postgresql-conf:
143143 - file : postgresql- conf- comment- port
144144 {%- endif % }
145145 - watch_in:
146- - module : postgresql- service - restart
146+ - service : postgresql- running
147147
148148{%- endif % }
149149
150- # Restart the service where reloading is not sufficient
151- # Currently when the cluster is created or changes made to `postgresql.conf`
152- postgresql- service- restart:
153- module.wait:
154- - name: service.restart
155- - m_name: {{ postgres.service }}
156-
157150{%- set pg_hba_path = salt[' file.join' ](postgres.conf_dir, ' pg_hba.conf' ) % }
158151
159152postgresql- pg_hba:
@@ -180,6 +173,8 @@ postgresql-pg_hba:
180173{%- endif % }
181174 - require:
182175 - file : postgresql- config- dir
176+ - watch_in:
177+ - service: postgresql- running
183178
184179{%- set pg_ident_path = salt[' file.join' ](postgres.conf_dir, ' pg_ident.conf' ) % }
185180
@@ -212,6 +207,12 @@ postgresql-pg_ident:
212207 {%- else % }
213208 - file : postgresql- cluster- prepared
214209 {%- endif % }
210+ - watch_in:
211+ {%- if grains.os not in (' MacOS' ,) % }
212+ - module: postgresql- service- reload
213+ {%- else % }
214+ - service: postgresql- running
215+ {%- endif % }
215216
216217{%- for name, tblspace in postgres.tablespaces| dictsort() % }
217218
@@ -256,15 +257,22 @@ postgresql-tablespace-dir-{{ name }}-fcontext:
256257{%- if not postgres.bake_image % }
257258
258259# Start PostgreSQL server using OS init
260+ # Note: This is also the target for numerous `watch_in` requisites above, used
261+ # for the necessary service restart after changing the relevant configuration files
259262postgresql- running:
260263 service.running:
261264 - name: {{ postgres.service }}
262265 - enable: True
263- {% if grains.os not in (' MacOS' ,) % }
264- - reload : True
265- {% endif % }
266- - watch:
267- - file : postgresql- pg_hba
268- - file : postgresql- pg_ident
266+
267+ # Reload the service for changes made to `pg_ident.conf`, except for `MacOS`
268+ # which is handled by `postgresql-running` above.
269+ {%- if grains.os not in (' MacOS' ,) % }
270+ postgresql- service- reload :
271+ module.wait:
272+ - name: service.reload
273+ - m_name: {{ postgres.service }}
274+ - require:
275+ - service: postgresql- running
276+ {%- endif % }
269277
270278{%- endif % }
0 commit comments