- re-arrange cluster initialization to a set of variables in a dictionary

which control three things:
    1. should we initialize?
    2. if so, how?
    3. what environment variables and user to use
  The approach taken is very similar to what the Apache formula uses, namely:
  a default dictionary which is over-ridden by:
     os-specific defaults,
     then os codename defaults,
     then os finger defaults,
     and finally user-specified pillar values
- this also adds support for grains['osfinger']
This commit is contained in:
Jon Nelson
2016-07-08 15:34:45 -05:00
parent 783d78bde7
commit 0220b67a85
7 changed files with 78 additions and 60 deletions

View File

@@ -16,9 +16,7 @@ postgresql-config-dir:
- makedirs: True
- require:
- pkg: postgresql-installed
{% if postgres.conf_dir == postgres.data_dir %}
- cmd: postgresql-cluster-prepared
{% endif %}
postgresql-installed:
pkg.installed:
@@ -28,20 +26,17 @@ postgresql-installed:
# make sure the data directory and contents have been initialized
postgresql-cluster-prepared:
cmd.run:
{% if postgres.initdb %}
- name: {{ postgres.commands.initdb }} {{ postgres.initdb_args }} -D {{ postgres.data_dir }}
{% elif grains.os_family == 'Debian' %}
- name: pg_createcluster {{ postgres.version }} main
{# else: TODO #}
{% endif %}
- cwd: /
- user: {{ postgres.initdb_user }}
- name: {{ postgres.prepare_cluster.command }}
- user: {{ postgres.prepare_cluster.user }}
- unless:
- test -f {{ postgres.data_dir }}/PG_VERSION
- {{ postgres.prepare_cluster.test }}
- require:
- pkg: postgresql-installed
- env:
LC_ALL: C.UTF-8
{% for name, value in postgres.prepare_cluster.env.items() %}
{{ name }}: {{ value }}
{% endfor %}
postgresql-running:
service.running:
@@ -154,8 +149,11 @@ postgresql-db-{{ name }}:
- user: {{ db.get('runas', postgres.user) }}
- require:
- service: postgresql-running
{% if db.get('user') %}
- postgres_user: postgresql-user-{{ db.get('user') }}
{% if db.get('tablespace') %}
- postgres_tablespace: postgresql-tablespace-{{ name }}
{% endif %}
{% if db.get('owner') %}
- postgres_user: postgresql-user-{{ db.get('owner') }}
{% endif %}
{% if db.schemas is defined %}