Occasionally I do stuff that's not amateur radio related. Today was one of those days.
I'm currently preparing a virtualised 'lab' to experiment with VoIP (Voice over IP), networking, and potentially some DMR network (radio) stuff in the future. I will be using
GNS3, a program that was created to emulate networking devices but now also does a great job of emulating servers and their associated network topology.
Historically when using GNS3 I've configured each 'node' manually, however its 2017, dev-ops is hot, and manual configuration is not. Enter
puppet, a configuration management tool that treats configuration more like code. You create a 'manifest' that contains instructions and templates on how to configure a device, and then an agent will then pull the configuration from the puppet master and apply the changes. Simple.
As far as I can tell (It's early days), puppet relies heavily on using hostnames to figure out which device needs which configuration. However, virtualised nodes within GNS3 are usually built from a template, and will share the same hostname when first configured. Additionally when a node is created, I don't know its MAC address, UUID, or any other identifier until its created. GNS3 will allow you to configure a hostname 'label' however this isn't communicated with the node out the box.
So, the plan? Create a script that will run on each node, query the GNS3 API and discover its own hostname, update it, and then puppet can do its thing and pull the correct configuration. BUT. How will the node know the IP that the API is running on?
I figured I could use DHCP options to send the IP of the API to the node, so it could then query the GNS3 API and grab it's hostname. I did the research and leg work, and then had an epiphany - what if someone had already invented a service that allows a device to find the IP address of a service... like... the Domain... Name... System. DNS.... Already invented.
For the sake of posterity, I've written up my findings below.