Skip to content

Commit

Permalink
Move concatenation of cluster preparation command to map.jinja
Browse files Browse the repository at this point in the history
  • Loading branch information
myii committed Jun 24, 2018
1 parent 944a077 commit f24b962
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 10 additions & 0 deletions postgres/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@
),
base='postgres',
) %}

{# Concatenate the cluster preparation command and then append it to the `postgres` dict #}
{% set pc_cmd = '{0} {1}'.format(postgres.prepare_cluster.pgcommand, postgres.data_dir) %}
{% if postgres.cluster.locale %}
{% set pc_cmd = '{0} --locale={1}'.format(pc_cmd, postgres.cluster.locale) %}
{% endif %}
{% if postgres.cluster.encoding %}
{% set pc_cmd = '{0} --encoding={1}'.format(pc_cmd, postgres.cluster.encoding) %}
{% endif %}
{% do postgres.update({'prepare_cluster_cmd': pc_cmd}) %}
9 changes: 1 addition & 8 deletions postgres/server/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,7 @@ postgresql-cluster-prepared:
- name: {{ postgres.prepare_cluster.command }}
- unless: {{ postgres.prepare_cluster.test }}
{%- else %}
{%- set cc_cmd = '{0} {1}'.format(postgres.prepare_cluster.pgcommand, postgres.data_dir) %}
{%- if postgres.cluster.locale %}
{%- set cc_cmd = '{0} --locale={1}'.format(cc_cmd, postgres.cluster.locale) %}
{%- endif %}
{%- if postgres.cluster.encoding %}
{%- set cc_cmd = '{0} --encoding={1}'.format(cc_cmd, postgres.cluster.encoding) %}
{%- endif %}
- name: {{ cc_cmd }}
- name: {{ postgres.prepare_cluster_cmd }}
- unless: test -f {{ postgres.data_dir }}/{{ postgres.prepare_cluster.pgtestfile }}
{%- endif %}
- cwd: /
Expand Down

0 comments on commit f24b962

Please sign in to comment.