No description
Find a file
Daniel 7529300c28
Merge pull request #332 from brettcs/debian12
Add support for Debian 12 distro packages in codenamemap
2024-03-11 07:42:03 +00:00
.github/workflows ci(vagrant): replace FreeBSD 12.2 with 12.3 [skip ci] 2021-12-24 14:06:11 +00:00
bin chore(gemfile.lock): update to latest gem versions (2022-W28) [skip ci] 2022-07-17 19:47:12 +01:00
docs chore(release): 0.44.0 [skip ci] 2022-02-07 23:31:36 +00:00
postgres feat(codenamemap): add support for Debian 12 2024-01-17 16:46:06 -05:00
test chore(gemfile.lock): update to latest gem versions (2022-W28) [skip ci] 2022-07-17 19:47:12 +01:00
.gitignore ci(kitchen+ci): update with latest CVE pre-salted images [skip ci] 2021-10-05 11:16:17 +01:00
.gitlab-ci.yml ci: update pre-commit configuration inc. for pre-commit.ci [skip ci] 2022-06-09 00:04:35 +01:00
.pre-commit-config.yaml ci: update pre-commit configuration inc. for pre-commit.ci [skip ci] 2022-06-09 00:04:35 +01:00
.rstcheck.cfg chore(pre-commit): use info report level for rstcheck [skip ci] 2021-05-20 14:09:47 +01:00
.rubocop.yml ci: update linters to latest versions [skip ci] 2022-02-12 23:23:35 +00:00
.salt-lint ci(travis): update salt-lint config for v0.0.10 [skip ci] 2019-10-23 17:35:39 +01:00
.travis.yml ci: update pre-commit configuration inc. for pre-commit.ci [skip ci] 2022-06-09 00:04:35 +01:00
.yamllint ci: add Debian 11 Bullseye & update yamllint configuration [skip ci] 2021-07-18 19:04:07 +01:00
AUTHORS.md chore(release): 0.45.0 [skip ci] 2022-07-18 06:25:06 +00:00
CHANGELOG.md chore(release): 0.45.0 [skip ci] 2022-07-18 06:25:06 +00:00
CODEOWNERS ci(kitchen+ci): update with 3004 pre-salted images/boxes [skip ci] 2021-11-23 10:36:29 +00:00
commitlint.config.js chore(commitlint): add {body,footer,header}-max(-line)-length [skip ci] 2020-10-07 09:09:01 +01:00
FORMULA chore(release): 0.45.0 [skip ci] 2022-07-18 06:25:06 +00:00
Gemfile chore(gemfile.lock): update to latest gem versions (2022-W22) [skip ci] 2022-05-30 17:28:17 +01:00
Gemfile.lock chore(gemfile.lock): update to latest gem versions (2022-W28) [skip ci] 2022-07-17 19:47:12 +01:00
kitchen.vagrant.yml ci(vagrant): use linked_clone at all times (inc. CI) [skip ci] 2022-05-14 20:11:36 +01:00
kitchen.yml ci: update pre-commit configuration inc. for pre-commit.ci [skip ci] 2022-06-09 00:04:35 +01:00
LICENSE Removing extra new lines 2015-05-07 13:37:18 -04:00
pillar.example chore(version): bump to modern version 2021-06-09 21:43:13 +01:00
pre-commit_semantic-release.sh chore(semantic-release): replace broken m2r with m2r2 [skip ci] 2022-01-17 08:15:37 +00:00
release-rules.js feat: implement semantic-release 2019-05-06 04:19:24 +01:00
release.config.js ci(gitlab-ci): use GitLab CI as Travis CI replacement 2020-12-16 06:38:36 +00:00

postgres-formula
================

|img_travis| |img_sr|

.. |img_travis| image:: https://travis-ci.com/saltstack-formulas/postgres-formula.svg?branch=master
   :alt: Travis CI Build Status
   :scale: 100%
   :target: https://travis-ci.com/saltstack-formulas/postgres-formula
.. |img_sr| image:: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
   :alt: Semantic Release
   :scale: 100%
   :target: https://github.com/semantic-release/semantic-release

A formula to install and configure PostgreSQL server.

.. contents:: **Table of Contents**

General notes
-------------

See the full `SaltStack Formulas installation and usage instructions
<https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>`_.

If you are interested in writing or contributing to formulas, please pay attention to the `Writing Formula Section
<https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#writing-formulas>`_.

If you want to use this formula, please pay attention to the ``FORMULA`` file and/or ``git tag``,
which contains the currently released version. This formula is versioned according to `Semantic Versioning <http://semver.org/>`_.

See `Formula Versioning Section <https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#versioning>`_ for more details.

Contributing to this repo
-------------------------

**Commit message formatting is significant!!**

Please see `How to contribute <https://github.com/saltstack-formulas/.github/blob/master/CONTRIBUTING.rst>`_ for more details.

Available states
----------------

.. contents::
   :local:

``postgres``
^^^^^^^^^^^^

Installs and configures both PostgreSQL server and client with creation of various DB objects in
the cluster. This state applies to both Linux and MacOS.

``postgres.client``
^^^^^^^^^^^^^^^^^^^

Installs the PostgreSQL client binaries and libraries on Linux.

``postgres.manage``
^^^^^^^^^^^^^^^^^^^

Creates such DB objects as: users, tablespaces, databases, schemas and extensions.
See ``pillar.example`` file for details.

``postgres.python``
^^^^^^^^^^^^^^^^^^^

Installs the PostgreSQL adapter for Python on Linux.

``postgres.server``
^^^^^^^^^^^^^^^^^^^

Installs the PostgreSQL server package on Linux, prepares the DB cluster and starts the server using
packaged init script, job or unit.


.. note::

    For PostgreSQL server before version 10 to work inside a **FreeBSD Jail**
    set ``sysvshm=new`` and ``sysvsem=new``.
    DO NOT SET ``allow.sysvipc=1``. It defeats the purpose of using Jails.

    Further information: https://blog.tyk.nu/blog/freebsd-jails-and-sysv-ipc/


**Running inside a container** (using Packer, Docker or similar tools), when OS ``init`` process
is not available to start the service and enable it on "boot", set pillar value:

.. code:: yaml

  postgres:
    bake_image: True

This toggles starting PostgreSQL daemon by issuing raw ``pg_ctl`` or ``pg_ctlcluster`` command.

``postgres.upstream``
^^^^^^^^^^^^^^^^^^^^^

Configures the PostgreSQL Official (upstream) repository on target system if
applicable.

The state relies on the ``postgres:use_upstream_repo`` Pillar value which could be set as following:

* ``True`` (default): adds the upstream repository to install packages from
* ``False``: makes sure that the repository configuration is absent
* ``'postgresapp'`` (MacOS) uses upstream PostgresApp package repository.
* ``'homebrew'`` (MacOS) uses Homebrew postgres

The ``postgres:version`` Pillar controls which version of the PostgreSQL packages should be
installed from the upstream Linux repository. Defaults to ``9.5``.


Removal states
--------------

``postgres.dropped``
^^^^^^^^^^^^^^^^^^^^

Meta state to remove Postgres software. By default the release installed by formula is targeted only. To target multiple releases, set pillar ``postgres.remove.multiple_releases: True``.

``postgres.server.remove``
^^^^^^^^^^^^^^^^^^^^^^^^^^

Remove server, lib, and contrib packages. The ``postgres.server.remove`` will retain data by default (no data loss) - set pillar ``postgres.remove.data: True`` to remove data and configuration directories also.

``postgres.client.remove``
^^^^^^^^^^^^^^^^^^^^^^^^^^

Remove client package.

``postgres.dev.remove``
^^^^^^^^^^^^^^^^^^^^^^^

Remove development and python packages.


Testing
-------

Linux testing is done with ``kitchen-salt``.

``kitchen converge``
^^^^^^^^^^^^^^^^^^^^

Creates the docker instance and runs the ``postgres`` main state, ready for testing.

``kitchen verify``
^^^^^^^^^^^^^^^^^^

Runs the ``inspec`` tests on the actual instance.

``kitchen destroy``
^^^^^^^^^^^^^^^^^^^

Removes the docker instance.

``kitchen test``
^^^^^^^^^^^^^^^^

Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``.

``kitchen login``
^^^^^^^^^^^^^^^^^

Gives you SSH access to the instance for manual testing.

Testing with Vagrant
--------------------

Windows/FreeBSD/OpenBSD testing is done with ``kitchen-salt``.

Requirements
^^^^^^^^^^^^

* Ruby
* Virtualbox
* Vagrant

Setup
^^^^^

.. code-block:: bash

   $ gem install bundler
   $ bundle install --with=vagrant
   $ bin/kitchen test [platform]

Where ``[platform]`` is the platform name defined in ``kitchen.vagrant.yml``,
e.g. ``windows-81-latest-py3``.

Note
^^^^

When testing using Vagrant you must set the environment variable ``KITCHEN_LOCAL_YAML`` to ``kitchen.vagrant.yml``.  For example:

.. code-block:: bash

   $ KITCHEN_LOCAL_YAML=kitchen.vagrant.yml bin/kitchen test      # Alternatively,
   $ export KITCHEN_LOCAL_YAML=kitchen.vagrant.yml
   $ bin/kitchen test

Then run the following commands as needed.

``bin/kitchen converge``
^^^^^^^^^^^^^^^^^^^^^^^^

Creates the Vagrant instance and runs the ``postgres`` main state, ready for testing.

``bin/kitchen verify``
^^^^^^^^^^^^^^^^^^^^^^

Runs the ``inspec`` tests on the actual instance.

``bin/kitchen destroy``
^^^^^^^^^^^^^^^^^^^^^^^

Removes the Vagrant instance.

``bin/kitchen test``
^^^^^^^^^^^^^^^^^^^^

Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``.

``bin/kitchen login``
^^^^^^^^^^^^^^^^^^^^^

Gives you RDP/SSH access to the instance for manual testing.

.. vim: fenc=utf-8 spell spl=en cc=100 tw=99 fo=want sts=2 sw=2 et