template-formula/pillar.example
Daniel Dehennin c4440d7c55 feat(sub-component): manage a dedicated configuration file
* pillar.example (template.subcomponent): configurable sub-component
  destination.
  (template.tofs.source_files): override sub-component template

* template/init.sls (include): setup sub-component last.

* template/clean.sls (include): clean sub-component first.

* template/subcomponent/init.sls: include the only setup state
  “config”.

* template/subcomponent/config/init.sls: include the only config state
  “file”.

* template/subcomponent/config/file.sls: manage the sub-component
  configuration file. It requires the main component configuration.

* template/subcomponent/files/default/subcomponent-example.tmpl.jinja:
  jinja template for the sub-component.

* template/subcomponent/files/default/subcomponent-example.tmpl:
  static configuration for the sub-component.

* template/subcomponent/clean.sls: include the only cleanup state “config”.

* template/subcomponent/config/clean.sls: remove the sub-component
  configuration file.
2019-07-30 16:17:39 +02:00

65 lines
1.9 KiB
YAML

# -*- coding: utf-8 -*-
# vim: ft=yaml
---
template:
lookup:
master: template-master
# Just for testing purposes
winner: lookup
added_in_lookup: lookup_value
# Using bash package and udev service as an example. This allows us to
# test the template formula itself. You should set these parameters to
# examples that make sense in the contexto of the formula you're writing.
{%- if grains.osfinger == 'CentOS-6' %}
pkg:
name: cronie
service:
name: crond
{%- else %}
pkg:
name: bash
service:
name: systemd-udevd
{%- endif %}
config: /etc/template-formula.conf
subcomponent:
config: /etc/template-subcomponent-formula.conf
tofs:
# The files_switch key serves as a selector for alternative
# directories under the formula files directory. See TOFS pattern
# doc for more info.
# Note: Any value not evaluated by `config.get` will be used literally.
# This can be used to set custom paths, as many levels deep as required.
files_switch:
- any/path/can/be/used/here
- id
- roles
- osfinger
- os
- os_family
# All aspects of path/file resolution are customisable using the options below.
# This is unnecessary in most cases; there are sensible defaults.
# path_prefix: template_alt
# dirs:
# files: files_alt
# default: default_alt
# The entries under `source_files` are prepended to the default source files
# given for the state
# source_files:
# template-config-file-file-managed:
# - 'example_alt.tmpl'
# - 'example_alt.tmpl.jinja'
# For testing purposes
source_files:
template-config-file-file-managed:
- 'example.tmpl.jinja'
template-subcomponent-config-file-file-managed:
- 'subcomponent-example.tmpl.jinja'
# Just for testing purposes
winner: pillar
added_in_pillar: pillar_value