Skip to content

Commit

Permalink
Merge pull request #1913 from matthewoliver/5.0_dns_bind_public_if_de…
Browse files Browse the repository at this point in the history
…signate

5.0: Public ips for dns nodes when designate integration is in use (SOC-9635)
  • Loading branch information
dirkmueller authored Sep 3, 2019
2 parents e9ef28b + 8731f91 commit e06d680
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
17 changes: 14 additions & 3 deletions chef/cookbooks/bind9/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ def make_zone(zone)
end
end

# We would like to bind service only to ip address from admin network
# We would like to bind service only to ip address from admin network unless enable_designate is
# enabled. In which case bind both the admin and public.
admin_network = Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, "admin")
admin_addr = admin_network.address

Expand Down Expand Up @@ -390,10 +391,20 @@ def make_zone(zone)

### FIXME Change to "any" once IPv6 support has been implemented
admin_addr6 = "none"
public_addr6 = "none"
if node[:dns][:enable_designate] && !node[:dns][:master]
node[:dns][:forwarders].push master_ip
end

ipaddresses = [admin_addr]
ip6addresses = [admin_addr6]
if node[:dns][:enable_designate]
public_addr = Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, "public").address
public_addr = nil if admin_addr == public_addr
ipaddresses << public_addr unless public_addr.nil?
ip6addresses << public_addr6 unless public_addr6 == "none"
end

# Rewrite our default configuration file
template "/etc/bind/named.conf" do
source "named.conf.erb"
Expand All @@ -402,8 +413,8 @@ def make_zone(zone)
group bindgroup
variables(forwarders: node[:dns][:forwarders],
allow_transfer: allow_transfer,
ipaddress: admin_addr,
ip6address: admin_addr6,
ipaddresses: ipaddresses,
ip6addresses: ip6addresses,
enable_designate: node[:dns][:enable_designate] && node[:dns][:master]
)
notifies :restart, "service[bind9]", :immediately
Expand Down
4 changes: 2 additions & 2 deletions chef/cookbooks/bind9/templates/default/named.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ options {
};
<% end -%>
auth-nxdomain no; # conform to RFC1035
listen-on { <%= @ipaddress %>; };
listen-on-v6 { <%= @ip6address %>; };
listen-on { <%= @ipaddresses.join("; ") %>; };
listen-on-v6 { <%= @ip6addresses.join("; ") %>; };
minimal-responses yes;
allow-new-zones yes;
};
Expand Down
7 changes: 7 additions & 0 deletions crowbar_framework/app/models/dns_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ def apply_role_pre_chef_call(old_role, role, all_nodes)
return if all_nodes.empty?

tnodes = role.override_attributes["dns"]["elements"]["dns-server"]
# If designate is enabled, we need each DNS node to be attached to the public network.
net_svc = NetworkService.new @logger
tnodes.each do |node|
if role.default_attributes[:dns][:enable_designate]
net_svc.allocate_ip "default", "public", "host", node
end
end
nodes = tnodes.map { |n| Node.find_by_name(n) }

if nodes.length == 1
Expand Down

0 comments on commit e06d680

Please sign in to comment.