Re: [Puppet Users] Optional template files?

2012-06-29 Thread R.I.Pienaar


- Original Message -
> From: "GriffaA10" 
> To: puppet-users@googlegroups.com
> Sent: Friday, June 29, 2012 3:37:29 PM
> Subject: Re: [Puppet Users] Optional template files?
> 
> Great, that's done the trick, thanks
> 
> Just one thing to note. file() takes an absolute file path (i.e.
> /etc/puppet/modules/snmp/templates/snmpd.conf.erb). Spent a few
> minutes trying to figure out the error I was getting before finally
> RTFM.

indeed, not ideal especially with environments.

Ages ago I wrote a little function to bring to template() the same behaviour
as source => [] I dont know if it still works on modern puppet but it
was handy

http://p.devco.net/27/

-- 
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] Optional template files?

2012-06-29 Thread GriffaA10
Great, that's done the trick, thanks

Just one thing to note. file() takes an absolute file path (i.e. 
/etc/puppet/modules/snmp/templates/snmpd.conf.erb). Spent a few minutes 
trying to figure out the error I was getting before finally RTFM.

On Friday, June 29, 2012 2:04:06 PM UTC+1, Darren Chamberlain wrote:
>
>
> * GriffaA10  [2012/06/29 05:35]: 
> > I'm trying get Puppet to manage my snmpd instances. I have a 
> > "base" snmpd.conf constructed from a template, but some hosts 
> > require additional config. My plan was to have something like 
> > snmpd.conf.$hostname.erb in the templates directory and 
> > concatenate this with the base template. However, for the majority 
> > of hosts this file will not be present and in those cases I will 
> > get a "Could not find template" error. 
>
> The file() function returns the content of the first file that 
> exists, so you can use it with inline_template(): 
>
> file { 
> "/etc/snmpd.conf": 
> ensure => "present", 
> content => inline_template( 
> file( 
> "puppet:///modules/snmp/snmpd.conf.$::hostname.erb", 
> "puppet:///modules/snmp/snmpd.conf.erb", 
> ) 
> ), 
>   } 
>
> -- 
> Darren Chamberlain  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/2PbYFufZmD4J.
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] Optional template files?

2012-06-29 Thread Dan White
- Darren Chamberlain  wrote:
> 
> The file() function returns the content of the first file that
> exists, so you can use it with inline_template():
> 
> file {
> "/etc/snmpd.conf":
> ensure => "present",
> content => inline_template(
> file(
> "puppet:///modules/snmp/snmpd.conf.$::hostname.erb",
> "puppet:///modules/snmp/snmpd.conf.erb",
> )
> ),
>   }
> 

That is a wonderful tip, Darren.

Thanks !

-- 
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] Optional template files?

2012-06-29 Thread Darren Chamberlain

* GriffaA10  [2012/06/29 05:35]:
> I'm trying get Puppet to manage my snmpd instances. I have a
> "base" snmpd.conf constructed from a template, but some hosts
> require additional config. My plan was to have something like
> snmpd.conf.$hostname.erb in the templates directory and
> concatenate this with the base template. However, for the majority
> of hosts this file will not be present and in those cases I will
> get a "Could not find template" error.

The file() function returns the content of the first file that
exists, so you can use it with inline_template():

file {
"/etc/snmpd.conf":
ensure => "present",
content => inline_template(
file(
"puppet:///modules/snmp/snmpd.conf.$::hostname.erb",
"puppet:///modules/snmp/snmpd.conf.erb",
)
),
  }

-- 
Darren Chamberlain 

-- 
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.