mirror of
https://github.com/saltstack-formulas/postgres-formula.git
synced 2025-04-17 10:10:31 +00:00
Merge pull request #298 from litnialex/master
fix(contributing): runnig formula inside container
This commit is contained in:
commit
2c1ce2c3a4
6 changed files with 23 additions and 32 deletions
|
@ -83,31 +83,15 @@ packaged init script, job or unit.
|
|||
Further information: https://blog.tyk.nu/blog/freebsd-jails-and-sysv-ipc/
|
||||
|
||||
|
||||
``postgres.server.image``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Installs the PostgreSQL server package on Linux, prepares the DB cluster and starts the server by issuing
|
||||
raw ``pg_ctl`` command. The ``postgres:bake_image`` Pillar toggles this behaviour. For example:
|
||||
**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
|
||||
|
||||
If set ``True``, then it becomes possible to fully provision PostgreSQL with all supported entities
|
||||
from ``postgres.manage`` state during the build ("baking") of AMI / VM / Container images (using
|
||||
Packer, Docker or similar tools), i.e. when OS ``init`` process is not available to start the
|
||||
service and enable it on "boot" of resulting appliance.
|
||||
|
||||
Also it allows to make Docker images with PostgreSQL using functionality being available since Salt
|
||||
2016.11.0 release:
|
||||
|
||||
.. code:: console
|
||||
|
||||
salt 'minion.with.docker' dockerng.sls_build my-postgres base=centos/systemd mods=postgres
|
||||
|
||||
If a lookup dictionary or Pillar has ``postgres:bake_image`` set ``False`` (this is default), it is
|
||||
equivalent of applying ``postgres.server`` state.
|
||||
This toggles starting PostgreSQL daemon by issuing raw ``pg_ctl`` or ``pg_ctlcluster`` command.
|
||||
|
||||
``postgres.upstream``
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
prepare_cluster:
|
||||
pgcommand: pg_createcluster {{ version }} {{ cluster_name }} -d
|
||||
user: root
|
||||
bake_image_run_cmd: pg_ctlcluster {{ version }} {{ cluster_name }} start
|
||||
|
||||
{% endmacro %}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ postgres:
|
|||
version: '10'
|
||||
pkg: postgresql
|
||||
pkgs_extra: []
|
||||
pkgs_deps: []
|
||||
pkg_client: postgresql-client
|
||||
pkg_dev: postgresql-devel
|
||||
pkg_dev_deps: []
|
||||
|
@ -76,6 +77,7 @@ postgres:
|
|||
sysrc: false
|
||||
|
||||
bake_image: false
|
||||
bake_image_run_cmd: pg_ctl start
|
||||
|
||||
fromrepo: ''
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ Arch:
|
|||
pkg_dev: postgresql
|
||||
|
||||
Debian:
|
||||
pkgs_deps: ['python3-apt']
|
||||
pkg_repo:
|
||||
humanname: PostgreSQL Official Repository
|
||||
key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'
|
||||
|
|
|
@ -5,20 +5,22 @@
|
|||
|
||||
{%- if postgres.bake_image %}
|
||||
|
||||
include:
|
||||
- postgres.server
|
||||
|
||||
# An attempt to start PostgreSQL with `pg_ctl`
|
||||
|
||||
postgresql-start:
|
||||
postgresql-running:
|
||||
cmd.run:
|
||||
- name: pg_ctl -D {{ postgres.data_dir }} -l logfile start
|
||||
- name: {{ postgres.bake_image_run_cmd }}
|
||||
- runas: {{ postgres.user }}
|
||||
- unless:
|
||||
- ps -p $(head -n 1 {{ postgres.data_dir }}/postmaster.pid) 2>/dev/null
|
||||
- require:
|
||||
- file: postgresql-pg_hba
|
||||
|
||||
postgresql-service-reload:
|
||||
module.run:
|
||||
- name: test.true
|
||||
- require:
|
||||
- cmd: postgresql-running
|
||||
|
||||
# Try to enable PostgreSQL in "manual" way
|
||||
|
||||
postgresql-enable:
|
||||
|
@ -34,12 +36,6 @@ postgresql-enable:
|
|||
- name: 'true'
|
||||
{%- endif %}
|
||||
- require:
|
||||
- cmd: postgresql-start
|
||||
|
||||
{%- else %}
|
||||
|
||||
postgresql-start:
|
||||
test.show_notification:
|
||||
- text: The 'postgres:bake_image' Pillar is disabled (set to 'False').
|
||||
- cmd: postgresql-running
|
||||
|
||||
{%- endif %}
|
||||
|
|
|
@ -17,10 +17,17 @@ postgresql-profile:
|
|||
- defaults:
|
||||
bin_dir: {{ postgres.bin_dir }}
|
||||
{%- endif %}
|
||||
|
||||
postgresql-pkg-deps:
|
||||
pkg.installed:
|
||||
- pkgs: {{ postgres.pkgs_deps }}
|
||||
|
||||
# Add upstream repository for your distro
|
||||
postgresql-repo:
|
||||
pkgrepo.managed:
|
||||
{{- format_kwargs(postgres.pkg_repo) }}
|
||||
- require:
|
||||
- pkg: postgresql-pkg-deps
|
||||
|
||||
{%- else -%}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue