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:
parent
4b5887a1f0
commit
de523dd8df
@ -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 %}
|
||||
|
||||
|
12
nsd/files/default/pillar-configuration.conf.jinja
Normal file
12
nsd/files/default/pillar-configuration.conf.jinja
Normal file
@ -0,0 +1,12 @@
|
||||
{%- for category, config in nsd.get('config_data').items() %}
|
||||
{{ category }}:
|
||||
{%- for option, value in config.items() %}
|
||||
{%- if value is string or value is number %}
|
||||
{{ option }}: {{ value }}
|
||||
{%- elif value is iterable %}
|
||||
{%- for item in value %}
|
||||
{{ option }}: {{ item }}
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{%- endfor %}
|
@ -17,9 +17,10 @@ nsd:
|
||||
# config_include_glob: *.conf
|
||||
|
||||
# Configuration is separated into several files which have their own templates
|
||||
config_files:
|
||||
10-server: local-nsd-for-unbound
|
||||
# 90-generated-zones is reserved for zones generated by this formula
|
||||
# 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,22 @@ 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'
|
||||
ip-address: 127.0.0.1
|
||||
# to use an option multiple times, make it a list:
|
||||
# ip-address:
|
||||
# - 127.0.0.1
|
||||
# - 192.168.0.1
|
||||
verbosity: 2
|
||||
port: 53530
|
||||
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
|
||||
|
@ -7,8 +7,15 @@ values:
|
||||
added_in_pillar: pillar_value
|
||||
arch: amd64
|
||||
config: /etc/nsd/nsd.conf
|
||||
config_files:
|
||||
10-server: local-nsd-for-unbound
|
||||
config_data:
|
||||
remote-control:
|
||||
control-enable: 'yes'
|
||||
control-interface: /run/nsd.sock
|
||||
server:
|
||||
hide-version: 'yes'
|
||||
ip-address: 127.0.0.1
|
||||
port: 53530
|
||||
verbosity: 2
|
||||
config_include_dir: "/etc/nsd/nsd.conf.d"
|
||||
config_include_glob: "*.conf"
|
||||
lookup:
|
||||
|
@ -7,8 +7,15 @@ values:
|
||||
added_in_pillar: pillar_value
|
||||
arch: amd64
|
||||
config: /etc/nsd/nsd.conf
|
||||
config_files:
|
||||
10-server: local-nsd-for-unbound
|
||||
config_data:
|
||||
remote-control:
|
||||
control-enable: 'yes'
|
||||
control-interface: /run/nsd.sock
|
||||
server:
|
||||
hide-version: 'yes'
|
||||
ip-address: 127.0.0.1
|
||||
port: 53530
|
||||
verbosity: 2
|
||||
config_include_dir: "/etc/nsd/nsd.conf.d"
|
||||
config_include_glob: "*.conf"
|
||||
lookup:
|
||||
|
@ -7,8 +7,15 @@ values:
|
||||
added_in_pillar: pillar_value
|
||||
arch: amd64
|
||||
config: /etc/nsd/nsd.conf
|
||||
config_files:
|
||||
10-server: local-nsd-for-unbound
|
||||
config_data:
|
||||
remote-control:
|
||||
control-enable: 'yes'
|
||||
control-interface: /run/nsd.sock
|
||||
server:
|
||||
hide-version: 'yes'
|
||||
ip-address: 127.0.0.1
|
||||
port: 53530
|
||||
verbosity: 2
|
||||
config_include_dir: "/etc/nsd/nsd.conf.d"
|
||||
config_include_glob: "*.conf"
|
||||
lookup:
|
||||
|
@ -7,8 +7,15 @@ values:
|
||||
added_in_pillar: pillar_value
|
||||
arch: amd64
|
||||
config: /etc/nsd/nsd.conf
|
||||
config_files:
|
||||
10-server: local-nsd-for-unbound
|
||||
config_data:
|
||||
remote-control:
|
||||
control-enable: 'yes'
|
||||
control-interface: /run/nsd.sock
|
||||
server:
|
||||
hide-version: 'yes'
|
||||
ip-address: 127.0.0.1
|
||||
port: 53530
|
||||
verbosity: 2
|
||||
config_include_dir: "/etc/nsd/nsd.conf.d"
|
||||
config_include_glob: "*.conf"
|
||||
lookup:
|
||||
|
Loading…
Reference in New Issue
Block a user