2017-08-24 11:21:48 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: ft=jinja
|
|
|
|
|
|
|
|
{%- macro deep_merge(a, b) %}
|
|
|
|
{#- This whole `'dict' in x.__class__.__name__` mess is a
|
|
|
|
workaround for the missing mapping test in CentOS 6's
|
|
|
|
ancient Jinja2, see #193 #}
|
|
|
|
{%- for k,v in b.iteritems() %}
|
|
|
|
{%- if v is string or v is number %}
|
|
|
|
{%- do a.update({ k: v }) %}
|
|
|
|
{%- elif 'dict' not in v.__class__.__name__ %}
|
|
|
|
{%- if a[k] is not defined %}
|
|
|
|
{%- do a.update({ k: v }) %}
|
|
|
|
{%- elif a[k] is iterable and 'dict' not in a[k].__class__.__name__ and
|
|
|
|
a[k] is not string %}
|
|
|
|
{%- do a.update({ k: v|list + a[k]|list}) %}
|
|
|
|
{%- else %}
|
|
|
|
{%- do a.update({ k: v }) %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- elif 'dict' in v.__class__.__name__ %}
|
|
|
|
{%- if a[k] is not defined %}
|
|
|
|
{%- do a.update({ k: v }) %}
|
|
|
|
{%- elif 'dict' in a[k].__class__.__name__ %}
|
|
|
|
{%- do a.update({ k: v }) %}
|
|
|
|
{%- else %}
|
|
|
|
{%- do deep_merge(a[k], v) %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- else %}
|
|
|
|
{%- do a.update({ k: 'ERROR: case not contempled in merging!' }) %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endmacro %}
|
|
|
|
|
|
|
|
|
|
|
|
{## Start with defaults from defaults.yaml ##}
|
|
|
|
{% import_yaml "postfix/defaults.yaml" as default_settings %}
|
|
|
|
|
|
|
|
{##
|
|
|
|
Setup variable using grains['os_family'] based logic, only add key:values here
|
|
|
|
that differ from whats in defaults.yaml
|
|
|
|
##}
|
|
|
|
{% set osrelease = salt['grains.get']('osrelease') %}
|
|
|
|
{# set salt_release = salt['pillar.get']('salt:release', 'latest') #}
|
|
|
|
{# set postfix = salt['grains.filter_by'](#}
|
|
|
|
{% set os_family_map = salt['grains.filter_by']({
|
2015-02-26 16:19:08 +01:00
|
|
|
'Debian': {
|
2015-08-22 13:59:29 +02:00
|
|
|
'policyd_spf_pkg': 'postfix-policyd-spf-python',
|
2016-05-24 11:49:28 +02:00
|
|
|
'pcre_pkg': 'postfix-pcre',
|
|
|
|
'mysql_pkg': 'postfix-mysql',
|
2015-02-26 16:19:08 +01:00
|
|
|
},
|
|
|
|
'Gentoo': {
|
2015-08-22 12:46:35 +02:00
|
|
|
'package': 'mail-mta/postfix',
|
2015-08-22 13:59:29 +02:00
|
|
|
'policyd_spf_pkg': 'mail-filter/pypolicyd-spf',
|
2015-08-22 12:40:09 +02:00
|
|
|
'postgrey_pkg': 'mail-filter/postgrey',
|
2017-08-24 11:21:48 +02:00
|
|
|
'postsrsd_pkg': 'mail-filter/postsrsd',
|
2015-08-27 16:11:22 +02:00
|
|
|
'aliases_file': '/etc/mail/aliases',
|
2015-02-26 16:19:08 +01:00
|
|
|
},
|
2015-03-13 13:26:27 +01:00
|
|
|
'RedHat': {
|
2015-08-22 13:59:29 +02:00
|
|
|
'policyd_spf_pkg': 'pypolicyd-spf',
|
2015-03-13 13:26:27 +01:00
|
|
|
},
|
2015-05-03 03:01:09 +02:00
|
|
|
'Arch' : {
|
2015-08-22 13:59:29 +02:00
|
|
|
'policyd_spf_pkg': 'python-postfix-policyd-spf',
|
2015-05-03 03:01:09 +02:00
|
|
|
},
|
2015-02-26 16:19:08 +01:00
|
|
|
}, merge=salt['pillar.get']('postfix:lookup')) %}
|
2017-08-24 11:21:48 +02:00
|
|
|
|
|
|
|
{## Merge the flavor_map to the default settings ##}
|
|
|
|
{% do deep_merge(default_settings.postfix, os_family_map) %}
|
|
|
|
|
|
|
|
{## Merge in postfix:lookup pillar ##}
|
|
|
|
{% set postfix = salt['pillar.get'](
|
|
|
|
'postfix',
|
|
|
|
default=default_settings.postfix,
|
|
|
|
merge=True)
|
|
|
|
%}
|