2019-05-02 17:01:03 +01:00
postgres-formula
================
|img_travis| |img_sr|
2019-05-06 09:38:49 +01:00
.. |img_travis| image :: https://travis-ci.com/saltstack-formulas/postgres-formula.svg?branch=master
2019-05-02 17:01:03 +01:00
:alt: Travis CI Build Status
:scale: 100%
2019-05-06 09:38:49 +01:00
:target: https://travis-ci.com/saltstack-formulas/postgres-formula
2019-05-02 17:01:03 +01:00
.. |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/> `_ .
2015-02-23 23:40:07 +05:30
2019-05-02 17:01:03 +01:00
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!!**
2019-10-14 11:37:53 +01:00
Please see `How to contribute <https://github.com/saltstack-formulas/.github/blob/master/CONTRIBUTING.rst> `_ for more details.
2015-02-23 23:40:07 +05:30
Available states
2019-05-02 17:01:03 +01:00
----------------
2015-02-23 23:40:07 +05:30
.. contents ::
2019-05-02 17:01:03 +01:00
:local:
2015-02-23 23:40:07 +05:30
`` postgres ``
2019-05-02 17:01:03 +01:00
^^^^^^^^^^^^
2015-02-23 23:40:07 +05:30
2017-01-09 16:05:48 +02:00
Installs and configures both PostgreSQL server and client with creation of various DB objects in
2018-03-08 11:41:19 +00:00
the cluster. This state applies to both Linux and MacOS.
2015-02-23 23:40:07 +05:30
2016-09-20 15:44:49 +03:00
`` postgres.client ``
2019-05-02 17:01:03 +01:00
^^^^^^^^^^^^^^^^^^^
2015-02-23 23:40:07 +05:30
2018-03-08 11:41:19 +00:00
Installs the PostgreSQL client binaries and libraries on Linux.
2016-10-20 12:23:40 +03:00
`` postgres.manage ``
2019-05-02 17:01:03 +01:00
^^^^^^^^^^^^^^^^^^^
2016-10-20 12:23:40 +03:00
2017-01-09 16:05:48 +02:00
Creates such DB objects as: users, tablespaces, databases, schemas and extensions.
See `` pillar.example `` file for details.
2015-02-23 23:40:07 +05:30
2016-09-20 15:44:49 +03:00
`` postgres.python ``
2021-05-05 15:16:30 +01:00
^^^^^^^^^^^^^^^^^^^
2015-04-21 13:40:01 -07:00
2018-03-08 11:41:19 +00:00
Installs the PostgreSQL adapter for Python on Linux.
2016-09-20 15:44:49 +03:00
2016-10-04 14:38:21 +03:00
`` postgres.server ``
2019-05-02 17:01:03 +01:00
^^^^^^^^^^^^^^^^^^^
2016-10-04 14:38:21 +03:00
2018-03-08 11:41:19 +00:00
Installs the PostgreSQL server package on Linux, prepares the DB cluster and starts the server using
2017-01-09 16:05:48 +02:00
packaged init script, job or unit.
2019-01-14 13:33:09 +01:00
.. 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/
2020-07-06 21:30:21 +03:00
**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:
2017-01-09 16:05:48 +02:00
.. code :: yaml
postgres:
bake_image: True
2020-07-06 21:30:21 +03:00
This toggles starting PostgreSQL daemon by issuing raw `` pg_ctl `` or `` pg_ctlcluster `` command.
2016-10-04 14:38:21 +03:00
2016-09-20 15:44:49 +03:00
`` postgres.upstream ``
2019-05-02 17:01:03 +01:00
^^^^^^^^^^^^^^^^^^^^^
2016-09-20 15:44:49 +03:00
Configures the PostgreSQL Official (upstream) repository on target system if
applicable.
2017-01-09 16:05:48 +02:00
The state relies on the `` postgres:use_upstream_repo `` Pillar value which could be set as following:
2016-09-20 15:44:49 +03:00
2016-09-23 17:50:57 +03:00
* `` True `` (default): adds the upstream repository to install packages from
* `` False `` : makes sure that the repository configuration is absent
2018-03-08 12:30:25 +00:00
* `` 'postgresapp' `` (MacOS) uses upstream PostgresApp package repository.
* `` 'homebrew' `` (MacOS) uses Homebrew postgres
2016-09-20 15:44:49 +03:00
2017-01-09 16:05:48 +02:00
The `` postgres:version `` Pillar controls which version of the PostgreSQL packages should be
2018-03-08 11:41:19 +00:00
installed from the upstream Linux repository. Defaults to `` 9.5 `` .
2015-04-21 13:40:01 -07:00
2018-07-24 21:44:09 +01:00
Removal states
2019-05-02 17:01:03 +01:00
--------------
2018-07-24 21:44:09 +01:00
`` postgres.dropped ``
2019-05-02 17:01:03 +01:00
^^^^^^^^^^^^^^^^^^^^
2018-07-24 21:44:09 +01:00
2018-07-25 19:48:37 +01:00
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 `` .
2018-07-24 21:44:09 +01:00
`` postgres.server.remove ``
2021-05-05 15:16:30 +01:00
^^^^^^^^^^^^^^^^^^^^^^^^^^
2018-07-24 21:44:09 +01:00
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 ``
2021-05-05 15:16:30 +01:00
^^^^^^^^^^^^^^^^^^^^^^^^^^
2018-07-24 21:44:09 +01:00
Remove client package.
`` postgres.dev.remove ``
2021-05-05 15:16:30 +01:00
^^^^^^^^^^^^^^^^^^^^^^^
2018-07-24 21:44:09 +01:00
Remove development and python packages.
2015-02-23 23:40:07 +05:30
Testing
2019-05-02 17:01:03 +01:00
-------
2015-02-23 23:40:07 +05:30
2019-04-30 17:00:23 +01:00
Linux testing is done with `` kitchen-salt `` .
2015-02-23 23:40:07 +05:30
`` kitchen converge ``
2019-05-02 17:01:03 +01:00
^^^^^^^^^^^^^^^^^^^^
2015-02-23 23:40:07 +05:30
2019-04-30 17:00:23 +01:00
Creates the docker instance and runs the `` postgres `` main state, ready for testing.
2015-02-23 23:40:07 +05:30
`` kitchen verify ``
2019-05-02 17:01:03 +01:00
^^^^^^^^^^^^^^^^^^
2015-02-23 23:40:07 +05:30
2019-04-30 17:00:23 +01:00
Runs the `` inspec `` tests on the actual instance.
`` kitchen destroy ``
2021-05-05 15:16:30 +01:00
^^^^^^^^^^^^^^^^^^^
2019-04-30 17:00:23 +01:00
Removes the docker instance.
2015-02-23 23:40:07 +05:30
`` kitchen test ``
2019-05-02 17:01:03 +01:00
^^^^^^^^^^^^^^^^
2015-02-23 23:40:07 +05:30
2019-04-30 17:00:23 +01:00
Runs all of the stages above in one go: i.e. `` destroy `` + `` converge `` + `` verify `` + `` destroy `` .
2015-02-23 23:40:07 +05:30
`` kitchen login ``
2019-05-02 17:01:03 +01:00
^^^^^^^^^^^^^^^^^
2015-02-23 23:40:07 +05:30
2019-04-30 17:00:23 +01:00
Gives you SSH access to the instance for manual testing.
2017-01-09 16:05:48 +02:00
2021-03-26 14:28:15 +00:00
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.
2017-01-09 16:05:48 +02:00
.. vim: fenc=utf-8 spell spl=en cc=100 tw=99 fo=want sts=2 sw=2 et