split config by $lsbdistid

194 views
Skip to first unread message

Vincent Louviaux

unread,
Oct 7, 2008, 4:53:13 AM10/7/08
to puppet...@googlegroups.com
Hello

Is it possible to split config files by distributions ?

the goal is to define the same class but different by os distribution
and not always define a case in all config files like

class ntp {
case "$lsbdistid $lsbdistcodename" {
  "Ubuntu hardy":   {
..


So I would like something like :
import "classes/$lsbdistid/$lsbdistcodename/*.pp"

Vincent

Vincent Louviaux

unread,
Oct 7, 2008, 4:53:13 AM10/7/08
to puppet...@googlegroups.com

Vincent Louviaux

unread,
Oct 7, 2008, 4:53:13 AM10/7/08
to puppet...@googlegroups.com

Vincent Louviaux

unread,
Oct 7, 2008, 4:53:13 AM10/7/08
to puppet...@googlegroups.com

Vincent Louviaux

unread,
Oct 7, 2008, 4:53:13 AM10/7/08
to puppet...@googlegroups.com

Mike Renfro

unread,
Oct 7, 2008, 9:41:41 AM10/7/08
to puppet...@googlegroups.com
Vincent Louviaux wrote:

Three things: first, I *think* the import lines would end up being
evaluated on the puppetmaster, and wouldn't use the clients' facts.
Second, I'm not sure you'd save any effort, and would be working against
the usual practice of "the files, templates, and manifests in my ntp
module tree are all I need to manage ntp on all the OSes I have to worry
about".

Third, you might be able to rework your case statements into selectors
and reduce the amount of repeated code that may be one cause for your
concerns (not knowing what's in your current case statements, it's hard
to say for sure). Here's an alternative that would work out pretty
compactly:

file { ntpconf:
path => "/etc/ntp.conf",
source => $operatingsystem ? {
"Debian" =>
"puppet:///ntp/ntp.conf.${lsbdistid}-${lsbdistcodename}",
"Solaris" => "puppet:///ntp/ntp.conf.Solaris"
},
owner => "root",
group => "root",
mode => 644,
}

Recent versions of facter on Ubuntu may return "Ubuntu" for the
operatingsystem fact instead of "Debian".

--
Mike Renfro / R&D Engineer, Center for Manufacturing Research,
931 372-3601 / Tennessee Technological University -- ren...@tntech.edu

Joshua Timberman

unread,
Oct 7, 2008, 10:33:12 AM10/7/08
to puppet...@googlegroups.com
On Tue, Oct 7, 2008 at 7:41 AM, Mike Renfro <ren...@tntech.edu> wrote:
>
> Recent versions of facter on Ubuntu may return "Ubuntu" for the
> operatingsystem fact instead of "Debian".


$ facter facterversion lsbdistid
facterversion => 1.3.8
lsbdistid => Ubuntu


I think only case statements can take multiple values though, so:

case $lsbdistid {
Debian, Ubuntu: { $ntp_file_source =


"puppet:///ntp/ntp.conf.${lsbdistid}-${lsbdistcodename}",

Solaris: { $ntp_file_source = "puppet:///ntp/ntp.conf.Solaris" }
}

file { ntpconf:
...
source => "$ntp_file_source",
...
}

Reply all
Reply to author
Forward
0 new messages