Hello,
I have a file which varies depending on which
OS/version it''s running. I tried to make a nested
source parameter like this, but it didn''t work:
source => $operatingsystem ? {
Debian =>
"puppet://myserver.com/files/os/debian/etc/ssh/sshd_config",
Gentoo =>
"puppet://myserver.com/files/os/gentoo/etc/ssh/sshd_config",
RedHat => $lsbdistrelease ? {
"4" =>
"puppet://myserver.com/files/os/rhel4/etc/ssh/sshd_config",
"5" =>
"puppet://myserver.com/files/os/rhel5/etc/ssh/sshd_config",
"5.1" =>
"puppet://myserver.com/files/os/rhel5/etc/ssh/sshd_config"
}
}
I asked on IRC and a fellow recommended using the case
function. It did work, but I don''t think it looks as
pretty:
case $operatingsystem {
Debian: {
$pkg_src
"puppet://myserver.com/files/os/debian/etc/ssh/sshd_config"
}
Gentoo: {
$pkg_src
"puppet://myserver.com/files/os/gentoo/etc/ssh/sshd_config"
}
RedHat: {
case $lsbdistrelease {
4: {
$pkg_src
"puppet://myserver.com/files/os/rhel4/etc/ssh/sshd_config"
}
5: {
$pkg_src
"puppet://myserver.com/files/os/rhel5/etc/ssh/sshd_config"
}
"5.1": {
$pkg_src
"puppet://myserver.com/files/os/rhel5/etc/ssh/sshd_config"
}
}
}
}
...
source => $pkg_src
Is there a reason the first method doesn''t work, or
better yet, a way to make it work? :-) It uses fewer
lines and is easier to read.
Thanks.
--
John Philips
johnphilips42@yahoo.com
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
It seems that would be something fairly common and people start managing
large more diverse infrastructures.
I have a tendency to do things like this to handle similar situations:
...
Redhat =>
"puppet://myserver.com/files/os/rhel${lsbrelease}/etc/ssh/sshd_config",
...
specifically I do it with apache (I have a custom fact for the apache major
version)
then in my files tree I have directories for the various cases.
Just another way to handle it. I think you''re first (non-working)
solution
is probably the right way to do it but the language isn''t quite there
yet.
C
On 12/14/07, John Philips <johnphilips42@yahoo.com>
wrote:>
> Hello,
>
> I have a file which varies depending on which
> OS/version it''s running. I tried to make a nested
> source parameter like this, but it didn''t work:
>
> source => $operatingsystem ? {
> Debian =>
> "puppet://myserver.com/files/os/debian/etc/ssh/sshd_config",
> Gentoo =>
> "puppet://myserver.com/files/os/gentoo/etc/ssh/sshd_config",
> RedHat => $lsbdistrelease ? {
> "4" =>
> "puppet://myserver.com/files/os/rhel4/etc/ssh/sshd_config",
> "5" =>
> "puppet://myserver.com/files/os/rhel5/etc/ssh/sshd_config",
> "5.1" =>
> "puppet://myserver.com/files/os/rhel5/etc/ssh/sshd_config"
> }
> }
>
> I asked on IRC and a fellow recommended using the case
> function. It did work, but I don''t think it looks as
> pretty:
>
> case $operatingsystem {
> Debian: {
> $pkg_src >
"puppet://myserver.com/files/os/debian/etc/ssh/sshd_config"
> }
> Gentoo: {
> $pkg_src >
"puppet://myserver.com/files/os/gentoo/etc/ssh/sshd_config"
> }
> RedHat: {
> case $lsbdistrelease {
> 4: {
> $pkg_src >
"puppet://myserver.com/files/os/rhel4/etc/ssh/sshd_config"
> }
> 5: {
> $pkg_src >
"puppet://myserver.com/files/os/rhel5/etc/ssh/sshd_config"
> }
> "5.1": {
> $pkg_src >
"puppet://myserver.com/files/os/rhel5/etc/ssh/sshd_config"
> }
> }
> }
> }
> ...
> source => $pkg_src
>
>
> Is there a reason the first method doesn''t work, or
> better yet, a way to make it work? :-) It uses fewer
> lines and is easier to read.
>
> Thanks.
>
> --
> John Philips
> johnphilips42@yahoo.com
>
>
>
>
____________________________________________________________________________________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile. Try it now.
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>
> _______________________________________________
> Puppet-users mailing list
> Puppet-users@madstop.com
> https://mail.madstop.com/mailman/listinfo/puppet-users
>
--
stickm@gmail.com
-==< Stick >==-
_______________________________________________
Puppet-users mailing list
Puppet-users@madstop.com
https://mail.madstop.com/mailman/listinfo/puppet-users
> I have a tendency to do things like this to handle > similar situations: > > ... > Redhat => >"puppet://myserver.com/files/os/rhel${lsbrelease}/etc/ssh/sshd_config",> ...I was thinking of going that route, until I noticed we have some systems running v5 and some running v5.1. In that case I''d either have to duplicate the dirs and have a rhel5 and rhel5.1 directory on the puppetmaster server or use a symlink. A symlink just seems like a hack.> I think you''re first > (non-working) solution > is probably the right way to do it but the language > isn''t quite there yet.Is this a limitation with ruby or puppet? If puppet, please consider adding this functionality to the TODO list as it would create beautiful manifests. On a related note, I''d also like to be able to use compound if statements. The LanguageTutorial wiki page describes if/else like this: if $variable { file { "/some/file": ensure => present } } else { file { "/some/other/file": ensure => present } } I''d like to do it like this (install package only in specific situation): if $operatingsystem == "RedHat" && $lsbdistrelease =4 { package { "perl-Time-HiRes": ensure => installed } } Instead I''m stuck with using case (ugly): case $operatingsystem { "RedHat": { case $lsbdistrelease { 4: { package { "perl-Time-HiRes": ensure => installed } } } } } Perhaps there is a cleaner method I don''t know of.> > > On 12/14/07, John Philips <johnphilips42@yahoo.com> > wrote: > > > > Hello, > > > > I have a file which varies depending on which > > OS/version it''s running. I tried to make a nested > > source parameter like this, but it didn''t work: > > > > source => $operatingsystem ? { > > Debian => > > >"puppet://myserver.com/files/os/debian/etc/ssh/sshd_config",> > Gentoo => > > >"puppet://myserver.com/files/os/gentoo/etc/ssh/sshd_config",> > RedHat => $lsbdistrelease ? { > > "4" => > > >"puppet://myserver.com/files/os/rhel4/etc/ssh/sshd_config",> > "5" => > > >"puppet://myserver.com/files/os/rhel5/etc/ssh/sshd_config",> > "5.1" => > > >"puppet://myserver.com/files/os/rhel5/etc/ssh/sshd_config"> > } > > } > > > > I asked on IRC and a fellow recommended using the > case > > function. It did work, but I don''t think it looks > as > > pretty: > > > > case $operatingsystem { > > Debian: { > > $pkg_src > > >"puppet://myserver.com/files/os/debian/etc/ssh/sshd_config"> > } > > Gentoo: { > > $pkg_src > > >"puppet://myserver.com/files/os/gentoo/etc/ssh/sshd_config"> > } > > RedHat: { > > case $lsbdistrelease { > > 4: { > > $pkg_src > > >"puppet://myserver.com/files/os/rhel4/etc/ssh/sshd_config"> > } > > 5: { > > $pkg_src > > >"puppet://myserver.com/files/os/rhel5/etc/ssh/sshd_config"> > } > > "5.1": { > > $pkg_src > > >"puppet://myserver.com/files/os/rhel5/etc/ssh/sshd_config"> > } > > } > > } > > } > > ... > > source => $pkg_src > > > > > > Is there a reason the first method doesn''t work, > or > > better yet, a way to make it work? :-) It uses > fewer > > lines and is easier to read. > > > > Thanks. > > > > -- > > John Philips > > johnphilips42@yahoo.com > > > > > > > > >____________________________________________________________________________________> > Be a better friend, newshound, and > > know-it-all with Yahoo! Mobile. Try it now. > > >http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ> > > > _______________________________________________ > > Puppet-users mailing list > > Puppet-users@madstop.com > > >https://mail.madstop.com/mailman/listinfo/puppet-users> > > > > > -- > stickm@gmail.com > -==< Stick >==- > > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com >https://mail.madstop.com/mailman/listinfo/puppet-users>____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
Hi: John Philips wrote:>> I have a tendency to do things like this to handle >> similar situations: >> >> ... >> Redhat => >> > "puppet://myserver.com/files/os/rhel${lsbrelease}/etc/ssh/sshd_config", >> ... > > I was thinking of going that route, until I noticed we > have some systems running v5 and some running v5.1. > In that case I''d either have to duplicate the dirs and > have a rhel5 and rhel5.1 directory on the puppetmaster > server or use a symlink. A symlink just seems like a > hack. >Just FYI, one of the newer releases of facter includes $operatingsystemrelease which will return ''5'' instead of the ''5'' and ''5.1'' of $lsbdistrelease. Not that it solves your initial problem, but it was an added feature I was happy to see. I''m running dlutter''s 1.3.8-1 facter package. Boone