Skip to content

Set up a PostgreSQL Server with Ansible

License

Notifications You must be signed in to change notification settings

stuvusIT/postgresql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

postgresql

This role installs and configures a PostgreSQL server. It allows to set all configuration variables supported by PostgreSQL.

This role also makes PostgreSQL comply more to the FHS. This is accomplished by moving configuration to /etc, logs to /var/log, and the databases to /var/lib.

Requirements

Debian 11 (Bullseye)

Role Variables

This role seriously has a ton of variables. Instead of copying the defaults file here, look it up there. All variables from postgresql.conf are called exactly like they are called in the file but with postgres_ prepended.

Name Default/Required Description
postgres_initdb initdb Path to the initdb executable. On Ubuntu, the default value is automatically discovered.
postgres_home_directory /var/lib/postgresHome Path to the home of the postgres user
postgres_users [] List of dicts of postgresql_user parameters
postgres_dbs [] List of dicts of postgresql_db parameters

roles

Name Default/Required Description
password The password to set
privileges The privileges to set

Dependencies

None

Example Playbook

- hosts: postgres
  roles:
    - role: postgresql
      postgres_users:
        - name: synapse
          password: TODO-change-me
      postgres_dbs:
        - name: synapse
          encoding: UTF8
          lc_collate: C
          lc_ctype: C
          template: template0
          owner: synapse

License

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Author Information