Page MenuHomeDevCentral

D1998.id5043.diff
No OneTemporary

D1998.id5043.diff

diff --git a/roles/paas-docker/containers/postgresql.sls b/roles/paas-docker/containers/postgresql.sls
new file mode 100644
--- /dev/null
+++ b/roles/paas-docker/containers/postgresql.sls
@@ -0,0 +1,56 @@
+# -------------------------------------------------------------
+# Salt — Provision Docker engine
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Created: 2018-11-10
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+{% set has_selinux = salt['grains.get']('selinux:enabled', False) %}
+{% set containers = pillar['docker_containers'][grains['id']] %}
+
+{% for instance, container in containers['postgresql'].items() %}
+{% set image = salt['paas_docker.get_image']("library/postgres", container) %}
+
+ # -------------------------------------------------------------
+ # Home directory
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+/srv/{{ instance }}/postgresql:
+ file.directory:
+ - user: 999
+ - group: 999
+ - makedirs: True
+
+{% if has_selinux %}
+
+selinux_context_{{ instance }}_postgresql_data:
+ selinux.fcontext_policy_present:
+ - name: /srv/{{ instance }}/postgresql
+ - sel_type: container_file_t
+
+selinux_context_{{ instance }}_postgresql_data_applied:
+ selinux.fcontext_policy_applied:
+ - name: /srv/{{ instance }}/postgresql
+
+{% endif %}
+
+# -------------------------------------------------------------
+# Container
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+{{ instance }}:
+ docker_container.running:
+ - detach: True
+ - interactive: True
+ - image: {{ image }}
+ - binds: /srv/{{ instance }}/postgresql:/var/lib/postgresql/data
+ - environment:
+ POSTGRES_USER: {{ salt['zr.get_username'](container['credential']) }}
+ POSTGRES_PASSWORD: {{ salt['zr.get_password'](container['credential']) }}
+{% if 'network' in container %}
+ - networks:
+ - {{ container['network'] }}
+{% endif %}
+
+{% endfor %}

File Metadata

Mime Type
text/plain
Expires
Thu, Feb 27, 21:41 (7 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2447879
Default Alt Text
D1998.id5043.diff (2 KB)

Event Timeline