Skip to content

Commit

Permalink
Cleanup subnet code a little
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewoliver committed Jan 7, 2019
1 parent 2257c37 commit a705dfa
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions chef/cookbooks/dhcp/providers/subnet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@
require "ipaddr"

action :add do
if IPAddr.new(new_resource.network["subnet"]).ipv6?
subnet_template = "subnet6.conf.erb"
subnet_list_file = "subnet6_list.conf"
ip_version = if IPAddr.new(new_resource.network["subnet"]).ipv6?
'6'
else
subnet_template = "subnet.conf.erb"
subnet_list_file = "subnet_list.conf"
''
end
filename = "/etc/dhcp3/subnets.d/#{new_resource.subnet}.conf"
template filename do
cookbook "dhcp"
source subnet_template
source "subnet#{ip_version}.conf.erb"
variables(
network: new_resource.network,
options: new_resource.options,
Expand All @@ -42,7 +40,7 @@
end
utils_line "include \"#{filename}\";" do
action :add
file "/etc/dhcp3/subnets.d/#{subnet_list_file}"
file "/etc/dhcp3/subnets.d/subnet#{ip_version}_list.conf"
if node[:provisioner][:enable_pxe]
notifies :restart, resources(service: "dhcp3-server"), :delayed
end
Expand Down

0 comments on commit a705dfa

Please sign in to comment.