diff --git a/pgbouncer/README.md b/pgbouncer/README.md index bf1914fc..fe8c0493 100644 --- a/pgbouncer/README.md +++ b/pgbouncer/README.md @@ -36,4 +36,18 @@ The value of `hash` can be obtained by running this command on the PostgreSQL se > These accounts must exist on the PostegreSQL server. +The variables `pgbouncer_admin_users` and `pgbouncer_stats_users` list the SQL user can be access on pgbouncer console. This variables can be defines like this : + +``` +pgbouncer_admin_users: + - account1 + - account2 +``` + +``` +pgbouncer_stats_users: + - account1 + - account2 +``` + The full list of variables (with default values) can be found in `defaults/main.yml`. diff --git a/pgbouncer/defaults/main.yml b/pgbouncer/defaults/main.yml index 4290afa5..5b5d293f 100644 --- a/pgbouncer/defaults/main.yml +++ b/pgbouncer/defaults/main.yml @@ -6,4 +6,8 @@ pgbouncer_auth_type: "scram-sha-256" pgbouncer_databases: [] -pgbouncer_account_list: [] +pgbouncer_admin_users: [] + +pgbouncer_stats_users: [] + +pgbouncer_account_list: [] \ No newline at end of file diff --git a/pgbouncer/tasks/main.yml b/pgbouncer/tasks/main.yml index 1d76931f..f52383a2 100644 --- a/pgbouncer/tasks/main.yml +++ b/pgbouncer/tasks/main.yml @@ -3,16 +3,19 @@ ansible.builtin.apt: name: pgbouncer state: present + - name: Limit for PgBouncer is set ansible.builtin.lineinfile: path: /etc/default/pgbouncer line: ulimit -n 65536 notify: Restart PgBouncer + - name: Add config file for PgBouncer ansible.builtin.template: src: pgbouncer.ini.j2 dest: /etc/pgbouncer/pgbouncer.ini notify: Restart PgBouncer + - name: Populate userlist.txt ansible.builtin.template: src: userlist.txt.j2 diff --git a/pgbouncer/templates/pgbouncer.ini.j2 b/pgbouncer/templates/pgbouncer.ini.j2 index 3bed0c5b..11eac58c 100644 --- a/pgbouncer/templates/pgbouncer.ini.j2 +++ b/pgbouncer/templates/pgbouncer.ini.j2 @@ -14,6 +14,9 @@ unix_socket_dir = auth_type = {{ pgbouncer_auth_type }} auth_file = /etc/pgbouncer/userlist.txt +admin_users = {{ pgbouncer_admin_users | join(",") }} +stats_users = {{ pgbouncer_stats_users | join(",") }} + # La connexion au serveur redevient libre lorsque le client termine une transaction # Autres valeurs possibles : session (lorsque le client ferme la session), statement (lorsque la requĂȘte se termine) pool_mode = transaction