ansible role for postgresql
Go to file
Jeff Geerling 78495e991e Add a LICENSE file for MIT license. [ci skip] 2017-03-31 11:25:49 -05:00
defaults Add db key for users. 2016-09-30 20:39:02 -05:00
handlers So many fixes for Ubuntu and Debian. 2016-09-29 20:01:39 -05:00
meta Initial commit for Ubuntu, Debian, and RHEL/CentOS. 2016-09-29 11:03:13 -05:00
tasks Fixes #7: 'postgresql_packages' is undefined with Ansible 2.2. 2016-11-02 12:02:30 -05:00
templates Fix broken tests, add Debian 8 test. 2016-09-29 14:33:39 -05:00
tests Fix Ubuntu test failures due to apt update. 2016-11-23 09:13:30 -06:00
vars Issue #2: More large fixes for later PostgreSQL versions. 2016-09-29 22:58:27 -05:00
.travis.yml Issue #2: Continue to pick up the mess. 2016-09-29 22:16:48 -05:00
LICENSE Add a LICENSE file for MIT license. [ci skip] 2017-03-31 11:25:49 -05:00
README.md Update the author's URL. Now with more HTTPS! 2017-01-21 20:02:29 -06:00

README.md

Ansible Role: PostgreSQL

Build Status

Installs and configures PostgreSQL server on RHEL/CentOS or Debian/Ubuntu servers.

Requirements

No special requirements; note that this role requires root access, so either run it in a playbook with a global become: yes, or invoke the role in your playbook like:

- hosts: database
  roles:
    - role: geerlingguy.postgresql
      become: yes

Role Variables

Available variables are listed below, along with default values (see defaults/main.yml):

postgresql_enablerepo: ""

(RHEL/CentOS only) You can set a repo to use for the PostgreSQL installation by passing it in here.

postgresql_user: postgres
postgresql_group: postgres

The user and group under which PostgreSQL will run.

postgresql_unix_socket_directories:
  - /var/run/postgresql

The directories (usually one, but can be multiple) where PostgreSQL's socket will be created.

postgresql_global_config_options:
  - option: unix_socket_directories
    value: '{{ postgresql_unix_socket_directories | join(",") }}'

Global configuration options that will be set in postgresql.conf. Note that for RHEL/CentOS 6 (or very old versions of PostgreSQL), you need to at least override this variable and set the option to unix_socket_directory.

postgresql_locales:
  - 'en_US.UTF-8'

(Debian/Ubuntu only) Used to generate the locales used by PostgreSQL databases.

postgresql_databases:
  - name: exampledb # required; the rest are optional
    lc_collate: # defaults to 'en_US.UTF-8'
    lc_ctype: # defaults to 'en_US.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
    state: # defaults to 'present'

A list of databases to ensure exist on the server. Only the name is required; all other properties are optional.

postgresql_users:
  - name: jdoe #required; the rest are optional
    password: # 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'

A list of users to ensure exist on the server. Only the name is required; all other properties are optional.

postgresql_version: [OS-specific]
postgresql_data_dir: [OS-specific]
postgresql_bin_path: [OS-specific]
postgresql_config_path: [OS-specific]
postgresql_daemon: [OS-specific]
postgresql_packages: [OS-specific]

OS-specific variables that are set by include files in this role's vars directory. These shouldn't be overridden unless you're using a verison of PostgreSQL that wasn't installed using system packages.

Dependencies

None.

Example Playbook

- hosts: database
  become: yes
  vars_files:
    - vars/main.yml
  roles:
    - geerlingguy.postgresql

Inside vars/main.yml:

postgresql_databases:
  - name: example_db
postgresql_users:
  - name: example_user
    password: supersecure

License

MIT / BSD

Author Information

This role was created in 2016 by Jeff Geerling, author of Ansible for DevOps.