Configuring Static IPs

Environment


Windows 7 x64 and x32

Chef Server 11.1.5-1

Chef Client 11.16.2-1

Setup


When configuring network settings, there is not consistent identifier for network adapters. The names and indexes are set arbitrarily on first boot. I need to set a configuration on the network adapter but have no method for determining which network to apply which configuration to.

http://support2.microsoft.com/kb/823206

Consistent Device Naming is a possible solution but it is only supported in Windows 8+ and only if the BIOS supports the feature.

Our environment has 3 types of networks. The Corporate Network has DHCP but for various reasons must be set static. This link has the communication to the Chef Server and the binary storage server. If we lose this link to a misconfiguration, we lose remote control of the machine. Internal networks have no DHCP and need a static IP to communicate. And lastly, point to point networks connect to a single device and needs a static IP to communicate.

Proposal


Define a resource with the IP configuration

ip_config "test" do

    state :static (or :dhcp)

    ip_address "10.1.1.1"

    subnetmask "255.255.255.0"

    gateway "10.1.1.100"

    dnsservers ["192.168.0.1", "192.168.0.2"]

    verification_ip "10.20.234.54"

end

This resource would go through each network adapter (skipping AdapterIndexes that already have configs), apply the config, and ping the verification ip. If the network can see the verification ip, the resource assumes the configuration is correct. The resource then stores the AdapterIndex and corresponding config in the node data and on the local disk so that on the next run the resource is aware the config has already been applied.

If the verification fails, the config is reverted and the resource moves onto the next adapter. If the resource cycles through all the adapters and does not find a successful verification, the resource raises an error.

If the network configuration data needs to be updated, the node data for the IP configuration is cleared so that the chef-client reapplies the configs on the next run.

In this approach, the verification IP address must be unique to that network and only able to be seen by that network. Does this seem like a good approach? Does anyone have any advice on how to pull this off? Are there any cookbooks that have any of this already implemented that I can build off of?

Thanks,

Jordan