[Puppet Users] How To Expand an .erb Template Without Doing a Full Puppet Run?

2011-09-10 Thread Jon Forrest

We use puppet to distribute named zone files, like many
of you do. We use git to maintain these files, which are
then pulled by the puppet master machine. These zone files are
actually puppet template .erb files.

The other day, I made a mistake which resulted in some zone
files with syntax errors in them. Puppet faithfully distributed
the erroneous zone files to the name servers, which killed them.

To prevent this from happening again, I want to be able to
somehow expand the template files and run named-checkzone
as part of a git pre-commit hook. I want this expansion to
occur without making a normal puppet run so that the bad
files won't get distributed.

Can anybody point me to a technique for doing this?

Cordially,
Jon Forrest

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



Re: [Puppet Users] How To Expand an .erb Template Without Doing a Full Puppet Run?

2011-09-10 Thread Nigel Kersten
On Sat, Sep 10, 2011 at 5:36 PM, Jon Forrest  wrote:

> We use puppet to distribute named zone files, like many
> of you do. We use git to maintain these files, which are
> then pulled by the puppet master machine. These zone files are
> actually puppet template .erb files.
>
> The other day, I made a mistake which resulted in some zone
> files with syntax errors in them. Puppet faithfully distributed
> the erroneous zone files to the name servers, which killed them.
>
> To prevent this from happening again, I want to be able to
> somehow expand the template files and run named-checkzone
> as part of a git pre-commit hook. I want this expansion to
> occur without making a normal puppet run so that the bad
> files won't get distributed.
>
> Can anybody point me to a technique for doing this?
>


git cat-file blob :0:$indexfile | erb -x -T - | ruby -c 2> $error_msg >
/dev/null ;

from:

http://projects.puppetlabs.com/projects/1/wiki/Puppet_Version_Control

should get you going.




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


-- 
Nigel Kersten
Product Manager, Puppet Labs

*Join us for **PuppetConf *

Sept 22/23 Portland, Oregon, USA.
*
*

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



Re: [Puppet Users] How To Expand an .erb Template Without Doing a Full Puppet Run?

2011-09-10 Thread Jonathan Stanton
On Sep 10, 2011, at 9:26 PM, Nigel Kersten wrote:

> On Sat, Sep 10, 2011 at 5:36 PM, Jon Forrest  wrote:
> 
>> We use puppet to distribute named zone files, like many
>> of you do. We use git to maintain these files, which are
>> then pulled by the puppet master machine. These zone files are
>> actually puppet template .erb files.
>> 
>> The other day, I made a mistake which resulted in some zone
>> files with syntax errors in them. Puppet faithfully distributed
>> the erroneous zone files to the name servers, which killed them.
>> 
>> To prevent this from happening again, I want to be able to
>> somehow expand the template files and run named-checkzone
>> as part of a git pre-commit hook. I want this expansion to
>> occur without making a normal puppet run so that the bad
>> files won't get distributed.
>> 
>> Can anybody point me to a technique for doing this?
>> 
> 
> 
> git cat-file blob :0:$indexfile | erb -x -T - | ruby -c 2> $error_msg >
> /dev/null ;
> 
> from:
> 
> http://projects.puppetlabs.com/projects/1/wiki/Puppet_Version_Control
> 
> should get you going.
> 


Maybe I'm missing something here, but I think Jon was asking something a bit 
different -- he doesn't want to check the validity of the erb template (i.e. 
ruby syntax check) but syntax check the named zone file generated by the 
template. 

So the tricky bit is how to get the variables out of the puppet manifests that 
the erb template needs to generate the output file that 'would' be generated by 
a new puppet run for this node -- without the actual puppet run (as he asks at 
the end of the email).

My first thought is that the only accurate way to do this is by doing a full 
puppet run, as any part of the node's manifest could effect the variables used 
in the zone file template. You should be able to get away with a --noop run so 
the changes won't actually be applied (because noop does generate files from 
templates, but you would need to have a way to capture the newly generated zone 
file on the client host and run the named-checkzone there.

Cheers,

Jonathan
---
Jonathan Stanton jonat...@spreadconcepts.com
Spread Group Messaging  www.spread.org
Spread Concepts LLC www.spreadconcepts.com
---




> 
> 
> 
>> 
>> Cordially,
>> Jon Forrest
>> 
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Puppet Users" group.
>> To post to this group, send email to puppet-users@googlegroups.com.
>> To unsubscribe from this group, send email to puppet-users+unsubscribe@**
>> googlegroups.com .
>> For more options, visit this group at http://groups.google.com/**
>> group/puppet-users?hl=en
>> .
>> 
>> 
> 
> 
> -- 
> Nigel Kersten
> Product Manager, Puppet Labs
> 
> *Join us for **PuppetConf *
> 
> Sept 22/23 Portland, Oregon, USA.
> *
> *
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> puppet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/puppet-users?hl=en.
> 



smime.p7s
Description: S/MIME cryptographic signature


Re: [Puppet Users] How To Expand an .erb Template Without Doing a Full Puppet Run?

2011-09-10 Thread Jon Forrest

On 9/10/2011 6:57 PM, Jonathan Stanton wrote:


Maybe I'm missing something here, but I think Jon was asking
something a bit different -- he doesn't want to check the validity of
the erb template (i.e. ruby syntax check) but syntax check the named
zone file generated by the template.


Precisely. Maybe later I'll face the issue of ruby syntax
problems but right now I need to detect named syntax errors
before they cause problems.


So the tricky bit is how to get the variables out of the puppet
manifests that the erb template needs to generate the output file
that 'would' be generated by a new puppet run for this node --
without the actual puppet run (as he asks at the end of the email).


Precisely again.


My first thought is that the only accurate way to do this is by doing
a full puppet run, as any part of the node's manifest could effect
the variables used in the zone file template. You should be able to
get away with a --noop run so the changes won't actually be applied
(because noop does generate files from templates, but you would need
to have a way to capture the newly generated zone file on the client
host and run the named-checkzone there.


That's what I figured. I was hoping that there would be an easier way
that could somehow do a facter run but only run the minimal amount
of puppet.

Jon


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



Re: [Puppet Users] How To Expand an .erb Template Without Doing a Full Puppet Run?

2011-09-10 Thread Aaron Grewell
Perhaps just add an exec step or two to your regular run? Put the file in a
temp location then move it to the live one if it checks out?
On Sep 10, 2011 8:01 PM, "Jon Forrest"  wrote:
> On 9/10/2011 6:57 PM, Jonathan Stanton wrote:
>>
>> Maybe I'm missing something here, but I think Jon was asking
>> something a bit different -- he doesn't want to check the validity of
>> the erb template (i.e. ruby syntax check) but syntax check the named
>> zone file generated by the template.
>
> Precisely. Maybe later I'll face the issue of ruby syntax
> problems but right now I need to detect named syntax errors
> before they cause problems.
>
>> So the tricky bit is how to get the variables out of the puppet
>> manifests that the erb template needs to generate the output file
>> that 'would' be generated by a new puppet run for this node --
>> without the actual puppet run (as he asks at the end of the email).
>
> Precisely again.
>
>> My first thought is that the only accurate way to do this is by doing
>> a full puppet run, as any part of the node's manifest could effect
>> the variables used in the zone file template. You should be able to
>> get away with a --noop run so the changes won't actually be applied
>> (because noop does generate files from templates, but you would need
>> to have a way to capture the newly generated zone file on the client
>> host and run the named-checkzone there.
>
> That's what I figured. I was hoping that there would be an easier way
> that could somehow do a facter run but only run the minimal amount
> of puppet.
>
> Jon
>
>
> --
> You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to
puppet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
>

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