Ansible role to install and configure a postgresql full-text search engine.
Building and improving this Ansible role have been sponsored by my current and previous employers like Cloudpunks GmbH and Proact Deutschland GmbH.
- Requirements
- Default Variables
- postgresql_backup_addition_script
- postgresql_backup_cron
- postgresql_backup_enabled
- postgresql_backup_formatting
- postgresql_backup_ignore
- postgresql_backup_path
- postgresql_backup_retention
- postgresql_ctl_options
- postgresql_default_hba
- postgresql_exporter_args
- postgresql_exporter_download
- postgresql_exporter_enabled
- postgresql_exporter_version
- postgresql_extra_databases
- postgresql_extra_environment
- postgresql_extra_hba
- postgresql_extra_ident
- postgresql_extra_users
- postgresql_global_databases
- postgresql_global_environment
- postgresql_global_hba
- postgresql_global_ident
- postgresql_global_users
- postgresql_listen_address
- postgresql_max_connections
- postgresql_packages
- postgresql_port
- postgresql_recursive_perm_enforce
- postgresql_root_password
- postgresql_root_username
- postgresql_ssl_ca_file
- postgresql_ssl_cert_file
- postgresql_ssl_crl_file
- postgresql_ssl_dh_params_file
- postgresql_ssl_enabled
- postgresql_ssl_key_file
- postgresql_superuser_reserved_connections
- postgresql_version
- Discovered Tags
- Dependencies
- License
- Author
- Minimum Ansible version:
2.10
Additional commands at the end of the script
postgresql_backup_addition_script:
A simple cron timing definition like hourly, daily or weekly
postgresql_backup_cron: daily
Enable or disable the backup script
postgresql_backup_enabled: false
Date format for the backup folder name
postgresql_backup_formatting: '%F'
Ignoring this filter via grep on database selection
postgresql_backup_ignore: (postgres|template0|template1)
Path to store the backups
postgresql_backup_path: /var/lib/postgresql/backup
Retention period to keep backups
postgresql_backup_retention: 7
Options for PostgeSQL ctl
postgresql_ctl_options:
List of default hba
postgresql_default_hba:
- type: local
database: all
user: postgres
method: peer
- type: local
database: all
user: all
method: peer
- type: host
database: all
user: all
address: 127.0.0.1/32
method: md5
- type: host
database: all
user: all
address: ::1/128
method: md5
- type: local
database: replication
user: all
method: peer
- type: host
database: replication
user: all
address: 127.0.0.1/32
method: md5
- type: host
database: replication
user: all
address: ::1/128
method: md5
postgresql_default_hba:
- type: local
database: example
user: postgresuser1
address: 127.0.0.1/32
method: md5
Optional list of additional arguments for the postgresql exporter
postgresql_exporter_args: []
URL to the apache exporter to install
postgresql_exporter_download: https://github.com/prometheus-community/postgres_exporter/releases/download/v{{
postgresql_exporter_version }}/postgres_exporter-{{ postgresql_exporter_version
}}.linux-amd64.tar.gz
Enable the installation of the apache exporter
postgresql_exporter_enabled: true
Version of the apache exporter to install
postgresql_exporter_version: 0.16.0
List of additional databases to create
postgresql_extra_databases: []
postgresql_extra_databases:
- name: example
encoding: UTF-8
lc_collate: de_DE.UTF-8
lc_ctype: de_DE.UTF-8
ansible.builtin.template: template0
state: present
- name: foobar
state: absent
Dict of extra environment variables
postgresql_extra_environment: {}
postgresql_extra_environment:
FOO: bar
EXAMPLE: works
List of extra hba
postgresql_extra_hba: []
postgresql_extra_hba:
- type: local
database: example
user: postgresuser1
address: 127.0.0.1/32
method: md5
List of extra identities
postgresql_extra_ident: []
postgresql_extra_ident:
- map: example1
system: systemuser1
postgres: postgresuser1
- map: example2
system: systemuser2
postgres: postgresuser2
List of additional users to create
postgresql_extra_users: []
postgresql_extra_users:
- name: example
password: p433w0rd
db: test
groups:
- group1
- group2
priv: ALL/example:ALL
role_attr_flags: CREATEDB,CREATEROLE,SUPERUSER
state: present
- name: foobar
state: absent
List of databases to create
postgresql_global_databases: []
postgresql_global_databases:
- name: example
encoding: UTF-8
lc_collate: de_DE.UTF-8
lc_ctype: de_DE.UTF-8
ansible.builtin.template: template0
state: present
- name: foobar
state: absent
Dict of global environment variables
postgresql_global_environment: {}
postgresql_global_environment:
FOO: bar
EXAMPLE: works
List of global hba
postgresql_global_hba: []
postgresql_global_hba:
- type: local
database: example
user: postgresuser1
address: 127.0.0.1/32
method: md5
List of global identities
postgresql_global_ident: []
postgresql_global_ident:
- map: example1
system: systemuser1
postgres: postgresuser1
- map: example2
system: systemuser2
postgres: postgresuser2
List of users to create
postgresql_global_users: []
postgresql_global_users:
- name: example
password: p433w0rd
db: test
groups:
- group1
- group2
priv: ALL/example:ALL
role_attr_flags: CREATEDB,CREATEROLE,SUPERUSER
state: present
- name: foobar
state: absent
Address to listen to
postgresql_listen_address: 0.0.0.0
Maximum of allowed connections
postgresql_max_connections: 1000
List of packages to install
postgresql_packages:
- postgresql-{{ postgresql_version }}
- postgresql-client-{{ postgresql_version }}
- python3-psycopg2
Port to listen to
postgresql_port: 5432
Enforce recursively permissions on data folder
postgresql_recursive_perm_enforce: false
Password for the root user
postgresql_root_password:
Username for the root user
postgresql_root_username: postgres
postgresql_ssl_ca_file:
postgresql_ssl_cert_file: /etc/ssl/certs/ssl-cert-snakeoil.pem
postgresql_ssl_crl_file:
postgresql_ssl_dh_params_file:
Enable SSL encryption
postgresql_ssl_enabled: true
postgresql_ssl_key_file: /etc/ssl/private/ssl-cert-snakeoil.key
Reserved connections for superuser
postgresql_superuser_reserved_connections: 3
postgresql_version: "{{ '14' if ansible_distribution_version is version('20.04', '>')
else ('12' if ansible_distribution_version is version('18.04', '>') else '10') }}"
postgresql
postgresql-exporter
Apache-2.0