I think this bind cookbook does that, pretty much what Joe suggested but with the entire zone file instead of a serial file.
Cheers
Mike
–
Michael Hart
Arctic Wolf Networks
M: 226-388-4773
From: Phillip Roberts <proberts@mybuys.commailto:proberts@mybuys.com>
Reply-To: "chef@lists.opscode.commailto:chef@lists.opscode.com" <chef@lists.opscode.commailto:chef@lists.opscode.com>
Date: Thursday, July 24, 2014 at 15:28
To: "chef@lists.opscode.commailto:chef@lists.opscode.com" <chef@lists.opscode.commailto:chef@lists.opscode.com>
Subject: [chef] RE: Re: RE: Re: Ohai Chefs!
Thank you for the input.
This would work, except I am dealing with thousands of zone files.
So what I need to do is figure out a good way to tell it to only generate a serial for the :serial => variable when it detects another change in the file.
Been beating it around in my head now since you pointed this out (which was helpful). Haven’t come up with a great solution yet.
Thanks,
Phillip Roberts | Sr. Linux Systems Administrator
MyBuyshttp://www.mybuys.com/ - Know Every Consumer
O 734.922.7014| M 614.423.9871 | proberts@mybuys.commailto:proberts@mybuys.com
@MyBuys | LinkedInhttp://www.linkedin.com/company/49603?trk=tyah&trkInfo=tarId%3A1395707807021%2Ctas%3Amybuys%2Cidx%3A3-1-5 | Facebookhttps://www.facebook.com/pages/MyBuys/145695757237?ref=br_tf
From: Joe Nuspl [mailto:nuspl@nvwls.com]
Sent: Wednesday, July 23, 2014 1:57 PM
To: chef@lists.opscode.commailto:chef@lists.opscode.com
Subject: [chef] Re: RE: Re: Ohai Chefs!
Yes, that will do it.
My bind knowledge is really rusty but could your zone file contain:
$INCLUDE serial
And then do something along the lines of:
template ‘serial’ do
action :nothing
variables :serial => Time.new.strftime("%Y%m%d%H%M%S")
source 'serial.erb’
notifies :reload, 'service[named]'
end
template ‘zone’ do
…
notifies :create, 'template[serial]'
end
I’ve done something similar for something other than bind.
Joe
On Jul 23, 2014, at 10:24 AM, Phillip Roberts <proberts@mybuys.commailto:proberts@mybuys.com> wrote:
I think because I have the serial variable as
:serial => Time.new.strftime("%Y%m%d%H%M%S")
It sees the serial change and rewrites the file. I guess what I need to figure out is a better way to do the serial so it only generates a new one when a change occurs.
Thanks,
Phillip Roberts | Sr. Linux Systems Administrator
MyBuyshttp://www.mybuys.com/ - Know Every Consumer
O 734.922.7014| M 614.423.9871 | proberts@mybuys.commailto:proberts@mybuys.com
@MyBuys | LinkedInhttp://www.linkedin.com/company/49603?trk=tyah&trkInfo=tarId%3A1395707807021%2Ctas%3Amybuys%2Cidx%3A3-1-5 | Facebookhttps://www.facebook.com/pages/MyBuys/145695757237?ref=br_tf
From: Joe Nuspl [mailto:nuspl@nvwls.com]
Sent: Wednesday, July 23, 2014 1:21 PM
To: chef@lists.opscode.commailto:chef@lists.opscode.com
Subject: [chef] Re: Ohai Chefs!
This is the default behavior. Either something in the template is causing the contents to change each run or something external is changing the file. If you run chef-client you should see the diff on stdout. Does that give you any clues?
Joe
On Jul 23, 2014, at 10:07 AM, Phillip Roberts <proberts@mybuys.commailto:proberts@mybuys.com> wrote:
Is there a way to make a recipe only write a template file if the file doesn’t exist or if the template has changed?
For instance, I have a recipe that generates zone files for bind based off of a list of domains in a data bag. However, on every chef-client run, it is regenerating the file, which is also regenerating the serial number.
Any assistance would be appreciated.
Thanks,
Phillip Roberts | Sr. Linux Systems Administrator
MyBuyshttp://www.mybuys.com/ - Know Every Consumer
O 734.922.7014| M 614.423.9871 | proberts@mybuys.commailto:proberts@mybuys.com
@MyBuys | LinkedInhttp://www.linkedin.com/company/49603?trk=tyah&trkInfo=tarId%3A1395707807021%2Ctas%3Amybuys%2Cidx%3A3-1-5 | Facebookhttps://www.facebook.com/pages/MyBuys/145695757237?ref=br_tf