Kill create_cluster pillar switch, refs: #100

It is just a variant of init_db. A more correct solution would be to
support configuring a different initdb command while passing values from
the pillar by default like version. This would make it truly generic but
is probably not achievable given current pillar self-referencing
capabilities (ie. none).

Thus, I decided to make it OS family specific since Debian provides its
own tools to manage clusters, etc. Gentoo also has a specific way to
initialize a new cluster which does not fit with commands.initdb so
the current if/elif would be extended when support is added for Gentoo.
This commit is contained in:
Gilles Dartiguelongue
2016-06-07 11:52:47 +02:00
parent dd53a6bea9
commit e0ed6b6e77
3 changed files with 13 additions and 33 deletions

View File

@@ -28,34 +28,18 @@ postgresql-installed:
# make sure the data directory and contents have been initialized
postgresql-cluster-prepared:
cmd.run:
- cwd: /
{% 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
- require:
- pkg: postgresql-installed
- env:
LC_ALL: C.UTF-8
postgresql-db-prepared:
cmd.run:
{% if postgres.init_db != False %}
- user: {{ postgres.initdb_user }}
{% if postgres.initdb %}
- name: {{ postgres.commands.initdb }} {{ postgres.initdb_args }} -D {{ postgres.data_dir }}
{% else %}
- name: test -f {{ postgres.data_dir }}/PG_VERSION
{% endif %}
{% elif grains.os_family == 'Debian' %}
- name: pg_createcluster {{ postgres.version }} main
{# else: TODO #}
{% endif %}
- cwd: /
- user: {{ postgres.initdb_user }}
- unless:
- test -f {{ postgres.data_dir }}/PG_VERSION
- require:
- pkg: postgresql-installed
- cmd: postgresql-cluster-prepared
- env:
LC_ALL: C.UTF-8
@@ -67,7 +51,6 @@ postgresql-running:
- reload: true
- require:
- cmd: postgresql-cluster-prepared
- cmd: postgresql-db-prepared
{% if postgres.pkgs_extra %}
postgresql-extra-pkgs-installed: