Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(tpldir): use tpldir or derivatives to make formula portable #46

Merged
merged 1 commit into from
Feb 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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