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