@@ -88,17 +88,11 @@ postgresql-pg_hba:
8888 - user: {{ postgres.user }}
8989 - group: {{ postgres.group }}
9090 - mode: 600
91+ - defaults:
92+ acls: {{ postgres.acls }}
9193 - require:
9294 - file : postgresql- config- dir
9395
94- postgresql- running:
95- service.running:
96- - name: {{ postgres.service }}
97- - enable: True
98- - reload : True
99- - watch:
100- - file : postgresql- pg_hba
101-
10296{%- for name, tblspace in postgres.tablespaces| dictsort() % }
10397
10498postgresql- tablespace- dir - {{ name }}:
@@ -114,28 +108,42 @@ postgresql-tablespace-dir-{{ name }}:
114108
115109{%- endfor % }
116110
117- # An attempt to launch PostgreSQL with `pg_ctl` if service failed to start
118- # with init system or Salt unable to load the `service` state module
111+ {%- if grains[' init' ] != ' unknown' % }
112+
113+ postgresql- running:
114+ service.running:
115+ - name: {{ postgres.service }}
116+ - enable: True
117+ - reload : True
118+ - watch:
119+ - file : postgresql- pg_hba
120+
121+ {%- else % }
122+
123+ # An attempt to launch PostgreSQL with `pg_ctl` if Salt was unable to
124+ # detect local init system (`service` module would fail in this case)
125+
119126postgresql- start:
120127 cmd.run:
121128 - name: pg_ctl - D {{ postgres.conf_dir }} - l logfile start
122129 - runas: {{ postgres.user }}
123130 - unless:
124131 - ps - p $ (head - n 1 {{ postgres.conf_dir }}/ postmaster.pid) 2 > / dev/ null
125- - onfail:
126- - service: postgresql- running
127132
128133# Try to enable PostgreSQL in "manual" way for systemd and RedHat-based distros.
129134# The packages for other OS (i.e. `*.deb`) should do it automatically by default
135+
130136postgresql- enable:
131137 cmd.run:
132- {%- if salt[' file.file_exists' ](' /bin/systemctl' ) % }
138+ {%- if salt[' file.file_exists' ](' /bin/systemctl' ) % }
133139 - name: systemctl enable {{ postgres.service }}
134- {%- elif salt[' cmd.which' ](' chkconfig' ) % }
140+ {%- elif salt[' cmd.which' ](' chkconfig' ) % }
135141 - name: chkconfig {{ postgres.service }} on
136- {%- else % }
142+ {%- else % }
137143 # Nothing to do
138144 - name: ' true'
139- {%- endif % }
145+ {%- endif % }
140146 - onchanges:
141147 - cmd: postgresql- start
148+
149+ {%- endif % }
0 commit comments