Skip to content

Commit 2c1ce2c

Browse files
authored
Merge pull request #298 from litnialex/master
fix(contributing): runnig formula inside container
2 parents 81c7c9f + 904a525 commit 2c1ce2c

File tree

6 files changed

+23
-32
lines changed

6 files changed

+23
-32
lines changed

docs/README.rst

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -83,31 +83,15 @@ packaged init script, job or unit.
8383
Further information: https://blog.tyk.nu/blog/freebsd-jails-and-sysv-ipc/
8484

8585

86-
``postgres.server.image``
87-
^^^^^^^^^^^^^^^^^^^^^^^^^
88-
89-
Installs the PostgreSQL server package on Linux, prepares the DB cluster and starts the server by issuing
90-
raw ``pg_ctl`` command. The ``postgres:bake_image`` Pillar toggles this behaviour. For example:
86+
**Running inside a container** (using Packer, Docker or similar tools), when OS ``init`` process
87+
is not available to start the service and enable it on "boot", set pillar value:
9188

9289
.. code:: yaml
9390
9491
postgres:
9592
bake_image: True
9693
97-
If set ``True``, then it becomes possible to fully provision PostgreSQL with all supported entities
98-
from ``postgres.manage`` state during the build ("baking") of AMI / VM / Container images (using
99-
Packer, Docker or similar tools), i.e. when OS ``init`` process is not available to start the
100-
service and enable it on "boot" of resulting appliance.
101-
102-
Also it allows to make Docker images with PostgreSQL using functionality being available since Salt
103-
2016.11.0 release:
104-
105-
.. code:: console
106-
107-
salt 'minion.with.docker' dockerng.sls_build my-postgres base=centos/systemd mods=postgres
108-
109-
If a lookup dictionary or Pillar has ``postgres:bake_image`` set ``False`` (this is default), it is
110-
equivalent of applying ``postgres.server`` state.
94+
This toggles starting PostgreSQL daemon by issuing raw ``pg_ctl`` or ``pg_ctlcluster`` command.
11195

11296
``postgres.upstream``
11397
^^^^^^^^^^^^^^^^^^^^^

postgres/codenamemap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
prepare_cluster:
3636
pgcommand: pg_createcluster {{ version }} {{ cluster_name }} -d
3737
user: root
38+
bake_image_run_cmd: pg_ctlcluster {{ version }} {{ cluster_name }} start
3839

3940
{% endmacro %}
4041

postgres/defaults.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ postgres:
99
version: '10'
1010
pkg: postgresql
1111
pkgs_extra: []
12+
pkgs_deps: []
1213
pkg_client: postgresql-client
1314
pkg_dev: postgresql-devel
1415
pkg_dev_deps: []
@@ -76,6 +77,7 @@ postgres:
7677
sysrc: false
7778

7879
bake_image: false
80+
bake_image_run_cmd: pg_ctl start
7981

8082
fromrepo: ''
8183

postgres/osfamilymap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Arch:
1212
pkg_dev: postgresql
1313

1414
Debian:
15+
pkgs_deps: ['python3-apt']
1516
pkg_repo:
1617
humanname: PostgreSQL Official Repository
1718
key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'

postgres/server/image.sls

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@
55
66
{%- if postgres.bake_image %}
77
8-
include:
9-
- postgres.server
10-
118
# An attempt to start PostgreSQL with `pg_ctl`
12-
13-
postgresql-start:
9+
postgresql-running:
1410
cmd.run:
15-
- name: pg_ctl -D {{ postgres.data_dir }} -l logfile start
11+
- name: {{ postgres.bake_image_run_cmd }}
1612
- runas: {{ postgres.user }}
1713
- unless:
1814
- ps -p $(head -n 1 {{ postgres.data_dir }}/postmaster.pid) 2>/dev/null
1915
- require:
2016
- file: postgresql-pg_hba
2117
18+
postgresql-service-reload:
19+
module.run:
20+
- name: test.true
21+
- require:
22+
- cmd: postgresql-running
23+
2224
# Try to enable PostgreSQL in "manual" way
2325
2426
postgresql-enable:
@@ -34,12 +36,6 @@ postgresql-enable:
3436
- name: 'true'
3537
{%- endif %}
3638
- require:
37-
- cmd: postgresql-start
38-
39-
{%- else %}
40-
41-
postgresql-start:
42-
test.show_notification:
43-
- text: The 'postgres:bake_image' Pillar is disabled (set to 'False').
39+
- cmd: postgresql-running
4440
4541
{%- endif %}

postgres/upstream.sls

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@ postgresql-profile:
1717
- defaults:
1818
bin_dir: {{ postgres.bin_dir }}
1919
{%- endif %}
20+
21+
postgresql-pkg-deps:
22+
pkg.installed:
23+
- pkgs: {{ postgres.pkgs_deps }}
24+
2025
# Add upstream repository for your distro
2126
postgresql-repo:
2227
pkgrepo.managed:
2328
{{- format_kwargs(postgres.pkg_repo) }}
29+
- require:
30+
- pkg: postgresql-pkg-deps
2431
2532
{%- else -%}
2633

0 commit comments

Comments
 (0)