Skip to content

Commit

Permalink
refactor(tpldir): use tpldir or derivatives to make formula portable
Browse files Browse the repository at this point in the history
  • Loading branch information
myii committed Feb 24, 2019
1 parent c246939 commit 52d03d8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions template/config.sls
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{%- from "template/map.jinja" import template with context %}
{%- from "template/macros.jinja" import files_switch with context %}
{%- from tpldir ~ "/map.jinja" import template with context %}
{%- from tpldir ~ "/macros.jinja" import files_switch with context %}
include:
- template.install
Expand Down
2 changes: 1 addition & 1 deletion template/install.sls
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{% from "template/map.jinja" import template with context %}
{%- from tpldir ~ "/map.jinja" import template with context %}
template-pkg:
pkg.installed:
Expand Down
14 changes: 8 additions & 6 deletions template/map.jinja
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# -*- coding: utf-8 -*-
# vim: ft=jinja

{## Start imports as ##}
{% import_yaml 'template/defaults.yaml' as default_settings %}
{% import_yaml 'template/osfamilymap.yaml' as osfamilymap %}
{% import_yaml 'template/osmap.yaml' as osmap %}
{% import_yaml 'template/osfingermap.yaml' as osfingermap %}
{#- Get the `topdir` from `tpldir` #}
{%- set topdir = tpldir.split('/')[0] %}
{#- Start imports as #}
{%- import_yaml topdir ~ "/defaults.yaml" as default_settings %}
{%- import_yaml topdir ~ "/osfamilymap.yaml" as osfamilymap %}
{%- import_yaml topdir ~ "/osmap.yaml" as osmap %}
{%- import_yaml topdir ~ "/osfingermap.yaml" as osfingermap %}

{% set defaults = salt['grains.filter_by'](default_settings,
default='template',
Expand All @@ -18,5 +20,5 @@
)
) %}

{## Merge the template pillar ##}
{#- Merge the template pillar #}
{% set template = salt['pillar.get']('template', default=defaults, merge=True) %}
2 changes: 1 addition & 1 deletion template/service.sls
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{% from "template/map.jinja" import template with context %}
{%- from tpldir ~ "/map.jinja" import template with context %}
include:
- template.config
Expand Down

0 comments on commit 52d03d8

Please sign in to comment.