Re: [Puppet Users] Using classes from extnode to define config files?

2010-04-30 Thread Michael DeHaan
This will work, but I'd use a selector.   Search for selector in
this document:  http://docs.puppetlabs.com/guides/more_language.html

The reason being, is you could supply a default if no match was found,
rather than it just generating an error.

I would use one to assign a variable to the template name, and just do
template($template_name) as normal, that way you don't evaluate
template() more than once.

A node can belong to more than one class, so I wouldn't rely on the
idea of using $CLASSNAME.(For instance, the external nodes system
could say I'm a webserver, and I'm also an appserver later.

Since you're using cobbler, you any --ksmeta variables you set are
available as variables in Puppet.

(Others can see docs on this here:
https://fedorahosted.org/cobbler/wiki/UsingCobblerWithConfigManagementSystem
)

Parameterized classes, coming in the next release, will make this a
lot easier -- though it's something Cobbler's going to have to adapt
to.

--Michael

On Fri, Apr 30, 2010 at 6:10 AM, Peter Meier peter.me...@immerda.ch wrote:
 but I'm not too sure how to set the value of $CLASSNAME.

 we do something similar:

 file{'/etc/exim/exim.conf':
  source = [ puppet://$server/modules/site-exim/${fqdn}/exim.conf,
              puppet://$server/modules/site-exim/${exim_type}/exim.conf,
              puppet://$server/modules/site-exim/exim.conf,
              puppet://$server/modules/exim/exim.conf ],
  require = Package['exim'],
  notify = Service['exim'],
  owner = root, group = mail, mode = 0640;
 }

 http://git.puppet.immerda.ch/?p=module-exim.git;a=blob;f=manifests/base.pp;h=a0b2d02ca3e1a95b0ddc0b48fa54efb5d2981774;hb=76f594abd5dabffe86bdaeecb99b15bda4b968fc#l13

 what we do then is to set per node the variable (or in an external node tool
 called parameter) $exim_type to set it to something like 'antivirus',
 'webhosting' or whatever. and then have in site-exim/files/antivirus/ the
 appropriate config file.

 btw: we nearly got rid off that, as we started to split the exim
 configuration into different subfiles and including them. We then deploy
 only these include files based on exim_type. This has the advantage, that we
 have only one identical main-exim config and do all the tweaks in little
 files we just include.

 cheers pete

 --
 You received this message because you are subscribed to the Google Groups
 Puppet Users group.
 To post to this group, send email to puppet-us...@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-us...@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] Using classes from extnode to define config files?

2010-04-30 Thread Matt Wallace
On Fri, 2010-04-30 at 12:10 +0200, Peter Meier wrote:
  but I'm not too sure how to set the value of $CLASSNAME.
 
 we do something similar:
 
 file{'/etc/exim/exim.conf':
source = [ puppet://$server/modules/site-exim/${fqdn}/exim.conf,
puppet://$server/modules/site-exim/${exim_type}/exim.conf,
puppet://$server/modules/site-exim/exim.conf,
puppet://$server/modules/exim/exim.conf ],
require = Package['exim'],
notify = Service['exim'],
owner = root, group = mail, mode = 0640;
 }
 
 http://git.puppet.immerda.ch/?p=module-exim.git;a=blob;f=manifests/base.pp;h=a0b2d02ca3e1a95b0ddc0b48fa54efb5d2981774;hb=76f594abd5dabffe86bdaeecb99b15bda4b968fc#l13
 
 what we do then is to set per node the variable (or in an external  
 node tool called parameter) $exim_type to set it to something like  
 'antivirus', 'webhosting' or whatever. and then have in  
 site-exim/files/antivirus/ the appropriate config file.
 
 btw: we nearly got rid off that, as we started to split the exim  
 configuration into different subfiles and including them. We then  
 deploy only these include files based on exim_type. This has the  
 advantage, that we have only one identical main-exim config and do all  
 the tweaks in little files we just include.
 
 cheers pete
 

Hi Pete,

I've decided to go with the following in the end:

===
# define the config file to use
if(tagged(webserver)) {
$filename = webserver
}
else
{
$filename = smtpserver
}


file { /etc/exim/exim.conf:
path = /etc/exim/exim.conf,
ensure = present,
source = puppet:///modules/exim/exim-$filename.conf,
owner = exim,
group = exim,
mode = 644,
require = Package[exim],
}
===

Does anyone know how to achieve the above in a prettier fashion?

M.

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To post to this group, send email to puppet-us...@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] Using classes from extnode to define config files?

2010-04-30 Thread Michael DeHaan

 Does anyone know how to achieve the above in a prettier fashion?

Thinking about it some more...

Create a baseclass called exim and subclasses called exim:web and
exim:smtp

Have the class webserver include exim:web and the class smtpserver
include exim:smtp.

--Michael

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To post to this group, send email to puppet-us...@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.