Skip to content

Instantly share code, notes, and snippets.

Created September 20, 2017 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/52390f4432511dfc57fc88f3684fcbd4 to your computer and use it in GitHub Desktop.
Save anonymous/52390f4432511dfc57fc88f3684fcbd4 to your computer and use it in GitHub Desktop.
# map.jinja
###########
# vim: ft=jinja
# This file handles the merging of pillar data with the data from defaults
{# Start with defaults from defaults.yml #}
{% import_yaml 'liquibase/defaults.yml' as default_settings %}
{#
Setup variable using grains['os_family'] based logic, only add key:values here
that differ from whats in defaults.yml
#}
{% set os_family_map = salt['grains.filter_by']({
'Debian': {},
'Suse': {},
'Arch': {},
'RedHat': {},
}
, grain="os_family"
, merge=salt['pillar.get']('liquibase:lookup'))
%}
{# Merge the flavor_map to the default settings #}
{% do default_settings.liquibase.update(os_family_map) %}
{# Merge in template:lookup pillar #}
{% set liquibase = salt['pillar.get'](
'liquibase',
default=default_settings.liquibase,
merge=True
)
%}
{#
Computed variables should go here
#}
{% set liquibase.install_path = '{0}/liquibase-{1}'.format(liquibase.install_root, liquibase.version) %}
{% if 'postgres' in liquibase.get('jdbc_drivers', {}) %}
{% set liquibase.jdbc_drivers.postgres.postgres_jar = salt.file.basename(liquibase.jdbc_drivers.postgres.url) %}
{% endif %}
# error
#######
minion_50:
Data failed to compile:
----------
Rendering SLS 'base:liquibase' failed: Jinja syntax error: expected token 'end of statement block', got '.'
/var/cache/salt/minion/files/base/liquibase/map.jinja(36):
---
[...]
{#
Computed variables should go here
#}
{% set liquibase.install_path = '{0}/liquibase-{1}'.format(liquibase.install_root, liquibase.version) %} <======================
{% if 'postgres' in liquibase.get('jdbc_drivers', {}) %}
{% set liquibase.jdbc_drivers.postgres.postgres_jar = salt.file.basename(liquibase.jdbc_drivers.postgres.url) %}
{% endif %}
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment