Compare commits

..

1 Commits

Author SHA1 Message Date
80e434b94b
feat(config): pillar based config template
Allow management of general configuration using pillar data.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2023-02-17 20:53:20 +01:00
4 changed files with 1 additions and 20 deletions

View File

@ -28,14 +28,10 @@ nsd-config-zones-file-directory:
"{{ identifier }}": "{{ identifier }}":
file.managed: file.managed:
- name: "{{ nsd.zones_dir }}/{{ zonefile_name(name, config) }}" - name: "{{ nsd.zones_dir }}/{{ zonefile_name(name, config) }}"
{%- if 'zone_source' in config %}
- source: {{ config['zone_source'] }}
{%- else %}
- source: {{ files_switch([template, template+'.jinja'], - source: {{ files_switch([template, template+'.jinja'],
lookup=identifier lookup=identifier
) )
}} }}
{%- endif %}
- mode: 644 - mode: 644
- user: root - user: root
- group: {{ nsd.rootgroup }} - group: {{ nsd.rootgroup }}

View File

@ -1,5 +1,4 @@
{%- from "nsd/macros.jinja" import zonefile_name with context -%} {%- from "nsd/macros.jinja" import zonefile_name with context -%}
{%- set extraopts = ['allow-notify', 'request-xfr', 'outgoing-interface'] -%}
######################################################################## ########################################################################
# File managed by Salt at <{{ source }}>. # File managed by Salt at <{{ source }}>.
# Your changes will be overwritten. # Your changes will be overwritten.
@ -9,9 +8,4 @@
zone: zone:
name: "{{ name }}" name: "{{ name }}"
zonefile: "{{ nsd.zones_dir }}/{{ zonefile_name(name, config) }}" zonefile: "{{ nsd.zones_dir }}/{{ zonefile_name(name, config) }}"
{%- for option in extraopts %}
{%- if option in config %}
{{ option }}: "{{ config[option] }}"
{%- endif %}
{%- endfor %}
{%- endfor %} {%- endfor %}

View File

@ -1,7 +1,7 @@
{%- for category, config in nsd.get('config_data').items() %} {%- for category, config in nsd.get('config_data').items() %}
{{ category }}: {{ category }}:
{%- for option, value in config.items() %} {%- for option, value in config.items() %}
{%- if value is string or value is number %} {%- if value is string %}
{{ option }}: {{ value }} {{ option }}: {{ value }}
{%- elif value is iterable %} {%- elif value is iterable %}
{%- for item in value %} {%- for item in value %}

View File

@ -31,11 +31,6 @@ nsd:
"168.192.in-addr.arpa": {} "168.192.in-addr.arpa": {}
# NSD's include-pattern directive may be a better way to share configuration # NSD's include-pattern directive may be a better way to share configuration
# across zones than using YAML anchors. # across zones than using YAML anchors.
#
# You can load the zone file from a custom source and specify additional configuration options:
# example.com:
# zone_source: salt://zones/example.com.zone
# request-xfr: 192.168.0.1
# If this section is present in your Pillar data, # If this section is present in your Pillar data,
# nsd.conf.d/10-salt.conf will be created and managed # nsd.conf.d/10-salt.conf will be created and managed
@ -43,10 +38,6 @@ nsd:
server: server:
hide-version: 'yes' hide-version: 'yes'
ip-address: 127.0.0.1 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 verbosity: 2
port: 53530 port: 53530
remote-control: remote-control: