In most cases it is enough to reload our PostgreSQL server:
postgresql_service:
service.running:
- name: postgresql
- enable: True
- reload: True
- watch:
- file: postgresql.conf
- file: pg_hba.conf
- require:
- pkg: postgresql
- failhard: True
But on some particular changes a reload is not enough, a restart is needed.
For example if this line gets added to postgresql.conf, a restart is required:
shared_preload_libraries = 'pglogical'
How can I tell Salt to use restart if the above line gets added to the config file?
Example:
- salt runs and 'pglogical' was not in the config before and not after the salt run. The servers should get reloaded.
- The config changes and 'pglogical' gets added. Now the server should get restarted
- The config changes and 'pglogical' is already in the file. The server should get reloaded.
Copyright Notice:Content Author:「guettli」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/58007104/saltstack-restart-server-not-only-reload-on-particular-change