We have a standard high-availability setup at a co-location facility that we host client programs on. For some programs, we host the DNS, but I find that setting up multiple zones manually can be tedious and prone to error. Is there an easy way to setup a standard zone file template and some how run sed, awk, or some other program to process a set of variables from another file and merge them with the template to create a zone file?
I thought about using m4, but I'm not well versed and it only seems ideal for merging one template at a time.
Ideally, I'd like to take a standard zone file template and merge it with a list like so:
domain1=ip1
domain2=ip2
domain3=ip1
domain4=ip1
etc...
Is there a way to script this?
I think m4 would be overkill. My first instinct would be bash + sed, but if you have any familiarity with a higher-level language that might be easier. Off the top of my head, I would imagine something like this:
Data file:
Script:
And your template zone file would have "DOMAIN" or "IPADDR" where appropriate.
This is completely untested and should be refined before use.