mirror of
https://github.com/saltstack-formulas/postgres-formula.git
synced 2025-04-16 17:50:27 +00:00
Merge pull request #250 from myii/PR_236
Fix #236: Restart postgres service after ACL changes in pg_hba.conf
This commit is contained in:
commit
d53648249c
2 changed files with 24 additions and 16 deletions
|
@ -84,7 +84,7 @@ postgresql-cluster-prepared:
|
||||||
- pkg: postgresql-server
|
- pkg: postgresql-server
|
||||||
- file: postgresql-cluster-prepared
|
- file: postgresql-cluster-prepared
|
||||||
- watch_in:
|
- watch_in:
|
||||||
- module: postgresql-service-restart
|
- service: postgresql-running
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
postgresql-config-dir:
|
postgresql-config-dir:
|
||||||
|
@ -143,17 +143,10 @@ postgresql-conf:
|
||||||
- file: postgresql-conf-comment-port
|
- file: postgresql-conf-comment-port
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
- watch_in:
|
- watch_in:
|
||||||
- module: postgresql-service-restart
|
- service: postgresql-running
|
||||||
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
# Restart the service where reloading is not sufficient
|
|
||||||
# Currently when the cluster is created or changes made to `postgresql.conf`
|
|
||||||
postgresql-service-restart:
|
|
||||||
module.wait:
|
|
||||||
- name: service.restart
|
|
||||||
- m_name: {{ postgres.service }}
|
|
||||||
|
|
||||||
{%- 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:
|
postgresql-pg_hba:
|
||||||
|
@ -180,6 +173,8 @@ postgresql-pg_hba:
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
- require:
|
- require:
|
||||||
- file: postgresql-config-dir
|
- file: postgresql-config-dir
|
||||||
|
- watch_in:
|
||||||
|
- service: postgresql-running
|
||||||
|
|
||||||
{%- set pg_ident_path = salt['file.join'](postgres.conf_dir, 'pg_ident.conf') %}
|
{%- set pg_ident_path = salt['file.join'](postgres.conf_dir, 'pg_ident.conf') %}
|
||||||
|
|
||||||
|
@ -212,6 +207,12 @@ postgresql-pg_ident:
|
||||||
{%- else %}
|
{%- else %}
|
||||||
- file: postgresql-cluster-prepared
|
- file: postgresql-cluster-prepared
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
- watch_in:
|
||||||
|
{%- if grains.os not in ('MacOS',) %}
|
||||||
|
- module: postgresql-service-reload
|
||||||
|
{%- else %}
|
||||||
|
- service: postgresql-running
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
{%- for name, tblspace in postgres.tablespaces|dictsort() %}
|
{%- for name, tblspace in postgres.tablespaces|dictsort() %}
|
||||||
|
|
||||||
|
@ -256,15 +257,22 @@ postgresql-tablespace-dir-{{ name }}-fcontext:
|
||||||
{%- if not postgres.bake_image %}
|
{%- if not postgres.bake_image %}
|
||||||
|
|
||||||
# Start PostgreSQL server using OS init
|
# Start PostgreSQL server using OS init
|
||||||
|
# Note: This is also the target for numerous `watch_in` requisites above, used
|
||||||
|
# for the necessary service restart after changing the relevant configuration files
|
||||||
postgresql-running:
|
postgresql-running:
|
||||||
service.running:
|
service.running:
|
||||||
- name: {{ postgres.service }}
|
- name: {{ postgres.service }}
|
||||||
- enable: True
|
- enable: True
|
||||||
{% if grains.os not in ('MacOS',) %}
|
|
||||||
- reload: True
|
# Reload the service for changes made to `pg_ident.conf`, except for `MacOS`
|
||||||
{% endif %}
|
# which is handled by `postgresql-running` above.
|
||||||
- watch:
|
{%- if grains.os not in ('MacOS',) %}
|
||||||
- file: postgresql-pg_hba
|
postgresql-service-reload:
|
||||||
- file: postgresql-pg_ident
|
module.wait:
|
||||||
|
- name: service.reload
|
||||||
|
- m_name: {{ postgres.service }}
|
||||||
|
- require:
|
||||||
|
- service: postgresql-running
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
|
@ -47,5 +47,5 @@
|
||||||
# MAPNAME SYSTEM-USERNAME PG-USERNAME
|
# MAPNAME SYSTEM-USERNAME PG-USERNAME
|
||||||
|
|
||||||
{%- for mapping in mappings %}
|
{%- for mapping in mappings %}
|
||||||
{{ '{0:<15} {1:<22} {2}'.format(mapping) -}}
|
{{ '{0:<15} {1:<22} {2}'.format(*mapping) -}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Add table
Reference in a new issue