Skip to content

Commit 3ff262d

Browse files
committed
chore: add overlay
1 parent 1c5981f commit 3ff262d

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
@@ -167,13 +167,80 @@
167167
loop_control:
168168
loop_var: 'pg_config_item'
169169

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
177244

178245
# Install extensions before init
179246
- name: Install Postgres extensions

nix/overlays/default.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,14 @@
2727
inherit (final) stdenv;
2828
inherit (final) rust-bin;
2929
};
30+
31+
# place the gatekeeper module in the expected libpam location
32+
gatekeeper = self.inputs.gatekeeper.packages.${final.system}.default;
33+
linux-pam = prev.linux-pam.overrideAttrs (old: {
34+
postInstall = (old.postInstall or "") + ''
35+
mkdir -p $out/lib/security
36+
cp ${final.gatekeeper}/lib/security/pam_jwt_pg.so $out/lib/security/
37+
'';
38+
});
3039
};
3140
}

0 commit comments

Comments
 (0)