feat(config): pillar based config template

Allow management of general configuration using pillar data.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
Georg Pfuetzenreuter 2023-02-17 00:07:24 +01:00
parent 4b5887a1f0
commit b922ebc2ea
Signed by: Georg
GPG Key ID: 1ED2F138E7E6FF57
3 changed files with 27 additions and 0 deletions

View File

@ -4,6 +4,7 @@
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_package_install = tplroot ~ '.package.install' %}
{%- from tplroot ~ "/macros.jinja" import config_file with context %}
{%- from tplroot ~ "/map.jinja" import mapdata as nsd with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
@ -28,3 +29,12 @@ nsd-config-file-file-managed:
- context:
nsd: {{ nsd | json }}
- check_cmd: nsd-checkconf
{%- set config_data = nsd.get('config_data', {}) %}
{%- if config_data | length > 0 %}
{{ config_file('10-salt', 'pillar-configuration') }}
{%- endif %}

View File

@ -0,0 +1,6 @@
{%- for category, config in nsd.get('config_data').items() %}
{{ category }}:
{%- for option, value in config.items() %}
{{ option }}: {{ value }}
{%- endfor %}
{%- endfor %}

View File

@ -20,6 +20,7 @@ nsd:
config_files:
10-server: local-nsd-for-unbound
# 90-generated-zones is reserved for zones generated by this formula
# 10-salt is reserved for general configuration generated by this formula
# If this section is present in your Pillar data,
# nsd.conf.d/90-generated-zones will be created and managed.
@ -31,6 +32,16 @@ nsd:
# NSD's include-pattern directive may be a better way to share configuration
# across zones than using YAML anchors.
# If this section is present in your Pillar data,
# nsd.conf.d/10-salt.conf will be created and managed
config_data:
server:
hide-version: 'yes'
verbosity: 3
remote-control:
control-enable: 'yes'
control-interface: /run/nsd.sock
tofs:
# The files_switch key serves as a selector for alternative
# directories under the formula files directory. See TOFS pattern