Update with the required logic.

Added an if-block to test for the file argument in the zone_data, and if found, use that view and update the zone variable to match the zone defined under available_zones.
This commit is contained in:
crux-capacitor 2018-11-15 16:07:19 -05:00 committed by GitHub
parent 33c34d928d
commit 342c0d7d08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -203,19 +203,24 @@ bind_rndc_client_config:
{%- set views = {False: salt['pillar.get']('bind', {})} %}{# process non-view zones in the same loop #} {%- set views = {False: salt['pillar.get']('bind', {})} %}{# process non-view zones in the same loop #}
{%- do views.update(salt['pillar.get']('bind:configured_views', {})) %} {%- do views.update(salt['pillar.get']('bind:configured_views', {})) %}
{%- for view, view_data in views|dictsort %} {%- for view, view_data in views|dictsort %}
{%- set dash_view = '-' + view if view else '' %} {%- set dash_view = '-' + view if view else '' %}
{% for zone, zone_data in view_data.get('configured_zones', {})|dictsort -%} {%- for zone, zone_data in view_data.get('configured_zones', {})|dictsort -%}
{%- set file = salt['pillar.get']("bind:available_zones:" + zone + ":file", false) %} {%- if 'file' in zone_data %}
{%- set zone_records = salt['pillar.get']('bind:available_zones:' + zone + ':records', {}) %} {%- set file = zone_data.file %}
{%- if salt['pillar.get']('bind:available_zones:' + zone + ':generate_reverse') %} {%- set zone = zone|replace(".txt", "") %}
{%- do generate_reverse(zone_records, salt['pillar.get']('bind:available_zones:' + zone + ':generate_reverse:net'), salt['pillar.get']('bind:available_zones:' + zone + ':generate_reverse:for_zones'), salt['pillar.get']('bind:available_zones', {})) %} {%- else %}
{%- endif %} {%- set file = salt['pillar.get']("bind:available_zones:" + zone + ":file", false) %}
{%- endif %}
{%- set zone_records = salt['pillar.get']('bind:available_zones:' + zone + ':records', {}) %}
{%- if salt['pillar.get']('bind:available_zones:' + zone + ':generate_reverse') %}
{%- do generate_reverse(zone_records, salt['pillar.get']('bind:available_zones:' + zone + ':generate_reverse:net'), salt['pillar.get']('bind:available_zones:' + zone + ':generate_reverse:for_zones'), salt['pillar.get']('bind:available_zones', {})) %}
{%- endif %}
{# If we define RRs in pillar, we use the internal template to generate the zone file {# If we define RRs in pillar, we use the internal template to generate the zone file
otherwise, we fallback to the old behaviour and use the declared file otherwise, we fallback to the old behaviour and use the declared file
#} #}
{%- set zone_source = 'salt://bind/files/zone.jinja' if zone_records != {} else 'salt://' ~ map.zones_source_dir ~ '/' ~ file %} {%- set zone_source = 'salt://bind/files/zone.jinja' if zone_records != {} else 'salt://' ~ map.zones_source_dir ~ '/' ~ file %}
{%- set serial_auto = salt['pillar.get']('bind:available_zones:' + zone + ':soa:serial', '') == 'auto' %} {%- set serial_auto = salt['pillar.get']('bind:available_zones:' + zone + ':soa:serial', '') == 'auto' %}
{% if file and zone_data['type'] == 'master' -%} {% if file and zone_data['type'] == 'master' -%}
zones{{ dash_view }}-{{ zone }}{{ '.include' if serial_auto else ''}}: zones{{ dash_view }}-{{ zone }}{{ '.include' if serial_auto else ''}}:
file.managed: file.managed:
- name: {{ zones_directory }}/{{ file }}{{ '.include' if serial_auto else ''}} - name: {{ zones_directory }}/{{ file }}{{ '.include' if serial_auto else ''}}