spheromak/dhcp-cook — pull request #13 by simonjohansson (2013-11-05 12:09:31+00:00)
Title: Support dynamic update of a bind server from a subnet.

A quick and dirty hack to allow a subnet to update a bind server.

Having a dhcp_network item like so

```
{
"name": "data_bag_item_dhcp_networks_172-30-5-0",
"json_class": "Chef::DataBagItem",
"chef_type": "data_bag_item",
"data_bag": "dhcp_networks",
"raw_data": {
"id": "172-30-5-0",
"routers": [
"172.30.5.1"
],
"address": "172.30.5.0",
"netmask": "255.255.255.0",
"broadcast": "172.30.5.255",
"range": "172.30.5.13 172.30.5.254",
"options": [
"option domain-name-servers 172.30.5.254",
"option domain-name \"lab.sp\"",
"ddns-domainname \"lab.sp.\"",
"ddns-rev-domainname \"5.30.172.in-addr.arpa.\""
],
"key": {
"name": "dhcpupdate",
"algorithm": "hmac-md5",
"secret": "megasecret=="
},
"zones": [
{
"zone": "lab.sp.",
"primary": "172.30.5.254",
"key": "dhcpupdate"
},
{
"zone": "5.30.172.in-addr.arpa",
"primary": "172.30.5.254",
"key": "dhcpupdate"
}
]
}
}
```

produces a subnet config file

```
# File managed by Chef

subnet 172.30.5.0 netmask 255.255.255.0 {
pool {
range 172.30.5.13 172.30.5.254;
}
option routers 172.30.5.1;
option subnet-mask 255.255.255.0;
option broadcast-address 172.30.5.255;
ddns-domainname "lab.sp.";
ddns-rev-domainname "5.30.172.in-addr.arpa.";
option domain-name "lab.sp";
option domain-name-servers 172.30.5.254;

key dhcpupdate {
algorithm hmac-md5;
secret "megasecret==";
};

zone lab.sp. {
primary 172.30.5.254;
key dhcpupdate;
}
zone 5.30.172.in-addr.arpa {
primary 172.30.5.254;
key dhcpupdate;
}
}
```

It aint pretty but it works.