-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(map): generate a YAML file to validate
map.jinja
We provide a new `_mapdata` state which generate a `/tmp/salt_mapdata_dump.yaml` to be validated by `Inspec`.
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# yamllint disable rule:indentation rule:line-length | ||
# {{ grains.get('osfinger', grains.os) }} | ||
--- | ||
{#- use salt.slsutil.serialize to avoid encoding errors on some platforms #} | ||
{{ salt['slsutil.serialize']( | ||
'yaml', | ||
map, | ||
default_flow_style=False, | ||
allow_unicode=True, | ||
) | ||
| regex_replace("^\s+'$", "'", multiline=True) | ||
| trim | ||
}} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
--- | ||
{#- Get the `tplroot` from `tpldir` #} | ||
{%- set tplroot = tpldir.split('/')[0] %} | ||
{%- from tplroot ~ "/map.jinja" import TEMPLATE as mapdata with context %} | ||
{%- do salt['log.debug']('### MAP.JINJA DUMP ###\n' ~ mapdata | yaml(False)) %} | ||
{%- set output_file = '/tmp/salt_mapdata_dump.yaml' %} | ||
{{ tplroot }}-mapdata-dump: | ||
file.managed: | ||
- name: {{ output_file }} | ||
- source: salt://{{ tplroot }}/_mapdata/_mapdata.jinja | ||
- template: jinja | ||
- context: | ||
map: {{ mapdata | yaml }} |