jradtilbrook.pgbouncer
Ansible Role: PgBouncer 
This role installs and sets up PgBouncer, which helps manage connections for PostgreSQL databases.
It is specifically designed for Ubuntu 16.04, but other versions of Debian may also work.
Requirements
No special requirements.
Role Variables
The pgbouncer_databases
list allows you to set up multiple databases easily. You can define any property from the connection string here, and it will be added automatically. The example below shows how to create a dev
database that connects to the postgres
database on postgres:5432
as user foo
with a specific password. You can add more databases in a similar way.
pgbouncer_databases:
- dev:
host: postgres # or use the actual IP address
port: 5432
dbname: postgres
user: foo
password: md5asdofiasodfa09f9832f
This role can also install the postgresql-client
package for command-line access to PostgreSQL or PgBouncer. To do this, set pgbouncer_install_psql: true
.
You can change some settings in the configuration template. To do this, create a variable named after the setting you want to change, starting with pgbouncer_
. For example, to change the default listen_port
from 6432, use the variable pgbouncer_listen_port
. Check the template file for other settings that can be changed this way. Note that not all settings can be changed, only some common ones that I use.
Note: Some variables need to be in a list, and it should be clear which ones.
For more information about other variables, check the defaults/main.yml
. You should also look at templates/pgbouncer.ini.j2
for additional variable options.
pgbouncer_install_state
: This is helpful for updating PgBouncer to newer versions after it has been installed. Use latest
if you want to do this.
Resources
You can find more information about PgBouncer at the following links:
Dependencies
No dependencies.
Example Playbook
- hosts: servers
become: yes
roles:
- role: jradtilbrook.pgbouncer
pgbouncer_databases:
- testing:
host: postgres
port: 5432
dbname: postgres
License
MIT
PgBouncer connection pooler for Ubuntu
ansible-galaxy install jradtilbrook.pgbouncer