|
167 | 167 | loop_control: |
168 | 168 | loop_var: 'pg_config_item' |
169 | 169 |
|
170 | | - - name: Move custom read-replica.conf file to /etc/postgresql-custom/read-replica.conf |
171 | | - ansible.builtin.template: |
172 | | - dest: '/etc/postgresql-custom/read-replica.conf' |
173 | | - mode: '0664' |
174 | | - owner: 'postgres' |
175 | | - group: 'postgres' |
176 | | - src: 'files/postgresql_config/custom_read_replica.conf.j2' |
| 170 | +- name: Allow adminapi to write custom config |
| 171 | + file: |
| 172 | + path: '{{ item }}' |
| 173 | + recurse: yes |
| 174 | + state: directory |
| 175 | + owner: postgres |
| 176 | + group: postgres |
| 177 | + mode: 0775 |
| 178 | + with_items: |
| 179 | + - '/etc/postgresql' |
| 180 | + - '/etc/postgresql-custom' |
| 181 | + when: debpkg_mode or nixpkg_mode |
| 182 | + |
| 183 | +- name: create placeholder config files |
| 184 | + file: |
| 185 | + path: '/etc/postgresql-custom/{{ item }}' |
| 186 | + state: touch |
| 187 | + owner: postgres |
| 188 | + group: postgres |
| 189 | + mode: 0664 |
| 190 | + with_items: |
| 191 | + - '01-generated-optimizations.conf' |
| 192 | + - '02-custom-overrides.conf' |
| 193 | + when: debpkg_mode or nixpkg_mode |
| 194 | + |
| 195 | +# Move Postgres configuration files into /etc/postgresql |
| 196 | +# Add postgresql.conf |
| 197 | +- name: import postgresql.conf |
| 198 | + template: |
| 199 | + src: files/postgresql_config/postgresql.conf.j2 |
| 200 | + dest: /etc/postgresql/postgresql.conf |
| 201 | + group: postgres |
| 202 | + when: debpkg_mode or nixpkg_mode |
| 203 | + |
| 204 | +- name: Check if psql_version is psql_15 |
| 205 | + set_fact: |
| 206 | + is_psql_15: "{{ psql_version in ['psql_15'] }}" |
| 207 | + |
| 208 | +- name: create placeholder pam config |
| 209 | + file: |
| 210 | + path: '/etc/pam.d/{{ item }}' |
| 211 | + state: touch |
| 212 | + owner: postgres |
| 213 | + group: postgres |
| 214 | + mode: 0664 |
| 215 | + with_items: |
| 216 | + - 'postgresql' |
| 217 | + when: (debpkg_mode or nixpkg_mode) and not is_psql_15 |
| 218 | + |
| 219 | +# Add pg_hba.conf |
| 220 | +- name: import pg_hba.conf |
| 221 | + template: |
| 222 | + src: files/postgresql_config/pg_hba.conf.j2 |
| 223 | + dest: /etc/postgresql/pg_hba.conf |
| 224 | + group: postgres |
| 225 | + when: debpkg_mode or nixpkg_mode |
| 226 | + |
| 227 | +# Add pg_ident.conf |
| 228 | +- name: import pg_ident.conf |
| 229 | + template: |
| 230 | + src: files/postgresql_config/pg_ident.conf.j2 |
| 231 | + dest: /etc/postgresql/pg_ident.conf |
| 232 | + group: postgres |
| 233 | + when: debpkg_mode or nixpkg_mode |
| 234 | + |
| 235 | +# Add custom config for read replicas set up |
| 236 | +- name: Move custom read-replica.conf file to /etc/postgresql-custom/04-read-replica.conf |
| 237 | + template: |
| 238 | + src: "files/postgresql_config/custom_read_replica.conf.j2" |
| 239 | + dest: /etc/postgresql-custom/04-read-replica.conf |
| 240 | + mode: 0664 |
| 241 | + owner: postgres |
| 242 | + group: postgres |
| 243 | + when: debpkg_mode or nixpkg_mode |
177 | 244 |
|
178 | 245 | # Install extensions before init |
179 | 246 | - name: Install Postgres extensions |
|
0 commit comments