saltstack template

 https://github.com/saltstack-formulas/template-formula

tree

.
├── CHANGELOG.rst
├── LICENSE
├── README.rst
├── pillar.example
└── template
    ├── config.sls
    ├── defaults.yaml
    ├── init.sls
    ├── install.sls
    ├── map.jinja
    └── service.sls

pillar.example

template:
  lookup:
    master: template-master

defaults.yaml

# -*- coding: utf-8 -*-
# vim: ft=yaml
template:
  pkg: template
  config: '/etc/template'
  service:
    name: template

map.jinja

# -*- coding: utf-8 -*-
# vim: ft=jinja
{## Start with  defaults from defaults.sls ##}
{% import_yaml 'template/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 os_family_map = salt['grains.filter_by']({
        'Debian': {},
        'Suse': {},
        'Arch': {
            "pkg" : 'template-arch',
        },
        'RedHat': {
            "config": '/etc/template.conf',
        },
  }
  , grain="os_family"
  , merge=salt['pillar.get']('template:lookup'))
%}
{## Merge the flavor_map to the default settings ##}
{% do default_settings.template.update(os_family_map) %}
{## Merge in template:lookup pillar ##}
{% set template = salt['pillar.get'](
        'template',
        default=default_settings.template,
        merge=True
    )
%}

init.sls

# -*- coding: utf-8 -*-
# vim: ft=sls
include:
  - template.install
  - template.config
  - template.service

install.sls

# -*- coding: utf-8 -*-
# vim: ft=sls
{% from "template/map.jinja" import template with context %}
template-pkg:
  pkg.installed:
    - name: {{ template.pkg }}

config.sls

# -*- coding: utf-8 -*-
# vim: ft=sls
{% from "template/map.jinja" import template with context %}
template-config:
  file.managed:
    - name: {{ template.config }}
    - source: salt://template/files/example.tmpl
    - mode: 644
    - user: root
    - group: root

service.sls

# -*- coding: utf-8 -*-
# vim: ft=sls
{% from "template/map.jinja" import template with context %}
template-name:
  service.running:
    - name: {{ template.service.name }}
    - enable: True