DNS Zone serial numbers

372 views
Skip to first unread message

Peter Berghold

unread,
Sep 9, 2011, 11:36:03 AM9/9/11
to puppet...@googlegroups.com
Hi folks,

Trying to create a function backed by some templates that will create DNS zone files.  The function is in the form of

function forward_zone ($dns_zone => "localdomain", $hosts => { { host=>"localhost", ip_addr=>"127.0.0.1" } }}) {

    .... logic here....
}

and the template will include the zone delegation record.  What I'm trying to figure out is how to generate the serial numbers. 

Normally when I hand edit zone files I use a serial number format of YYYYMMDDXXX where YYYY is the year, MM is the month and DD is the day the change is being made with XX being a two digit number incremented for each change done that day.

I cannot figure out a "good" way to do this with puppet.  Any thoughts?


--
Peter L. Berghold
Owner, Shark River Technical Solutions LLC

Daniel Maher

unread,
Sep 9, 2011, 12:05:21 PM9/9/11
to puppet...@googlegroups.com
On 09/09/2011 05:36 PM, Peter Berghold wrote:

> Normally when I hand edit zone files I use a serial number format of
> YYYYMMDDXXX where YYYY is the year, MM is the month and DD is the day
> the change is being made with XX being a two digit number incremented
> for each change done that day.
>
> I cannot figure out a "good" way to do this with puppet. Any thoughts?

Either a ridiculous erb template or a relatively simple custom function
would do the trick, though either way you'll have to write some Ruby.

--
Daniel Maher
� makin' plans now to live on Mars 'cuz I got Earth on lock. �

Jan-Piet Mens

unread,
Sep 9, 2011, 12:02:35 PM9/9/11
to puppet...@googlegroups.com
> and the template will include the zone delegation record. What I'm trying
> to figure out is how to generate the serial numbers.

I'd forego the YYYYMMDDxxx format and use either UNIX epoch time which
is auto-incrementing anyway, or store an integer counter (in a file) and
increment that each time your zone changes.

(Do note, though, that if you do move away from YYYYMMDDxxx, you'll
probably have to "reset" your zones' SOA serial numbers so that slave
servers don't miss out on zone transfers. [1].)

Hope that helps a bit (from the DNS point of view), and I cannot really
give you a good answer from the Puppet-point-of-view.

-JP

[1] http://www.zytrax.com/books/dns/ch9/serial.html

Aaron Grewell

unread,
Sep 9, 2011, 12:05:55 PM9/9/11
to puppet...@googlegroups.com
I'd just write a custom script in the language of your choice, put it on the server, and use the generate() function to pull the data.  Since it doesn't need to run on the client this should make things simpler.


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.


R.I.Pienaar

unread,
Sep 9, 2011, 12:06:31 PM9/9/11
to puppet...@googlegroups.com

the puppet problem is if you generate the serial you should only generate
it if the content of the rest of the file changes, this is pretty hard without
a type/provider.

I have some code to increment serials the way you want with yyyymmddxx but
dont have an immediate answer to how to use that without writing a type

Reply all
Reply to author
Forward
0 new messages