Last active
August 29, 2015 14:01
-
-
Save spheromak/0a25aba87e893b3f6c53 to your computer and use it in GitHub Desktop.
Using attribute mode to drive dhcp_cookbook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default[:dhcp][:failover] = nil | |
default[:dhcp][:allows] = [ "booting", "bootp", "unknown-clients" ] | |
default[:dhcp][:hosts] = [] | |
default[:dhcp][:groups] = [] | |
default[:dhcp][:networks] = [] | |
default[:dhcp][:interfaces] = [] | |
default[:dhcp][:hosts_bag] = "dhcp_hosts" | |
default[:dhcp][:networks_bag] = "dhcp_networks" | |
default[:dhcp][:groups_bag] = "dhcp_groups" | |
default[:dhcp][:parameters][:"default-lease-time"] = "6400" | |
default[:dhcp][:parameters][:"ddns-domainname"] = "\"#{domain}\"" | |
default[:dhcp][:parameters][:"ddns-update-style"] = "interim" | |
default[:dhcp][:parameters][:"max-lease-time"] = "86400" | |
default[:dhcp][:parameters][:"update-static-leases"] = "true" | |
default[:dhcp][:parameters][:"one-lease-per-client"] = "true" | |
default[:dhcp][:parameters][:"authoritative"] = "" | |
default[:dhcp][:parameters][:"ping-check"] = "true" | |
default[:dhcp][:parameters][:"next-server"] = node[:ipaddress] | |
default[:dhcp][:parameters][:"filename"] = '"pxelinux.0"' | |
default[:dhcp][:options][:'domain-name'] = "\"#{domain}\"" | |
default[:dhcp][:options][:'domain-name-servers'] = "8.8.8.8" | |
default[:dhcp][:options][:'host-name'] = " = binary-to-ascii (16, 8, \"-\", substring (hardware, 1, 6))" | |
default[:dhcp][:dir] = "/etc/dhcp" | |
default[:dhcp][:init_config] = "/etc/sysconfig/dhcpd" | |
case node[:platform_family] | |
when "rhel" | |
default[:dhcp][:package_name] = "dhcp" | |
default[:dhcp][:service_name] = "dhcpd" | |
default[:dhcp][:init_config] = "/etc/sysconfig/dhcpd" | |
default[:dhcp][:init_iface] = "DHCPDARGS" | |
if node[:platform_version].to_i >= 6 | |
default[:dhcp][:config_file] = "/etc/dhcp/dhcpd.conf" | |
else | |
default[:dhcp][:dir] = "/etc/dhcpd" | |
default[:dhcp][:config_file] = "/etc/dhcpd.conf" | |
end | |
when "debian" | |
default[:dhcp][:package_name] = "isc-dhcp-server" | |
default[:dhcp][:service_name] = "isc-dhcp-server" | |
default[:dhcp][:config_file] = "/etc/dhcp/dhcpd.conf" | |
default[:dhcp][:init_config] = "/etc/default/isc-dhcp-server" | |
default[:dhcp][:init_iface] = "INTERFACES" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tag 'dhcp' | |
node.default[:dhcp][:options]['domain-name-servers'] = '10.33.87.98, 10.33.87.99' | |
include_recipe "dhcp::_package" | |
include_recipe "dhcp::_service" | |
include_recipe "dhcp::_config" | |
rndc_key = { | |
'name' => 'dev.foo.com', | |
'algorithm' => 'hmac-md5', | |
'secret' => 'supersecret' | |
} | |
dns_zones = [ | |
{ | |
'zone' => 'dev.foo.com', | |
'primary' => 'ns01.dev.foo.com', | |
'key' => 'dev.foo.com' | |
}, | |
{ | |
'zone' => '0.87.33.10.in-addr.arpa.', | |
'primary' => 'ns01.dev.foo.com', | |
'key' => 'dev.foo.com' | |
} | |
] | |
dhcp_subnet "10.33.87.0" do | |
conf_dir node[:dhcp][:dir] | |
netmask "255.255.255.0" | |
broadcast "10.33.87.255" | |
routers ["10.33.87.1"] | |
range "10.33.87.5 10.33.87.254" | |
key rndc_key | |
zones dns_zones | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment