-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #284 from myii/feat/use-top-level_values_for-map.j…
…inja-dump-files feat(_mapdata): use top-level `values` for `map.jinja` dump files
- Loading branch information
Showing
5 changed files
with
68 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,34 @@ | ||
${ '# -*- coding: utf-8 -*-' } | ||
${ '# vim: ft=sls' } | ||
${ "# -*- coding: utf-8 -*-" } | ||
${ "# vim: ft=sls" } | ||
--- | ||
{#- Get the `tplroot` from `tpldir` #} | ||
{%- set tplroot = tpldir.split('/')[0] %} | ||
<% filename = map_jinja['filename'] %>\ | ||
<% import_var = map_jinja['verification']['import'] %>\ | ||
<% import_var_as = '' if import_var == 'mapdata' else ' as mapdata' %>\ | ||
{%- from tplroot ~ "/${ filename }" import ${ import_var }${ import_var_as } with context %} | ||
{%- set tplroot = tpldir.split("/")[0] %} | ||
<% filename = map_jinja["filename"] %>\ | ||
<% import_vars = map_jinja["verification"]["import"] %>\ | ||
% for import_var in import_vars: | ||
{%- from tplroot ~ "/${ filename }" import ${ import_var } with context %} | ||
% endfor | ||
{%- do salt['log.debug']('### MAP.JINJA DUMP ###\n' ~ mapdata | yaml(False)) %} | ||
{%- set _mapdata = { | ||
% if map_jinja["version"] > 3: | ||
"values": mapdata, | ||
% else: | ||
"values": { | ||
% for import_var in import_vars: | ||
"${ import_var }": ${ import_var }, | ||
% endfor | ||
} | ||
% endif | ||
} %} | ||
{%- do salt["log.debug"]("### MAP.JINJA DUMP ###\n" ~ _mapdata | yaml(False)) %} | ||
{%- set output_dir = '/temp' if grains.os_family == 'Windows' else '/tmp' %} | ||
{%- set output_file = output_dir ~ '/salt_mapdata_dump.yaml' %} | ||
{%- set output_dir = "/temp" if grains.os_family == "Windows" else "/tmp" %} | ||
{%- set output_file = output_dir ~ "/salt_mapdata_dump.yaml" %} | ||
{{ tplroot }}-mapdata-dump: | ||
file.managed: | ||
- name: {{ output_file }} | ||
- source: salt://{{ tplroot }}/_mapdata/_mapdata.jinja | ||
- template: jinja | ||
- context: | ||
map: {{ mapdata | yaml }} | ||
map: {{ _mapdata | yaml }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters