postgres.sls 1.16 KB
Newer Older
Bach Dániel committed
1 2 3 4 5
{% if grains['os_family'] == 'RedHat' %}
postgresql_initdb:
  cmd.run:
    - cwd: /
    - user: root
Bach Dániel committed
6
    - name: postgresql-setup initdb
Bach Dániel committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20
    - unless: test -f /var/lib/pgsql/data/postgresql.conf
    - env:
      LC_ALL: C.UTF-8
  file.managed:
    - name: /var/lib/pgsql/data/pg_hba.conf
    - template: jinja
    - source: salt://manager/files/pg_hba.conf
    - user: postgres
    - group: postgres
    - mode: 600
    - require:
       - cmd: postgresql_initdb
{% endif %}

Guba Sándor committed
21 22 23
postgres_service:
  service.running:
    - name: postgresql
Bach Dániel committed
24 25 26 27 28
    - enable: True
    {% if grains['os_family'] == 'RedHat' %}
    - require:
      - file: postgresql_initdb
    {% endif %}
Guba Sándor committed
29 30 31 32 33

dbuser:
  postgres_user.present:
    - name: {{ pillar['database']['user'] }}
    - password: {{ pillar['database']['password'] }}
Bach Dániel committed
34
    - user: postgres
Guba Sándor committed
35 36 37 38 39 40 41 42 43 44 45
    - require:
      - service: postgresql

database:
  postgres_database.present:
    - name: {{ pillar['database']['name'] }}
    - encoding: UTF8
    - lc_ctype: en_US.UTF8
    - lc_collate: en_US.UTF8
    - template: template0
    - owner: {{ pillar['database']['user'] }}
Bach Dániel committed
46
    - user: postgres
Guba Sándor committed
47 48 49
    - require:
      - service: postgresql
      - postgres_user: dbuser