diff --git a/README.md b/README.md index 816470e..fdb577a 100644 --- a/README.md +++ b/README.md @@ -227,6 +227,30 @@ and queries for the `example.org` domain are handled using a declared zone (see ], } +View declarations can also include server clause configuration. The `servers` +property of `bind::view` accepts an array value which specifies each `server` +clause in the view as a hash. The hash must contain an `ip_addr` key which +specifies the IP address (optionally, a CIDR address range), and may contain a +`keys` key with a string value. The value of `keys` will be used as the name of +a key in the `server` clause. In this example, the `ns` view will contain a +`server` clause that configures BIND to use the key `internal-ns` to TSIG-sign +transactions with `192.168.24.2` and the key `hurricane-electric` to TSIG-sign +transactions with `216.218.130.2`: + + bind::view { 'ns': + servers => [ + { + 'ip_addr' => '192.168.24.2', + 'keys' => 'internal-ns', + }, + { + 'ip_addr' => '216.218.130.2', + 'keys' => 'hurricane-electric', + } + ], + ... + } + ###resource_record Declares a resource record. For exampmle: diff --git a/templates/view.erb b/templates/view.erb index 85048bf..9270391 100644 --- a/templates/view.erb +++ b/templates/view.erb @@ -34,14 +34,15 @@ view "<%= @name %>" { }; <%- end -%> <%- end -%> -<%- if @server -%> -<%- @server.each_pair do |srv, srv_values| -%> - server <%= srv %> { -<%- Array(srv_values).each do |srv_value| -%> - <%= srv_value %>; -<%- end -%> +<%- if @servers and @servers.is_a?(Array) -%> +<%- @servers.each do |properties| -%> +<%- raise Puppet::Error, 'view servers must have an ip_addr key' unless properties.has_key?('ip_addr') -%> + server <%= properties['ip_addr'] %> { +<%- if properties.has_key?('keys') and properties['keys'] != '' -%> + keys { <%= properties['keys'] %>; }; +<%- end -%> }; -<%- end -%> +<%- end -%> <%- end -%> <%- if scope.lookupvar('osfamily') == 'Debian' -%> include "<%= @confdir %>/named.conf.default-zones";