From f24b962ebc8a0568024bde48d96f73d1765727c4 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Sun, 24 Jun 2018 16:18:21 +0100 Subject: [PATCH] Move concatenation of cluster preparation command to `map.jinja` --- postgres/map.jinja | 10 ++++++++++ postgres/server/init.sls | 9 +-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/postgres/map.jinja b/postgres/map.jinja index 55c0449d..50c59532 100644 --- a/postgres/map.jinja +++ b/postgres/map.jinja @@ -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}) %} diff --git a/postgres/server/init.sls b/postgres/server/init.sls index 417d2790..a576fdef 100644 --- a/postgres/server/init.sls +++ b/postgres/server/init.sls @@ -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: /