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.
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^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 1212 pkg_dev : postgresql
1313
1414Debian :
15+ pkgs_deps : ['python3-apt']
1516 pkg_repo :
1617 humanname : PostgreSQL Official Repository
1718 key_url : ' https://www.postgresql.org/media/keys/ACCC4CF8.asc'
Original file line number Diff line number Diff line change 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
2426postgresql- 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 % }
Original file line number Diff line number Diff 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
2126postgresql- repo:
2227 pkgrepo.managed:
2328 {{- format_kwargs(postgres.pkg_repo) }}
29+ - require:
30+ - pkg: postgresql- pkg- deps
2431
2532 {%- else -% }
2633
You can’t perform that action at this time.
0 commit comments