Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My tradition is to set all zone serials to the timestamp at modification. Now that Puppet is my new religion, I want to set serial timestamps when building zone files from exported resources. A somewhat trivialized example may look like this:

file { "/tmp/dafile": content = inline_template("<%= Time.now.to_i %>"), }

The problem with this approach is that content will be different all the time, which will (ultimately) provoke rebuilding of zone files on each puppet config poll.

Is there some way I can insert a timestamp without it being included in the data that is compared against previous state?

share|improve this question
    
What is your problem with a frequently changing serial? Why not just accept it will change frequently? –  Zoredache Nov 29 '11 at 4:41
1  
It consumes system resources; reassembling the zone file from all the exported resources takes tens of seconds. It generates log spam from both puppet and bind. It will require frequent reloads of bind configuration, which incurs a small risk. Also, it is impolite to invalidate the zone essentially every refresh interval unless necessary. –  Bittrance Nov 29 '11 at 4:52
    
BTW, what are you using to generated your DNS zones? –  Zoredache Nov 29 '11 at 5:12

4 Answers 4

up vote 3 down vote accepted

Don't use a template, if you try to use a serial number there the problem is your going to keep making changes each time.

I have two ideas:

  1. Create a proper type that can manage DNS using DNS updates via the standard API. Then let BIND do the serial number increments itself.
  2. Use a file fragment pattern on each element within your DNS zone, and have it so that the main zone file only gets updated when these change. You do this by having a 'zone refresh' exec that concats your parts into the final zone including the header. The difference between most file fragment solutions would be that you generate your zone serial from a timestamp or some such, which should only ever get triggered when the parts are changed thus avoiding the constant serial number changes you would get from a template.

Some examples of the file fragment pattern are here:

http://projects.puppetlabs.com/projects/puppet/wiki/Generating_a_config_file_from_fragments

https://github.com/ripienaar/puppet-concat

share|improve this answer

How about using the timestamp of the file:

file { "/tmp/dafile": content = inline_template("<%= File.mtime("/tmp/dafile").to_i %>"), }

The only thing is that this will probably run on each client and may update the timestamp of the file for every run. If it doesn't, it should suit your requirement.

share|improve this answer

How about the following,

$utime_serial = inline_template("<%= Time.now.to_i %>")

file { "/var/named/$domain.hosts":
          content => template("named/$domain.hosts.erb"),
          owner => root,
          group => named,
          mode => 0640,
}

where the erb template file contains,

$TTL 1D
@             IN      SOA       galaxy.example.com.  sysadmin.example.com.  (
                               <%=utime_serial %>       ; Serial
                                8H             ; Refresh
                                2H             ; Retry
                                4W             ; Expire
                                1D )           ; Minimum
share|improve this answer

can you run external commands from within puppet (I´m using cfengine, don't know puppet) Whats about this /bin/date '+%Y%m%d00'

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.