supertarto.postgresql
Ansible PostgreSQL
This guide helps you install and set up PostgreSQL using Ansible. It has only been tested on Debian systems.
Supported Platforms
- Debian 10 (Buster)
- Debian 11 (Bullseye)
- Debian 12 (Bookworm)
Role Variables
You can specify a list of packages to install.
postgresql_packages:
- postgresql
- postgresql-contrib
- libpq-dev
Settings about PostgreSQL, including the version to install and relevant directory paths.
postgresql_version: "11"
postgresql_daemon: postgresql@{{ postgresql_version }}-main
postgresql_data_dir: "/var/lib/postgresql/{{ postgresql_version }}/main"
postgresql_bin_path: "/usr/lib/postgresql/{{ postgresql_version }}/bin"
postgresql_config_path: "/etc/postgresql/{{ postgresql_version }}/main"
You can use a script to handle database dumps.
postgresql_use_dump_script: true
postgresql_dump_path: "/var/local/dump_sql"
postgresql_dump_path_script: "/var/local/scripts"
Specify the Python library needed for creating users.
postgresql_python_library: python-psycopg2
Set the default locale.
postgresql_locales:
- 'fr_FR.UTF-8'
Define the user and group for PostgreSQL.
postgresql_user: postgres
postgresql_group: postgres
Configuration related to the socket.
postgresql_global_config_options:
- option: unix_socket_directories
value: '{{ postgresql_unix_socket_directories | join(",") }}'
postgresql_unix_socket_directories:
- /var/run/postgresql
List of users to create. Only the name field is required.
postgresql_users:
# - name: testuser #required; the rest are optional
# password: # defaults to not set
# encrypted: # defaults to not set
# priv: # defaults to not set
# role_attr_flags: # defaults to not set
# db: # defaults to not set
# login_host: # defaults to 'localhost'
# login_password: # defaults to not set
# login_user: # defaults to '{{ postgresql_user }}'
# login_unix_socket: # defaults to 1st of postgresql_unix_socket_directories
# port: # defaults to not set
# state: # defaults to 'present'
List of databases to create. Only the name field is required.
postgresql_databases:
# - name: exampledb # required; the rest are optional
# lc_collate: # defaults to 'fr_FR.UTF-8'
# lc_ctype: # defaults to 'fr_FR.UTF-8'
# encoding: # defaults to 'UTF-8'
# template: # defaults to 'template0'
# login_host: # defaults to 'localhost'
# login_password: # defaults to not set
# login_user: # defaults to '{{ postgresql_user }}'
# login_unix_socket: # defaults to 1st of postgresql_unix_socket_directories
# port: # defaults to not set
# owner: # defaults to postgresql_user
# state: # defaults to 'present'
Examples
Here’s an example playbook:
---
- name: Converge
hosts: all
roles:
- role: supertarto.postgresql
vars:
postgresql_databases:
- name: example
postgresql_users:
- name: testuser
Installation
To install this role, use the following command:
ansible-galaxy install supertarto.postgresql
License
GPL V3.0
Installa
ansible-galaxy install supertarto.postgresqlLicenza
gpl-3.0
Download
529
Proprietario
