No description
Find a file
2021-09-10 14:14:32 +02:00
defaults first version 2021-09-10 14:09:38 +02:00
handlers first version 2021-09-10 14:09:38 +02:00
meta first version 2021-09-10 14:09:38 +02:00
molecule/default first version 2021-09-10 14:09:38 +02:00
tasks first version 2021-09-10 14:09:38 +02:00
templates first version 2021-09-10 14:09:38 +02:00
.gitignore first version 2021-09-10 14:09:38 +02:00
.yamllint first version 2021-09-10 14:09:38 +02:00
CHANGELOG.md release: version 1.0.0 2021-09-10 14:14:32 +02:00
LICENSE first version 2021-09-10 14:09:38 +02:00
README.md release: version 1.0.0 2021-09-10 14:14:32 +02:00

Ansible role: Postgresql

Version License

Install and configure Postgresql

Requirements

  • Ansible >= 2.9
  • Debian
    • Buster
    • Bullseye

Role variables

Name Type Required Default Comment
postgresql_version str no 13 the major version to use
postgresql_use_official_repository bool no false set to true if you want official postgresql repository
postgresql_config dict no add option config file
postgresql_databases array no the database to manage
postgresql_users array no the users to manage

postgresql_config

See all options on postgresql documentation

Example:

  listen_addresses: '*'
  port: 5432
  ssl: true
  unix_socket_directories: /var/run/postgresql

postgresql_databases

Name Type Required Default Comment
name str yes the database name
encoding str no UTF-8 encoding to use
lc_collate str no C.UTF-8 lc_collate to use
lc_ctype str no C.UTF-8 lc_ctype to use
template str no template0 template to use
state str no present if absent the database is deleted

Example:

  - name: test
    encoding: UTF-8
    state: present

postgresql_users

Name Type Required Default Comment
name str yes the user name
password str yes the password to logon
database str yes the database where user's permissions will be granted
privileges array yes list with the user's privileges
state str no present if absent the user is deleted

Example:

  - name: user1
    password: secret
    database: test
    privileges:
      - SELECT
      - table1:INSERT
    state: present

How to use

- hosts: server
  roles:
    - postgresql
  vars:
    postgresql_use_official_repository: true
    postgresql_config:
      listen_addresses: '*'
    postgresql_databases:
      - name: test
    postgresql_users
      - name: user1
        password: secret
        database: test
        privileges:
          - SELECT
          - table1:INSERT

Development

Test with molecule and docker

  • install docker
  • install python3 and python3-pip
  • install molecule and dependencies pip3 install molecule molecule-docker docker ansible-lint testinfra yamllint
  • run molecule test

License

Copyright (c) 2021 Adrien Waksberg

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.