diff --git a/pillar.example b/pillar.example index 6eee62a..27aab2a 100644 --- a/pillar.example +++ b/pillar.example @@ -34,3 +34,8 @@ postgres: template: 'template0' lc_ctype: 'C.UTF-8' lc_collate: 'C.UTF-8' + + # This section will append your configuration to postgresql.conf. + postgresconf: | + listen_addresses = 'localhost,*' + diff --git a/postgres/init.sls b/postgres/init.sls index 6ba093c..6ba5eb4 100644 --- a/postgres/init.sls +++ b/postgres/init.sls @@ -23,6 +23,19 @@ libpq-dev: python-dev: pkg.installed +{% if 'postgresconf' in pillar.get('postgres', {}) %} +postgresql-conf: + file.blockreplace: + - name: {{ postgres.conf_dir }}/postgresql.conf + - marker_start: "# Managed by SaltStack: listen_addresses: please do not edit" + - marker_end: "# Managed by SaltStack: end of salt managed zone --" + - content: {{ salt['pillar.get']('postgres:postgresconf') }} + - show_changes: True + - append_if_not_found: True + - watch_in: + - service: postgresql +{% endif %} + {% if 'pg_hba.conf' in pillar.get('postgres', {}) %} pg_hba.conf: file.managed: @@ -38,6 +51,7 @@ pg_hba.conf: - service: postgresql {% endif %} + {% if 'users' in pillar.get('postgres', {}) %} {% for name, user in salt['pillar.get']('postgres:users').items() %} postgres-user-{{ name }}: @@ -70,3 +84,4 @@ postgres-db-{{ name }}: {% endif %} {% endfor%} {% endif %} + diff --git a/postgres/map.jinja b/postgres/map.jinja index 85d932c..fbf5473 100644 --- a/postgres/map.jinja +++ b/postgres/map.jinja @@ -4,15 +4,24 @@ 'python': 'python-pygresql', 'service': 'postgresql', 'pg_hba': '/etc/postgresql/9.1/main/pg_hba.conf', + 'conf_dir': '/etc/postgresql/9.1/main', }, 'RedHat': { 'pkg': 'postgresql', 'python': 'postgresql-python', 'service': 'postgresql', + 'conf_dir': '/var/lib/pgsql/data', }, 'Arch': { 'pkg': 'postgresql', 'python': 'python-psycopg2', 'service': 'postgresql', + 'conf_dir': '/var/lib/pgsql/data', }, -}, merge=salt['pillar.get']('postgres:lookup')) %} +}, merge=salt['grains.filter_by']({ + '14.04': { + 'pkg': 'postgresql', + 'pkg_dev': 'postgresql-server-dev-9.3', + 'conf_dir': '/etc/postgresql/9.3/main', + }, +}, grain='lsb_distrib_release', merge=salt['pillar.get']('postgres:lookup'))) %}