Commit graph

5 commits

Author SHA1 Message Date
Daniel Dehennin
42e19322c9 feat(map): update to v5 map.jinja
The v5 `map.jinja` is a generic and configurable system to load
configuration values, exposed as the `mapdata` variable, from
different places:

- YAML files and templates from the fileserver for non-secret data
- pillars or SDB are preferred for secret data
- grains or `config.get`

The `map.jinja` optional sources are configured with compound targeting like
syntax `[<TYPE>[:<OPTION>[:<DELIMITER>]]@]<KEY>` with the following
default ordered sources:

- `Y:G@osarch`: YAML file and Jinja template named after `osarch` grain
- `Y:G@os_family`: YAML file and Jinja template named after `os_family` grain
- `Y:G@os` YAML file and Jinja template named after `os` grain
- `Y:G@osfinger` YAML file and Jinja template named after `osfinger` grain
- `C@{{ tplroot ~ ':lookup' }}`: dict retrieved with `salt["config.get"]`
- `C@{{ tplroot }}`: dict retrieved with `salt["config.get"]`
- `Y:G@id`: YAML file and Jinja template named after `osarch` grain

This is done by two new libraries:

- `libmatchers.jinja` provides the `parse_matchers` macro to parse
  strings looking like compound matchers, for example `Y:G@osarch`

- `libmapstack.jinja` provides the `mapstack` macro to load
  configuration from different sources described by matchers

Post-processing of `mapdata` variable can be done in a `parameters/post-map.jinja`.

The v5 `map.jinja` is documented in `docs/map.jinja.rst`.

BREAKING CHANGE: `map.jinja` now exports a generic `mapdata` variable

BREAKING CHANGE: The per grain parameter values are now under `TEMPLATE/parameters/`
2021-02-16 11:10:09 +01:00
Daniel Dehennin
bcb8e29b68
fix(_mapdata): ensure map data is directly under values
* Semi-automated using https://github.com/myii/ssf-formula/pull/287
2021-01-14 20:35:51 +00:00
Imran Iqbal
f8e8fcb29e
refactor(map): use top-level values: key in map.jinja dumps
* Semi-automated using https://github.com/myii/ssf-formula/pull/284
2020-12-23 18:44:04 +00:00
Imran Iqbal
4c8cf32db1
test(map): standardise map.jinja verification
* Automated using https://github.com/myii/ssf-formula/pull/281
2020-12-22 00:43:16 +00:00
Daniel Dehennin
fc90075dd9 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`.
2020-09-03 16:29:10 +02:00