diff --git a/postgres/init.sls b/postgres/init.sls index 2dfe606..b0d1347 100644 --- a/postgres/init.sls +++ b/postgres/init.sls @@ -32,17 +32,30 @@ postgresql-cluster-prepared: {% if postgres.create_cluster != False %} - user: root - name: pg_createcluster {{ postgres.version }} main +{% else %} + - name: test -f {{ postgres.conf_dir }}/environment +{% endif %} - unless: - test -f {{ postgres.conf_dir }}/environment -{% endif %} + - require: + - pkg: postgresql-installed + - env: + LC_ALL: C.UTF-8 + +postgresql-db-prepared: + cmd.run: {% if postgres.init_db != False %} - user: {{ postgres.initdb_user }} - name: {{ postgres.commands.initdb }} {{ postgres.initdb_args }} -D {{ postgres.data_dir }} + +{% else %} + - name: test -f {{ postgres.data_dir }}/PG_VERSION +{% endif %} - unless: - test -f {{ postgres.data_dir }}/PG_VERSION -{% endif %} - require: - pkg: postgresql-installed + - cmd: postgresql-cluster-prepared - env: LC_ALL: C.UTF-8 @@ -54,6 +67,7 @@ postgresql-running: - reload: true - require: - cmd: postgresql-cluster-prepared + - cmd: postgresql-db-prepared {% if postgres.pkgs_extra %} postgresql-extra-pkgs-installed: