1
1
# PgBouncer
2
- - name : PgBouncer - download & install dependencies
3
- apt :
4
- pkg :
5
- - build-essential
6
- - libssl-dev
7
- - pkg-config
8
- - libevent-dev
9
- - libsystemd-dev
10
- update_cache : yes
11
- cache_valid_time : 3600
12
-
13
- - name : PgBouncer - download latest release
14
- get_url :
15
- url : " https://www.pgbouncer.org/downloads/files/{{ pgbouncer_release }}/pgbouncer-{{ pgbouncer_release }}.tar.gz"
16
- dest : /tmp/pgbouncer-{{ pgbouncer_release }}.tar.gz
17
- checksum : " {{ pgbouncer_release_checksum }}"
18
- timeout : 60
19
-
20
- - name : PgBouncer - unpack archive
21
- unarchive :
22
- remote_src : yes
23
- src : /tmp/pgbouncer-{{ pgbouncer_release }}.tar.gz
24
- dest : /tmp
25
- become : yes
26
-
27
- - name : PgBouncer - configure
28
- shell :
29
- cmd : " ./configure --prefix=/usr/local --with-systemd"
30
- chdir : /tmp/pgbouncer-{{ pgbouncer_release }}
31
- become : yes
32
-
33
- - name : PgBouncer - build
34
- make :
35
- chdir : /tmp/pgbouncer-{{ pgbouncer_release }}
36
- become : yes
37
-
38
- - name : PgBouncer - install
39
- make :
40
- chdir : /tmp/pgbouncer-{{ pgbouncer_release }}
41
- target : install
42
- become : yes
2
+ # - name: PgBouncer - download & install dependencies
3
+ # apt:
4
+ # pkg:
5
+ # - build-essential
6
+ # - libssl-dev
7
+ # - pkg-config
8
+ # - libevent-dev
9
+ # - libsystemd-dev
10
+ # update_cache: yes
11
+ # cache_valid_time: 3600
12
+
13
+ # - name: PgBouncer - download latest release
14
+ # get_url:
15
+ # url: "https://www.pgbouncer.org/downloads/files/{{ pgbouncer_release }}/pgbouncer-{{ pgbouncer_release }}.tar.gz"
16
+ # dest: /tmp/pgbouncer-{{ pgbouncer_release }}.tar.gz
17
+ # checksum: "{{ pgbouncer_release_checksum }}"
18
+ # timeout: 60
19
+
20
+ # - name: PgBouncer - unpack archive
21
+ # unarchive:
22
+ # remote_src: yes
23
+ # src: /tmp/pgbouncer-{{ pgbouncer_release }}.tar.gz
24
+ # dest: /tmp
25
+ # become: yes
26
+
27
+ # - name: PgBouncer - configure
28
+ # shell:
29
+ # cmd: "./configure --prefix=/usr/local --with-systemd"
30
+ # chdir: /tmp/pgbouncer-{{ pgbouncer_release }}
31
+ # become: yes
32
+
33
+ # - name: PgBouncer - build
34
+ # make:
35
+ # chdir: /tmp/pgbouncer-{{ pgbouncer_release }}
36
+ # become: yes
37
+
38
+ # - name: PgBouncer - install
39
+ # make:
40
+ # chdir: /tmp/pgbouncer-{{ pgbouncer_release }}
41
+ # target: install
42
+ # become: yes
43
43
44
44
- name : Create pgbouncer user
45
45
user :
46
46
name : pgbouncer
47
47
shell : /bin/false
48
48
comment : PgBouncer user
49
49
groups : postgres,ssl-cert
50
+ when : nixpkg_mode
50
51
51
52
- name : PgBouncer - create a directory if it does not exist
52
53
file :
55
56
owner : pgbouncer
56
57
group : pgbouncer
57
58
mode : ' 0700'
59
+ when : nixpkg_mode
58
60
59
61
- name : PgBouncer - create a directory if it does not exist
60
62
file :
65
67
mode : ' 0775'
66
68
with_items :
67
69
- ' /etc/pgbouncer-custom'
70
+ when : nixpkg_mode
68
71
69
72
- name : create placeholder config files
70
73
file :
77
80
- ' generated-optimizations.ini'
78
81
- ' custom-overrides.ini'
79
82
- ' ssl-config.ini'
83
+ when : nixpkg_mode
80
84
81
85
- name : PgBouncer - adjust pgbouncer.ini
82
86
copy :
83
87
src : files/pgbouncer_config/pgbouncer.ini.j2
84
88
dest : /etc/pgbouncer/pgbouncer.ini
85
89
owner : pgbouncer
86
90
mode : ' 0700'
91
+ when : nixpkg_mode
87
92
88
93
- name : PgBouncer - create a directory if it does not exist
89
94
file :
90
95
path : /etc/pgbouncer/userlist.txt
91
96
state : touch
92
97
owner : pgbouncer
93
98
mode : ' 0700'
94
-
99
+ when : nixpkg_mode
100
+
95
101
- name : import /etc/tmpfiles.d/pgbouncer.conf
96
102
template :
97
103
src : files/pgbouncer_config/tmpfiles.d-pgbouncer.conf.j2
98
104
dest : /etc/tmpfiles.d/pgbouncer.conf
99
105
become : yes
106
+ when : nixpkg_mode
100
107
101
108
- name : PgBouncer - By default allow ssl connections.
102
109
become : yes
103
110
copy :
104
111
dest : /etc/pgbouncer-custom/ssl-config.ini
105
112
content : |
106
113
client_tls_sslmode = allow
114
+ when : nixpkg_mode
107
115
108
116
- name : Grant pg_hba and pgbouncer grp perm for adminapi updates
109
117
shell : |
110
118
chmod g+w /etc/postgresql/pg_hba.conf
111
119
chmod g+w /etc/pgbouncer-custom/ssl-config.ini
120
+ when : nixpkg_mode
112
121
113
122
# Add fail2ban filter
114
123
- name : import jail.d/pgbouncer.conf
115
124
template :
116
125
src : files/fail2ban_config/jail-pgbouncer.conf.j2
117
126
dest : /etc/fail2ban/jail.d/pgbouncer.conf
118
127
become : yes
128
+ when : nixpkg_mode
119
129
120
130
- name : import filter.d/pgbouncer.conf
121
131
template :
122
132
src : files/fail2ban_config/filter-pgbouncer.conf.j2
123
133
dest : /etc/fail2ban/filter.d/pgbouncer.conf
124
134
become : yes
135
+ when : nixpkg_mode
125
136
126
137
# Add systemd file for PgBouncer
127
138
- name : PgBouncer - import postgresql.service
128
139
template :
129
140
src : files/pgbouncer_config/pgbouncer.service.j2
130
141
dest : /etc/systemd/system/pgbouncer.service
131
142
become : yes
143
+ when : nixpkg_mode
144
+
145
+ - name : install pgbouncer from supabase nix binary cache
146
+ become : yes
147
+ shell : |
148
+ sudo -u pgbouncer bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install github:supabase/postgres/{{ git_commit_sha }}#pgbouncer"
149
+ when : stage2_nix
132
150
133
151
- name : PgBouncer - reload systemd
134
152
systemd :
135
153
daemon_reload : yes
154
+ when : stage2_nix
0 commit comments