@@ -86,23 +86,50 @@ postgresql-config-dir:
86
86
- require:
87
87
- cmd: postgresql- cluster- prepared
88
88
89
- {%- if postgres.postgresconf % }
89
+ {%- set db_port = salt[' config.option' ](' postgres.port' ) % }
90
+ {%- if db_port % }
91
+
92
+ postgresql- conf- comment- port:
93
+ file .comment:
94
+ - name: {{ postgres.conf_dir }}/ postgresql.conf
95
+ - regex: ^ port\s*=.+
96
+ - require:
97
+ - file : postgresql- config- dir
98
+
99
+ {%- endif % }
100
+
101
+ {%- if postgres.postgresconf or db_port % }
90
102
91
103
postgresql- conf:
92
104
file .blockreplace:
93
105
- name: {{ postgres.conf_dir }}/ postgresql.conf
94
106
- marker_start: " # Managed by SaltStack: listen_addresses: please do not edit"
95
107
- marker_end: " # Managed by SaltStack: end of salt managed zone --"
96
108
- content: |
109
+ {%- if postgres.postgresconf % }
97
110
{{ postgres.postgresconf| indent(8 ) }}
111
+ {%- endif % }
112
+ {%- if db_port % }
113
+ port = {{ db_port }}
114
+ {%- endif % }
98
115
- show_changes: True
99
116
- append_if_not_found: True
100
117
{# - Detect empty values (none, '') in the config_backup #}
101
118
- backup: {{ postgres.config_backup| default(false, true) }}
102
119
- require:
103
120
- file : postgresql- config- dir
121
+ {%- if db_port % }
122
+ - file : postgresql- conf- comment- port
123
+ {%- endif % }
104
124
- watch_in:
105
- - service: postgresql- running
125
+ - module: postgresql- service- restart
126
+
127
+ # Restart the service where reloading is not sufficient
128
+ # Currently only when changes are made to `postgresql.conf`
129
+ postgresql- service- restart:
130
+ module.wait:
131
+ - name: service.restart
132
+ - m_name: {{ postgres.service }}
106
133
107
134
{%- endif % }
108
135
0 commit comments