From c6c2f35875df5538d85b8ce4121bde57e1dc24d8 Mon Sep 17 00:00:00 2001 From: Vitaliy Kukharik <37010174+vitabaks@users.noreply.github.com> Date: Sat, 18 Nov 2023 14:15:55 +0300 Subject: [PATCH] PgBouncer: Use RuntimeDirectory (#506) --- roles/pgbouncer/tasks/main.yml | 9 +++++++++ roles/pgbouncer/templates/pgbouncer.service.j2 | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/roles/pgbouncer/tasks/main.yml b/roles/pgbouncer/tasks/main.yml index 54fb72136..a91386f3e 100644 --- a/roles/pgbouncer/tasks/main.yml +++ b/roles/pgbouncer/tasks/main.yml @@ -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 diff --git a/roles/pgbouncer/templates/pgbouncer.service.j2 b/roles/pgbouncer/templates/pgbouncer.service.j2 index 2b926a36a..c69eb1ee5 100644 --- a/roles/pgbouncer/templates/pgbouncer.service.j2 +++ b/roles/pgbouncer/templates/pgbouncer.service.j2 @@ -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 %}