silverlogic.postgresql
ANXS - PostgreSQL
Help Needed! If you can help maintain this Ansible role, please open an issue on GitHub. Many people use this role, and we definitely need assistance! 💖
This Ansible role installs and sets up PostgreSQL, along with its extensions, databases, and users.
Installation
This role works with Ansible 2.4.0 and newer.
To install it, run:
ansible-galaxy install ANXS.postgresql
Example Playbook
Here's how to use this role in a playbook:
- hosts: postgresql-server
become: yes
roles:
- { role: anxs.postgresql }
Dependencies
- ANXS.monit (Galaxy/GitHub) if you want protection from monit (make sure to set
monit_protection: true
).
Compatibility Matrix
Distribution / PostgreSQL | <= 9.3 | 9.4 | 9.5 | 9.6 | 10 | 11 | 12 |
---|---|---|---|---|---|---|---|
Ubuntu 14.04 | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
Ubuntu 16.04 | ❌ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Debian 8.x | ❌ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Debian 9.x | ❌ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
CentOS 6.x | ❌ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
CentOS 7.x | ❌ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
CentOS 8.x | ❌ | ❔ | ❔ | ❔ | ❔ | ❔ | ❔ |
Fedora latest | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
Legend:
- ✔️ - tested, works fine
- ⚠️ - not for production use
- ❔ - will work in the future (help if you can)
- ❓ - maybe works, not tested
- ❌ - has reached End of Life (EOL)
Variables
You can set the following variables in your playbook:
# Basic settings
postgresql_version: 12
postgresql_encoding: "UTF-8"
postgresql_locale: "en_US.UTF-8"
postgresql_ctype: "en_US.UTF-8"
postgresql_admin_user: "postgres"
postgresql_default_auth_method: "peer"
postgresql_service_enabled: false # Default is true
postgresql_cluster_name: "main"
postgresql_cluster_reset: false
# List of databases to create (optional)
postgresql_databases:
- name: foobar
owner: baz # optional; specify the owner
hstore: yes # install hstore extension (yes/no)
uuid_ossp: yes # install uuid-ossp extension (yes/no)
citext: yes # install citext extension (yes/no)
encoding: "UTF-8" # database encoding
lc_collate: "en_GB.UTF-8" # locale for collation
lc_ctype: "en_GB.UTF-8" # locale for character type
# List of user privileges to apply (optional)
postgresql_user_privileges:
- name: baz # user name
db: foobar # database
priv: "ALL" # privileges like INSERT, UPDATE
role_attr_flags: "CREATEDB" # role flags
More settings can be found in defaults/main.yml.
Testing
This project includes a Vagrantfile, which makes it easy to test changes. Use vagrant up
to start.
Refer to Vagrant documentation to get started.
Once your VM is ready, use vagrant provision
or run ansible-playbook tests/playbook.yml -i vagrant-inventory
to reprovision it.
For testing, check tests/playbook.yml and update variables in tests/vars.yml.
If you're contributing, please test your changes in the Vagrant environment and ensure they're included in the tests in .travis.yml.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Thanks
Creator:
Maintainers:
Top Contributors:
Feedback, Bugs, Requests...
Your feedback is welcome!
Install and configure PostgreSQL, dependencies, extensions, databases and users.
ansible-galaxy install silverlogic.postgresql