From 494fe89d26ba4698b39d5901190544d0fe43d040 Mon Sep 17 00:00:00 2001 From: Georgiy Kutsurua Date: Sat, 16 Dec 2017 22:49:01 +0400 Subject: [PATCH] Add hba & servers settings control --- README.rst | 24 +++++++++++++++++++++ postgresql/files/8.4/postgresql.conf.Debian | 5 +++++ postgresql/files/8.4/postgresql.conf.RedHat | 5 +++++ postgresql/files/9.1/postgresql.conf.Debian | 5 +++++ postgresql/files/9.3/postgresql.conf.Debian | 5 +++++ postgresql/files/9.4/postgresql.conf.Debian | 5 +++++ postgresql/files/9.5/postgresql.conf.Debian | 5 +++++ postgresql/files/9.6/postgresql.conf.Debian | 5 +++++ postgresql/files/pg_hba.conf | 5 +++++ tests/pillar/postgresql_server.sls | 6 ++++++ 10 files changed, 70 insertions(+) diff --git a/README.rst b/README.rst index 60738f8..8deba66 100644 --- a/README.rst +++ b/README.rst @@ -43,6 +43,30 @@ Single database server with empty database host: 'localhost' rights: 'all privileges' +With custom settings + +.. code-block:: yaml + + postgresql: + server: + ... + settings: + max_connections: 300 + timezone: "'UTC'" + ... + +With custom hba records + +.. code-block:: yaml + + postgresql: + server: + ... + hba_records: + - 'host all all 192.168.0.101/32 trust' + - 'host all all 0.0.0.0/0 md5' + ... + Single database server with initial data .. code-block:: yaml diff --git a/postgresql/files/8.4/postgresql.conf.Debian b/postgresql/files/8.4/postgresql.conf.Debian index baef22a..d6df7e1 100644 --- a/postgresql/files/8.4/postgresql.conf.Debian +++ b/postgresql/files/8.4/postgresql.conf.Debian @@ -1,4 +1,5 @@ {%- from "postgresql/map.jinja" import server with context -%} +{%- set settings = server.get('settings', {}) -%} # ----------------------------- # PostgreSQL configuration file # ----------------------------- @@ -561,3 +562,7 @@ default_text_search_config = 'pg_catalog.english' #------------------------------------------------------------------------------ #custom_variable_classes = '' # list of custom variable class names + +{%- for k, v in settings.items() %} +{{ k }} = {{ v }} +{%- endfor %} diff --git a/postgresql/files/8.4/postgresql.conf.RedHat b/postgresql/files/8.4/postgresql.conf.RedHat index f3b3ef2..bb22008 100644 --- a/postgresql/files/8.4/postgresql.conf.RedHat +++ b/postgresql/files/8.4/postgresql.conf.RedHat @@ -1,4 +1,5 @@ {%- from "postgresql/map.jinja" import server with context -%} +{%- set settings = server.get('settings', {}) -%} # ----------------------------- # PostgreSQL configuration file # ----------------------------- @@ -507,3 +508,7 @@ default_text_search_config = 'pg_catalog.english' #------------------------------------------------------------------------------ #custom_variable_classes = '' # list of custom variable class names + +{%- for k, v in settings.items() %} +{{ k }} = {{ v }} +{%- endfor %} diff --git a/postgresql/files/9.1/postgresql.conf.Debian b/postgresql/files/9.1/postgresql.conf.Debian index 02f65c9..4a976cf 100644 --- a/postgresql/files/9.1/postgresql.conf.Debian +++ b/postgresql/files/9.1/postgresql.conf.Debian @@ -1,4 +1,5 @@ {%- from "postgresql/map.jinja" import server with context -%} +{%- set settings = server.get('settings', {}) -%} # ----------------------------- # PostgreSQL configuration file # ----------------------------- @@ -561,3 +562,7 @@ default_text_search_config = 'pg_catalog.english' #------------------------------------------------------------------------------ #custom_variable_classes = '' # list of custom variable class names + +{%- for k, v in settings.items() %} +{{ k }} = {{ v }} +{%- endfor %} diff --git a/postgresql/files/9.3/postgresql.conf.Debian b/postgresql/files/9.3/postgresql.conf.Debian index 45eb96c..519c8eb 100644 --- a/postgresql/files/9.3/postgresql.conf.Debian +++ b/postgresql/files/9.3/postgresql.conf.Debian @@ -1,4 +1,5 @@ {%- from "postgresql/map.jinja" import server with context -%} +{%- set settings = server.get('settings', {}) -%} # ----------------------------- # PostgreSQL configuration file # ----------------------------- @@ -596,3 +597,7 @@ default_text_search_config = 'pg_catalog.english' #------------------------------------------------------------------------------ # Add settings for extensions here + +{%- for k, v in settings.items() %} +{{ k }} = {{ v }} +{%- endfor %} diff --git a/postgresql/files/9.4/postgresql.conf.Debian b/postgresql/files/9.4/postgresql.conf.Debian index e43fc6f..5cb55cc 100644 --- a/postgresql/files/9.4/postgresql.conf.Debian +++ b/postgresql/files/9.4/postgresql.conf.Debian @@ -1,4 +1,5 @@ {%- from "postgresql/map.jinja" import server, cluster with context -%} +{%- set settings = server.get('settings', {}) -%} # ----------------------------- # PostgreSQL configuration file # ----------------------------- @@ -624,3 +625,7 @@ default_text_search_config = 'pg_catalog.english' #------------------------------------------------------------------------------ # Add settings for extensions here + +{%- for k, v in settings.items() %} +{{ k }} = {{ v }} +{%- endfor %} diff --git a/postgresql/files/9.5/postgresql.conf.Debian b/postgresql/files/9.5/postgresql.conf.Debian index 1dee134..6fdaeae 100644 --- a/postgresql/files/9.5/postgresql.conf.Debian +++ b/postgresql/files/9.5/postgresql.conf.Debian @@ -1,4 +1,5 @@ {%- from "postgresql/map.jinja" import server, cluster with context -%} +{%- set settings = server.get('settings', {}) -%} # ----------------------------- # PostgreSQL configuration file # ----------------------------- @@ -645,3 +646,7 @@ default_text_search_config = 'pg_catalog.english' #------------------------------------------------------------------------------ # Add settings for extensions here + +{%- for k, v in settings.items() %} +{{ k }} = {{ v }} +{%- endfor %} diff --git a/postgresql/files/9.6/postgresql.conf.Debian b/postgresql/files/9.6/postgresql.conf.Debian index e0fce11..32c639c 100644 --- a/postgresql/files/9.6/postgresql.conf.Debian +++ b/postgresql/files/9.6/postgresql.conf.Debian @@ -1,4 +1,5 @@ {%- from "postgresql/map.jinja" import server, cluster with context -%} +{%- set settings = server.get('settings', {}) -%} # ----------------------------- # PostgreSQL configuration file # ----------------------------- @@ -665,3 +666,7 @@ default_text_search_config = 'pg_catalog.english' #------------------------------------------------------------------------------ # Add settings for extensions here + +{%- for k, v in settings.items() %} +{{ k }} = {{ v }} +{%- endfor %} diff --git a/postgresql/files/pg_hba.conf b/postgresql/files/pg_hba.conf index a1f1eb8..d07b639 100644 --- a/postgresql/files/pg_hba.conf +++ b/postgresql/files/pg_hba.conf @@ -1,4 +1,5 @@ {%- from "postgresql/map.jinja" import server, cluster with context -%} +{%- set hba_records = server.get('hba_records', []) -%} # PostgreSQL Client Authentication Configuration File # =================================================== # @@ -129,3 +130,7 @@ host all all ::1/128 md5 #host replication postgres ::1/128 md5 {%- endif %} + +{%- for record in hba_records %} +{{ record }} +{%- endfor %} diff --git a/tests/pillar/postgresql_server.sls b/tests/pillar/postgresql_server.sls index 0cf7f27..ba39a5b 100644 --- a/tests/pillar/postgresql_server.sls +++ b/tests/pillar/postgresql_server.sls @@ -18,3 +18,9 @@ postgresql: host: localhost createdb: true rights: all privileges + settings: + max_connections: 300 + timezone: "'UTC'" + hba_records: + - 'host all all 192.168.0.101/32 trust' + - 'host all all 0.0.0.0/0 md5'