From 64f51a69b59b1bfe289a27805e10b15ea343e533 Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Fri, 17 Feb 2023 21:21:15 +0100 Subject: [PATCH] feat(zones): allow custom options and files - allow additional configuration options in zone blocks - allow installation of zone files from other Salt file roots Signed-off-by: Georg Pfuetzenreuter --- nsd/config/zones.sls | 4 ++++ nsd/files/default/generated-zones.conf.jinja | 6 ++++++ pillar.example | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/nsd/config/zones.sls b/nsd/config/zones.sls index 6d5b0e4..f4f612c 100644 --- a/nsd/config/zones.sls +++ b/nsd/config/zones.sls @@ -28,10 +28,14 @@ nsd-config-zones-file-directory: "{{ identifier }}": file.managed: - name: "{{ nsd.zones_dir }}/{{ zonefile_name(name, config) }}" + {%- if 'zone_source' in config %} + - source: {{ config['zone_source'] }} + {%- else %} - source: {{ files_switch([template, template+'.jinja'], lookup=identifier ) }} + {%- endif %} - mode: 644 - user: root - group: {{ nsd.rootgroup }} diff --git a/nsd/files/default/generated-zones.conf.jinja b/nsd/files/default/generated-zones.conf.jinja index d993a5b..5e2f29e 100644 --- a/nsd/files/default/generated-zones.conf.jinja +++ b/nsd/files/default/generated-zones.conf.jinja @@ -1,4 +1,5 @@ {%- from "nsd/macros.jinja" import zonefile_name with context -%} +{%- set extraopts = ['allow-notify', 'request-xfr', 'outgoing-interface'] -%} ######################################################################## # File managed by Salt at <{{ source }}>. # Your changes will be overwritten. @@ -8,4 +9,9 @@ zone: name: "{{ name }}" zonefile: "{{ nsd.zones_dir }}/{{ zonefile_name(name, config) }}" + {%- for option in extraopts %} + {%- if option in config %} + {{ option }}: "{{ config[option] }}" + {%- endif %} + {%- endfor %} {%- endfor %} diff --git a/pillar.example b/pillar.example index 77ffe8a..e26fbd9 100644 --- a/pillar.example +++ b/pillar.example @@ -31,6 +31,11 @@ nsd: "168.192.in-addr.arpa": {} # NSD's include-pattern directive may be a better way to share configuration # 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, # nsd.conf.d/10-salt.conf will be created and managed