File tree Expand file tree Collapse file tree 6 files changed +70
-9
lines changed
Expand file tree Collapse file tree 6 files changed +70
-9
lines changed Original file line number Diff line number Diff line change 4343;;; Administrative settings
4444;;;
4545
46- logfile = /var/log/postgresql/ pgbouncer.log
47- pidfile = /var/run/postgresql /pgbouncer.pid
46+ logfile = /var/log/pgbouncer.log
47+ pidfile = /var/run/pgbouncer /pgbouncer.pid
4848
4949;;;
5050;;; Where to wait for clients
Original file line number Diff line number Diff line change 1+ # Example systemd service unit for PgBouncer
2+ #
3+ # - Adjust the paths in ExecStart for your installation.
4+ #
5+ # - The User setting requires careful consideration. PgBouncer needs
6+ # to be able to place a Unix-domain socket file where PostgreSQL
7+ # clients will look for it. In the olden days, this was in /tmp,
8+ # but systems using systemd now prefer something like
9+ # /var/run/postgresql/. But then some systems also lock down that
10+ # directory so that only the postgres user can write to it. That
11+ # means you need to either
12+ #
13+ # - run PgBouncer as the postgres user, or
14+ #
15+ # - create a separate user and add it to the postgres group and
16+ # make /var/run/postgresql/ group-writable, or
17+ #
18+ # - use systemd to create the sockets; see pgbouncer.socket nearby.
19+ #
20+ # For packagers and deployment systems, this requires some
21+ # coordination between the PgBouncer and the PostgreSQL
22+ # packages/components.
23+ #
24+ [Unit]
25+ Description=connection pooler for PostgreSQL
26+ Documentation=man:pgbouncer(1)
27+ Documentation=https://www.pgbouncer.org/
28+ After=network.target
29+ #Requires=pgbouncer.socket
30+
31+ [Service]
32+ Type=notify
33+ User=postgres
34+ ExecStart=/usr/local/bin/pgbouncer /etc/pgbouncer/pgbouncer.ini
35+ ExecReload=/bin/kill -HUP $MAINPID
36+ KillSignal=SIGINT
37+ #LimitNOFILE=1024
38+
39+ [Install]
40+ WantedBy=multi-user.target
File renamed without changes.
Original file line number Diff line number Diff line change 99
1010 vars :
1111 sql_files :
12- - { source: "pgbouncer_auth_schema.sql", dest: "00-schema.sql" }
12+ - { source: "pgbouncer_config/ pgbouncer_auth_schema.sql", dest: "00-schema.sql" }
1313 - { source: "stat_extension.sql", dest: "01-extension.sql" }
1414
1515 environment :
6868 state : absent
6969 loop : " {{ sql_files }}"
7070
71- - name : Adjust pgbouncer.ini
72- copy :
73- src : files/pgbouncer.ini
74- dest : /etc/pgbouncer/pgbouncer.ini
75-
7671 - name : UFW - Allow SSH connections
7772 ufw :
7873 rule : allow
Original file line number Diff line number Diff line change 88 update_cache : yes
99 cache_valid_time : 3600
1010
11+ - name : Create directory for pgbouncer.pid
12+ file :
13+ path : /var/run/pgbouncer
14+ state : directory
15+ owner : postgres
16+ group : postgres
17+
1118- name : PgBouncer - download latest release
1219 get_url :
1320 url : " https://www.pgbouncer.org/downloads/files/{{ pgbouncer_release }}/pgbouncer-{{ pgbouncer_release }}.tar.gz"
3946 become : yes
4047
4148# Create /etc/postgresql directory and make sure postgres group owns it
42- - name : Create a directory if it does not exist
49+ - name : PgBouncer - create a directory if it does not exist
4350 file :
4451 path : /etc/pgbouncer
4552 state : directory
4653 group : postgres
54+
55+ - name : PgBouncer - adjust pgbouncer.ini
56+ copy :
57+ src : files/pgbouncer_config/pgbouncer.ini.j2
58+ dest : /etc/pgbouncer/pgbouncer.ini
59+
60+ # Add systemd file for PgBouncer
61+ - name : PgBouncer - import postgresql.service
62+ template :
63+ src : files/pgbouncer_config/pgbouncer.service.j2
64+ dest : /etc/systemd/system/pgbouncer.service
65+ become : yes
66+
67+ - name : PgBouncer - reload systemd
68+ systemd :
69+ daemon_reload : yes
Original file line number Diff line number Diff line change @@ -6,3 +6,6 @@ rm -rf /var/log/*
66
77# https://github.com/fail2ban/fail2ban/issues/1593
88touch /var/log/auth.log
9+
10+ touch /var/log/pgbouncer.log
11+ chown postgres:postgres /var/log/pgbouncer.log
You can’t perform that action at this time.
0 commit comments