mirror of
https://github.com/saltstack-formulas/template-formula.git
synced 2025-04-17 10:10:28 +00:00
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`.
This commit is contained in:
parent
31e1096add
commit
fc90075dd9
2 changed files with 31 additions and 0 deletions
13
TEMPLATE/_mapdata/_mapdata.jinja
Normal file
13
TEMPLATE/_mapdata/_mapdata.jinja
Normal file
|
@ -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
|
||||
}}
|
18
TEMPLATE/_mapdata/init.sls
Normal file
18
TEMPLATE/_mapdata/init.sls
Normal file
|
@ -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 }}
|
Loading…
Add table
Reference in a new issue