Switch to new style map.jinja

Move this formula to the new style map.jinja. Still need to sort out RedHat
handling, but it's not any worse than it was before (i.e. horribly broken)
This commit is contained in:
Brian Jackson
2015-04-22 17:47:02 -05:00
parent 98bb44df47
commit 967fa6504b
8 changed files with 81 additions and 83 deletions

View File

@@ -1,6 +1,6 @@
{% from "postgres/map.jinja" import postgres with context %}
{% if salt['pillar.get']('postgres:use_upstream_repo') %}
{% if postgres.use_upstream_repo %}
include:
- postgres.upstream
{% endif %}
@@ -8,7 +8,7 @@ include:
install-postgresql:
pkg.installed:
- name: {{ postgres.pkg }}
- refresh: {{ salt['pillar.get']('postgres:use_upstream_repo', False) }}
- refresh: {{ postgres.use_upstream_repo }}
{% if postgres.create_cluster != False %}
create-postgresql-cluster:
@@ -57,25 +57,24 @@ install-postgres-contrib:
- name: {{ postgres.pkg_contrib }}
{% endif %}
{% if 'postgresconf' in pillar.get('postgres', {}) %}
{% if postgres.postgresconf %}
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') | indent(8) }}
{{ postgres.postgresconf|indent(8) }}
- 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:
- name: {{ postgres.conf_dir }}/pg_hba.conf
- source: {{ salt['pillar.get']('postgres:pg_hba.conf', 'salt://postgres/pg_hba.conf') }}
- source: {{ postgres['pg_hba.conf'] }}
- template: jinja
- user: postgres
- group: postgres
@@ -84,37 +83,32 @@ pg_hba.conf:
- pkg: {{ postgres.pkg }}
- watch_in:
- service: postgresql
{% endif %}
{% if 'users' in pillar.get('postgres', {}) %}
{% for name, user in salt['pillar.get']('postgres:users').items() %}
{% for name, user in postgres.users.items() %}
postgres-user-{{ name }}:
postgres_user.present:
- name: {{ name }}
- createdb: {{ salt['pillar.get']('postgres:users:' + name + ':createdb', False) }}
- password: {{ salt['pillar.get']('postgres:users:' + name + ':password', 'changethis') }}
- runas: postgres
- createdb: {{ user.get('createdb', False) }}
- password: {{ user.get('password', 'changethis') }}
- user: {{ user.get('runas', 'postgres') }}
- require:
- service: {{ postgres.service }}
{% endfor%}
{% endif %}
{% if 'databases' in pillar.get('postgres', {}) %}
{% for name, db in salt['pillar.get']('postgres:databases').items() %}
{% for name, db in postgres.databases.items() %}
postgres-db-{{ name }}:
postgres_database.present:
- name: {{ name }}
- encoding: {{ salt['pillar.get']('postgres:databases:'+ name +':encoding', 'UTF8') }}
- lc_ctype: {{ salt['pillar.get']('postgres:databases:'+ name +':lc_ctype', 'en_US.UTF8') }}
- lc_collate: {{ salt['pillar.get']('postgres:databases:'+ name +':lc_collate', 'en_US.UTF8') }}
- template: {{ salt['pillar.get']('postgres:databases:'+ name +':template', 'template0') }}
{% if salt['pillar.get']('postgres:databases:'+ name +':owner') %}
- owner: {{ salt['pillar.get']('postgres:databases:'+ name +':owner') }}
- encoding: {{ db.get('encoding', 'UTF8') }}
- lc_ctype: {{ db.get('lc_ctype', 'en_US.UTF8') }}
- lc_collate: {{ db.get('lc_collate', 'en_US.UTF8') }}
- template: {{ db.get('template', 'template0') }}
{% if db.get('owner') %}
- owner: {{ db.get('owner') }}
{% endif %}
- runas: {{ salt['pillar.get']('postgres:databases:'+ name +':runas', 'postgres') }}
{% if salt['pillar.get']('postgres:databases:'+ name +':user') %}
- user: {{ db.get('runas', 'postgres') }}
{% if db.get('user') %}
- require:
- postgres_user: postgres-user-{{ salt['pillar.get']('postgres:databases:'+ name +':user') }}
- postgres_user: postgres-user-{{ db.get('user') }}
{% endif %}
{% endfor%}
{% endif %}