From 8b52b737532dcb685685c07643017f853f38489e Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 1 Jun 2016 19:00:16 +0200 Subject: [PATCH 1/2] iteritems() -> items(), fixes saltstack-formulas/bind-formula#30 --- bind/config.sls | 6 +++--- bind/files/arch/named.conf | 2 +- bind/files/arch/named.conf.local | 2 +- bind/files/debian/named.conf.key | 2 +- bind/files/debian/named.conf.local | 6 +++--- bind/files/debian/named.conf.options | 2 +- bind/files/redhat/named.conf.local | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bind/config.sls b/bind/config.sls index 22e292f..2161079 100644 --- a/bind/config.sls +++ b/bind/config.sls @@ -130,7 +130,7 @@ bind_default_zones: map: {{ map }} {% endif %} -{% for zone, zone_data in salt['pillar.get']('bind:configured_zones', {}).iteritems() -%} +{% for zone, zone_data in salt['pillar.get']('bind:configured_zones', {}).items() -%} {%- set file = salt['pillar.get']("bind:available_zones:" + zone + ":file") %} {% if file and zone_data['type'] == "master" -%} zones-{{ zone }}: @@ -157,8 +157,8 @@ signed-{{ zone }}: {% endif %} {% endfor %} -{%- for view, view_data in salt['pillar.get']('bind:configured_views', {}).iteritems() %} -{% for zone, zone_data in view_data.get('configured_zones', {}).iteritems() -%} +{%- for view, view_data in salt['pillar.get']('bind:configured_views', {}).items() %} +{% for zone, zone_data in view_data.get('configured_zones', {}).items() -%} {%- set file = salt['pillar.get']("bind:available_zones:" + zone + ":file") %} {% if file and zone_data['type'] == "master" -%} zones-{{ view }}-{{ zone }}: diff --git a/bind/files/arch/named.conf b/bind/files/arch/named.conf index 214ba83..3aab9ba 100644 --- a/bind/files/arch/named.conf +++ b/bind/files/arch/named.conf @@ -11,7 +11,7 @@ options { // listen-on { none; }; {#- Allow inclusion of arbitrary statements #} - {%- for statement, value in salt['pillar.get']('bind:config:options', {}).iteritems() -%} + {%- for statement, value in salt['pillar.get']('bind:config:options', {}).items() -%} {%- if value is iterable and value is not string %} {{ statement }} { {%- for item in value %} diff --git a/bind/files/arch/named.conf.local b/bind/files/arch/named.conf.local index 75f9faf..bddbd10 100644 --- a/bind/files/arch/named.conf.local +++ b/bind/files/arch/named.conf.local @@ -6,7 +6,7 @@ // organization //include "/etc/bind/zones.rfc1918"; -{% for key,args in salt['pillar.get']('bind:configured_zones', {}).iteritems() -%} +{% for key,args in salt['pillar.get']('bind:configured_zones', {}).items() -%} {%- set file = salt['pillar.get']("bind:available_zones:" + key + ":file") %} {%- set masters = salt['pillar.get']("bind:available_zones:" + key + ":masters") %} zone "{{ key }}" { diff --git a/bind/files/debian/named.conf.key b/bind/files/debian/named.conf.key index b604243..74690e3 100644 --- a/bind/files/debian/named.conf.key +++ b/bind/files/debian/named.conf.key @@ -3,7 +3,7 @@ // Do any local configuration here // -{% for key,args in salt['pillar.get']('bind:keys', {}).iteritems() -%} +{% for key,args in salt['pillar.get']('bind:keys', {}).items() -%} key "{{ key }}" { algorithm {{ args['algorithm'] | default('HMAC-MD5.SIG-ALG.REG.INT') }}; secret "{{ args['secret'] }}"; diff --git a/bind/files/debian/named.conf.local b/bind/files/debian/named.conf.local index e71080d..ddc5953 100644 --- a/bind/files/debian/named.conf.local +++ b/bind/files/debian/named.conf.local @@ -60,13 +60,13 @@ zone "{{ key }}" { include "{{ map.default_zones_config }}"; {%- endif %} -{% for key, args in salt['pillar.get']('bind:configured_zones', {}).iteritems() -%} +{% for key, args in salt['pillar.get']('bind:configured_zones', {}).items() -%} {%- set file = salt['pillar.get']("bind:available_zones:" + key + ":file") %} {%- set masters = salt['pillar.get']("bind:available_zones:" + key + ":masters") %} {{ zone(key, args, file, masters) }} {% endfor %} -{% for view, view_data in salt['pillar.get']('bind:configured_views', {}).iteritems() %} +{% for view, view_data in salt['pillar.get']('bind:configured_views', {}).items() %} view {{ view }} { {%- if view == 'default' %} @@ -79,7 +79,7 @@ match-clients { {%- endfor %} }; -{% for key, args in view_data.get('configured_zones', {}).iteritems() -%} +{% for key, args in view_data.get('configured_zones', {}).items() -%} {%- set file = salt['pillar.get']("bind:available_zones:" + key + ":file") %} {%- set masters = salt['pillar.get']("bind:available_zones:" + key + ":masters") %} {{ zone(key, args, file, masters) }} diff --git a/bind/files/debian/named.conf.options b/bind/files/debian/named.conf.options index 39c7c56..e1987f5 100644 --- a/bind/files/debian/named.conf.options +++ b/bind/files/debian/named.conf.options @@ -21,7 +21,7 @@ options { {%- endif -%} {#- Allow inclusion of arbitrary statements #} -{%- for statement, value in salt['pillar.get']('bind:config:options', {}).iteritems() -%} +{%- for statement, value in salt['pillar.get']('bind:config:options', {}).items() -%} {%- if value is iterable and value is not string %} {{ statement }} { {%- for item in value %} diff --git a/bind/files/redhat/named.conf.local b/bind/files/redhat/named.conf.local index 89e7bf9..52e8cad 100644 --- a/bind/files/redhat/named.conf.local +++ b/bind/files/redhat/named.conf.local @@ -6,7 +6,7 @@ // organization //include "/etc/bind/zones.rfc1918"; -{% for key,args in salt['pillar.get']('bind:configured_zones', {}).iteritems() -%} +{% for key,args in salt['pillar.get']('bind:configured_zones', {}).items() -%} {%- set file = salt['pillar.get']("bind:available_zones:" + key + ":file") %} {%- set masters = salt['pillar.get']("bind:available_zones:" + key + ":masters") %} zone "{{ key }}" { From 264c2966723f017ecdd5f295e3813b33925bd7e4 Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 1 Jun 2016 19:17:27 +0200 Subject: [PATCH 2/2] fix broken zones_source_dir on RedHat/Debian Als add docs for how to overwrite the path. Fixes saltstack-formulas/bind-formula#60? --- README.rst | 4 ++++ bind/map.jinja | 4 ++-- pillar.example | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index c88ae43..dc7c4ae 100644 --- a/README.rst +++ b/README.rst @@ -24,6 +24,10 @@ Install the bind package and start the bind service. --------------- Manage the bind configuration file. +Zone files are not generated by this state +rather than taken from `salt://zones`. +See `pillar.example` for how to overwrite +this URL. Example Pillar ============== diff --git a/bind/map.jinja b/bind/map.jinja index fec64a5..af4ac55 100644 --- a/bind/map.jinja +++ b/bind/map.jinja @@ -3,7 +3,7 @@ 'pkgs': ['bind9', 'bind9utils', 'dnssec-tools'], 'service': 'bind9', 'config_source_dir': 'bind/files/debian', - 'zones_source_dir': '/srv/salt/zones', + 'zones_source_dir': 'zones', 'config': '/etc/bind/named.conf', 'local_config': '/etc/bind/named.conf.local', 'key_config': '/etc/bind/named.conf.key', @@ -20,7 +20,7 @@ 'pkgs': ['bind'], 'service': 'named', 'config_source_dir': 'bind/files/redhat', - 'zones_source_dir': '/srv/salt/zones', + 'zones_source_dir': 'zones', 'config': '/etc/named.conf', 'local_config': '/etc/named.conf.local', 'default_config': '/etc/sysconfig/named', diff --git a/pillar.example b/pillar.example index 4c4c8c6..23a41ea 100644 --- a/pillar.example +++ b/pillar.example @@ -3,6 +3,9 @@ bind: pkgs: - bind service: named + # take zonefiles from `salt://bind/zonedata` + # instead of `salt://zones`: + zones_source_dir: bind/zonedata bind: config: