Skip to content

Commit

Permalink
PgBouncer: Use RuntimeDirectory (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks authored Nov 18, 2023
1 parent ccfb79a commit c6c2f35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions roles/pgbouncer/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
mode: "0750"
tags: pgbouncer_conf, pgbouncer

- name: Ensure log directory "{{ pgbouncer_log_dir }}" exist
ansible.builtin.file:
path: "{{ pgbouncer_log_dir }}"
state: directory
owner: postgres
group: postgres
mode: "0750"
tags: pgbouncer_conf, pgbouncer

- name: Check if pgbouncer systemd service file exists
ansible.builtin.stat:
path: /etc/systemd/system/pgbouncer.service
Expand Down
6 changes: 3 additions & 3 deletions roles/pgbouncer/templates/pgbouncer.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Type=forking
User=postgres
Group=postgres

PermissionsStartOnly=true
ExecStartPre=-/bin/mkdir -p /run/pgbouncer /var/run/pgbouncer{{ '-%d' % (idx + 1) if idx > 0 else '' }} {{ pgbouncer_log_dir }}
ExecStartPre=/bin/chown -R postgres:postgres /run/pgbouncer /var/run/pgbouncer{{ '-%d' % (idx + 1) if idx > 0 else '' }} {{ pgbouncer_log_dir }}
RuntimeDirectory=pgbouncer{{ '-%d' % (idx + 1) if idx > 0 else '' }}
RuntimeDirectoryMode=0755

{% if ansible_os_family == "Debian" %}
ExecStart=/usr/sbin/pgbouncer -d {{ pgbouncer_conf_dir }}/pgbouncer{{ '-%d' % (idx + 1) if idx > 0 else '' }}.ini
{% endif %}
Expand Down

0 comments on commit c6c2f35

Please sign in to comment.