Split postgresql-cluster-prepared in two states, refs: #100

Previous write up lead the two pillar settings overwriting each other in the same state.
We can now properly select whether to create a cluster and/or initialize a new database.

Also the commands will not fail if both settings are false as found on Debian family OSes
as this is taken care of by the packaging system for main cluster.
This commit is contained in:
Gilles Dartiguelongue 2016-06-06 14:28:31 +02:00
parent 8ddfbd2403
commit 4a00acf26a

View file

@ -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: