From 3e20211d7261059b589543440d5bbbee8ee11654 Mon Sep 17 00:00:00 2001 From: "Matthew X. Economou" Date: Sun, 11 Sep 2016 06:09:59 -0400 Subject: [PATCH 1/2] Feature setting the template context from the mysql:schema pillar This simplifies how schema files can be templated, especially when using the same template to set up multiple databases on the same server. --- mysql/database.sls | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql/database.sls b/mysql/database.sls index e077db8..72106a9 100644 --- a/mysql/database.sls +++ b/mysql/database.sls @@ -30,8 +30,10 @@ include: - name: /etc/mysql/{{ database }}.schema - source: {{ salt['pillar.get'](['mysql', 'schema', database, 'source']|join(':')) }} {%- set template_type = salt['pillar.get'](['mysql', 'schema', database, 'template']|join(':'), False) %} +{%- set template_context = salt['pillar.get'](['mysql', 'schema', database, 'context']|join(':'), {}) %} {%- if template_type %} - template: {{ template_type }} + - context: {{ template_context|yaml }} {% endif %} - user: {{ salt['pillar.get']('mysql:server:user', 'mysql') }} - makedirs: True From 0611f52616947ec8557d14da8b22b315f96bcbfc Mon Sep 17 00:00:00 2001 From: "Matthew X. Economou" Date: Sun, 11 Sep 2016 06:25:16 -0400 Subject: [PATCH 2/2] Add two examples of using the template context --- pillar.example | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pillar.example b/pillar.example index 70801ef..0dedba8 100644 --- a/pillar.example +++ b/pillar.example @@ -55,6 +55,20 @@ mysql: load: True source: salt://mysql/files/baz.schema.tmpl template: jinja + qux: + load: True + source: salt://mysql/files/qux.schema.tmpl + template: jinja + context: + encabulator: Turbo + girdlespring: differential + quux: + load: True + source: salt://mysql/files/qux.schema.tmpl + template: jinja + context: + encabulator: Retro + girdlespring: integral # Manage users # you can get pillar for existing server using scripts/import_users.py script