honzamach.postgresql

Role postgresql

This guide is about the postgresql Ansible role, which helps you easily install the PostgreSQL database.

Overview

The postgresql role aims to make PostgreSQL installation simple. It only performs the basic installation and setup. For any advanced configurations, you need to do those manually. This role installs the latest version, which is 12, and can optionally remove older versions (10.x and 11.x). However, migration between versions is complex and must be handled manually.

Table of Contents

Installation

To install this role from Ansible Galaxy, run the following command:

ansible-galaxy install honzamach.postgresql

To install directly from GitHub, use:

git clone https://github.com/honzamach/ansible-role-postgresql.git honzamach.postgresql

Cloning from GitHub allows you to easily update the role when new versions are available.

Dependencies

This role doesn’t depend on any other roles.

These roles depend directly on this role:

  • griffin
  • mentat
  • mentat_dev

Usage

Example of an inventory file (inventory):

[servers_postgresql]
your-server

Example of a role playbook file (role_playbook.yml):

- hosts: servers_postgresql
  remote_user: root
  roles:
    - role: honzamach.postgresql
  tags:
    - role-postgresql

To run everything, use:

ansible-playbook --ask-vault-pass --inventory inventory role_playbook.yml

To update the package cache before installing packages, use:

ansible-playbook --ask-vault-pass --inventory inventory role_playbook.yml --extra-vars '{"hm_pgsql__apt_force_update":"yes"}'

Configuration Tips

  1. Create or edit the file inventory/group_vars/all/vars.yml to define common settings for all servers:

    hm_pgsql__monitoring_password: "{{ vault_hm_pgsql__monitoring_password }}"
    
  2. Create an encrypted vault file (inventory/group_vars/all/vault.yml) to store sensitive values like backup passwords:

    vault_hm_pgsql__monitoring_password: something-so-secret-no1-is-gonna-guess
    
  3. Use inventory/host_vars/[your-server]/vars.yml to customize settings for specific servers. See the configuration variables section for options.

Configuration Variables

Internal role variables include:

  • hm_pgsql__apt_key_url: URL for GPG key for PostgreSQL packages.
    Default: "https://www.postgresql.org/media/keys/ACCC4CF8.asc"

  • hm_pgsql__major_version: Version number (default is 12).
    Default: "12"

  • hm_pgsql__install_packages: List of packages that must be installed.
    Default: Defined in DEFAULT file.

  • hm_pgsql__databases: List of databases that should exist on the server.
    Default: [] (an empty list).

A full list of configuration options is provided in the documentation.

Managed Files

This role manages the content of certain files on the target system, including:

  • /etc/logrotate.d/postgresql-common
  • /etc/nagios/nrpe.d/postgresql.cfg
  • /opt/system-status/system-status.d/20-postgresql

Author and License

  • Copyright: (C) since 2019 Honza Mach
  • Author: Honza Mach
  • This role is governed by the MIT license. See the LICENSE file for details.
Informazioni sul progetto

Ansible role for convenient installation of the PostgreSQL database.

Installa
ansible-galaxy install honzamach.postgresql
Licenza
mit
Download
143
Proprietario