From 69a59b6f63050714df89863a312c7e0085af067c Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Thu, 12 Jan 2017 11:34:41 +0200 Subject: [PATCH] Skip configuring ACLs in ``pg_hba.conf`` if not provided --- pillar.example | 7 +++++-- postgres/server/init.sls | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pillar.example b/pillar.example index b95d65c..0d294cf 100644 --- a/pillar.example +++ b/pillar.example @@ -41,6 +41,9 @@ postgres: # # The uppercase items must be replaced by actual values. # METHOD could be omitted, 'md5' will be appended by default. + # + # If ``acls`` item value is empty ('', [], null), then the contents of + # ``pg_hba.conf`` file will not be touched at all. acls: - ['local', 'db1', 'localUser'] - ['host', 'db2', 'remoteUser', '192.168.33.0/24'] @@ -52,7 +55,7 @@ postgres: # If Salt is unable to detect init system running in the scope of state run, # probably we are trying to bake a container/VM image with PostgreSQL. - # Use ``bake_image`` setting to contol how PostgreSQL will be started: if set + # Use ``bake_image`` setting to control how PostgreSQL will be started: if set # to ``True`` the raw ``pg_ctl`` will be utilized instead of packaged init # script, job or unit run with Salt ``service`` state. bake_image: True @@ -62,7 +65,7 @@ postgres: # Create/remove users, tablespaces, databases, schema and extensions. # Each of these dictionaries contains PostgreSQL entities which # mapped to the ``postgres_*`` Salt states with arguments. See the Salt - # documentaion to get all supported argument for a particular state. + # documentation to get all supported argument for a particular state. # # Format is the following: # diff --git a/postgres/server/init.sls b/postgres/server/init.sls index 0c23ab3..91fe11d 100644 --- a/postgres/server/init.sls +++ b/postgres/server/init.sls @@ -93,13 +93,17 @@ postgresql-conf: postgresql-pg_hba: file.managed: - name: {{ postgres.conf_dir }}/pg_hba.conf - - source: {{ postgres['pg_hba.conf'] }} - - template: jinja - user: {{ postgres.user }} - group: {{ postgres.group }} - mode: 600 +{%- if postgres.acls %} + - source: {{ postgres['pg_hba.conf'] }} + - template: jinja - defaults: acls: {{ postgres.acls }} +{%- else %} + - replace: False +{%- endif %} - require: - file: postgresql-config-dir