diff --git a/postgres/defaults.yaml b/postgres/defaults.yaml index 2f470fb9..60036320 100644 --- a/postgres/defaults.yaml +++ b/postgres/defaults.yaml @@ -69,6 +69,8 @@ postgres: bake_image: False + manage_force_reload_modules: False + fromrepo: '' users: {} diff --git a/postgres/macros.jinja b/postgres/macros.jinja index 4eedddbb..ea50decd 100644 --- a/postgres/macros.jinja +++ b/postgres/macros.jinja @@ -23,7 +23,7 @@ {{ state }}-{{ name }}: {{ state }}.{{ ensure|default('present') }}: {{- format_kwargs(kwarg) }} - - onchanges: + - watch: - test: postgres-reload-modules {%- endmacro %} diff --git a/postgres/manage.sls b/postgres/manage.sls index 19311555..a2c87e12 100644 --- a/postgres/manage.sls +++ b/postgres/manage.sls @@ -1,7 +1,9 @@ {%- from tpldir + "/map.jinja" import postgres with context -%} {%- from tpldir + "/macros.jinja" import format_state with context -%} -{%- if salt['postgres.user_create']|default(none) is not callable %} +{%- set needs_client_binaries = salt['postgres.user_create']|default(none) is not callable -%} + +{%- if needs_client_binaries %} # Salt states for managing PostgreSQL is not available, # need to provision client binaries first @@ -18,7 +20,11 @@ include: # Ensure that Salt is able to use postgres modules postgres-reload-modules: +{%- if needs_client_binaries or postgres.manage_force_reload_modules %} test.succeed_with_changes: +{%- else %} + test.succeed_without_changes: +{%- endif %} - reload_modules: True # User states diff --git a/postgres/server/init.sls b/postgres/server/init.sls index a757056b..1dc09add 100644 --- a/postgres/server/init.sls +++ b/postgres/server/init.sls @@ -143,13 +143,6 @@ postgresql-conf: {%- 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') %} postgresql-pg_hba: @@ -176,6 +169,15 @@ postgresql-pg_hba: {%- endif %} - require: - file: postgresql-config-dir + - watch_in: + - module: postgresql-service-restart + +# 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_ident_path = salt['file.join'](postgres.conf_dir, 'pg_ident.conf') %}