File tree Expand file tree Collapse file tree 6 files changed +23
-32
lines changed Expand file tree Collapse file tree 6 files changed +23
-32
lines changed Original file line number Diff line number Diff line change @@ -83,31 +83,15 @@ packaged init script, job or unit.
83
83
Further information: https://blog.tyk.nu/blog/freebsd-jails-and-sysv-ipc/
84
84
85
85
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:
91
88
92
89
.. code :: yaml
93
90
94
91
postgres :
95
92
bake_image : True
96
93
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.
111
95
112
96
``postgres.upstream ``
113
97
^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change 35
35
prepare_cluster :
36
36
pgcommand : pg_createcluster {{ version }} {{ cluster_name }} -d
37
37
user : root
38
+ bake_image_run_cmd : pg_ctlcluster {{ version }} {{ cluster_name }} start
38
39
39
40
{% endmacro %}
40
41
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ postgres:
9
9
version : ' 10'
10
10
pkg : postgresql
11
11
pkgs_extra : []
12
+ pkgs_deps : []
12
13
pkg_client : postgresql-client
13
14
pkg_dev : postgresql-devel
14
15
pkg_dev_deps : []
@@ -76,6 +77,7 @@ postgres:
76
77
sysrc : false
77
78
78
79
bake_image : false
80
+ bake_image_run_cmd : pg_ctl start
79
81
80
82
fromrepo : ' '
81
83
Original file line number Diff line number Diff line change 12
12
pkg_dev : postgresql
13
13
14
14
Debian :
15
+ pkgs_deps : ['python3-apt']
15
16
pkg_repo :
16
17
humanname : PostgreSQL Official Repository
17
18
key_url : ' https://www.postgresql.org/media/keys/ACCC4CF8.asc'
Original file line number Diff line number Diff line change 5
5
6
6
{%- if postgres.bake_image % }
7
7
8
- include:
9
- - postgres.server
10
-
11
8
# An attempt to start PostgreSQL with `pg_ctl`
12
-
13
- postgresql- start:
9
+ postgresql- running:
14
10
cmd.run:
15
- - name: pg_ctl - D {{ postgres.data_dir }} - l logfile start
11
+ - name: {{ postgres.bake_image_run_cmd }}
16
12
- runas: {{ postgres.user }}
17
13
- unless:
18
14
- ps - p $ (head - n 1 {{ postgres.data_dir }}/ postmaster.pid) 2 > / dev/ null
19
15
- require:
20
16
- file : postgresql- pg_hba
21
17
18
+ postgresql- service- reload :
19
+ module.run:
20
+ - name: test.true
21
+ - require:
22
+ - cmd: postgresql- running
23
+
22
24
# Try to enable PostgreSQL in "manual" way
23
25
24
26
postgresql- enable:
@@ -34,12 +36,6 @@ postgresql-enable:
34
36
- name: ' true'
35
37
{%- endif % }
36
38
- 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
44
40
45
41
{%- endif % }
Original file line number Diff line number Diff line change @@ -17,10 +17,17 @@ postgresql-profile:
17
17
- defaults:
18
18
bin_dir: {{ postgres.bin_dir }}
19
19
{%- endif % }
20
+
21
+ postgresql- pkg- deps:
22
+ pkg.installed:
23
+ - pkgs: {{ postgres.pkgs_deps }}
24
+
20
25
# Add upstream repository for your distro
21
26
postgresql- repo:
22
27
pkgrepo.managed:
23
28
{{- format_kwargs(postgres.pkg_repo) }}
29
+ - require:
30
+ - pkg: postgresql- pkg- deps
24
31
25
32
{%- else -% }
26
33
You can’t perform that action at this time.
0 commit comments