Skip to content

Commit 6cb4ef1

Browse files
committed
chore: add overlay
1 parent 5bd75d9 commit 6cb4ef1

File tree

2 files changed

+83
-7
lines changed

2 files changed

+83
-7
lines changed

ansible/tasks/setup-postgres.yml

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,80 @@
157157
loop_control:
158158
loop_var: 'pg_config_item'
159159

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
167234

168235
# Install extensions before init
169236
- name: Install Postgres extensions

nix/overlays/default.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,14 @@
6060
buildPgrxExtension_0_14_3 = prev.buildPgrxExtension.override {
6161
cargo-pgrx = final.cargo-pgrx.cargo-pgrx_0_14_3;
6262
};
63+
64+
# place the gatekeeper module in the expected libpam location
65+
gatekeeper = self.inputs.gatekeeper.packages.${final.system}.default;
66+
linux-pam = prev.linux-pam.overrideAttrs (old: {
67+
postInstall = (old.postInstall or "") + ''
68+
mkdir -p $out/lib/security
69+
cp ${final.gatekeeper}/lib/security/pam_jwt_pg.so $out/lib/security/
70+
'';
71+
});
6372
};
6473
}

0 commit comments

Comments
 (0)