I'd recommend using hooks for this. The flow would be that a node binds to a policy, which triggers a hook script to run. That hook script determines which static IP a node should use. The script returns that value as metadata, which gets applied to the node. Later, when the node requests its install script, this metadata can be used to change how the install scripts are rendered for the node, in this case setting the static IP.
Here's what would be required:
- Write a hook that will run on the
node-bound-to-policy event. This hook should operate similar to the
hostname hook, so that can be used as a model if you choose to write yours in Ruby. The job of this script, which can be written in any executable language, is to update the node's
ip metadata to the desired value.
- Modify the kernel_args.erb in your task to set the static IP of the node to the
ip value of the node's metadata, e.g.:
--ip=<%= node.metadata['ip'] %>
The hook script can be as complicated or simple as you like. You could have a block of available addresses and use a counter to select an available value, or query an external system for the value, or any other number of methods.
Let me know if you need any further help!