Jason Amato
2010-Aug-11 15:55 UTC
[Puppet Users] install package based on operatingsystem AND operatingsystemrelease
How can I create a class to install a RPM based on the o/s type and the o/s release. I want to install a package on SLES, but only if it''s release 11, not 10. I can do this, but how do I incorporate the release in here... thanks in advance! class packages1 { $lsb = $operatingsystem ? { OEL => redhat-lsb, SLES => lsb, default => redhat-lsb } package { $lsb: ensure => installed } } -Jason -- 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.
Joe McDonagh
2010-Aug-11 16:33 UTC
Re: [Puppet Users] install package based on operatingsystem AND operatingsystemrelease
On 08/11/2010 11:55 AM, Jason Amato wrote:> How can I create a class to install a RPM based on the o/s type and > the o/s release. > I want to install a package on SLES, but only if it''s release 11, not > 10. > > I can do this, but how do I incorporate the release in here... thanks > in advance! > > class packages1 { > $lsb = $operatingsystem ? { > OEL => redhat-lsb, > SLES => lsb, > default => redhat-lsb > } > package { $lsb: > ensure => installed > } > > } > > > -Jason > >Try using a nested selector in the package name selector, and setting 10 => "absent". -- Joe McDonagh AIM: YoosingYoonickz IRC: joe-mac on freenode "When the going gets weird, the weird turn pro." -- 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.
Nan Liu
2010-Aug-11 16:48 UTC
Re: [Puppet Users] install package based on operatingsystem AND operatingsystemrelease
On Wed, Aug 11, 2010 at 11:55 AM, Jason Amato <amato_jason@yahoo.com> wrote:> How can I create a class to install a RPM based on the o/s type and > the o/s release. > I want to install a package on SLES, but only if it''s release 11, not > 10. > >I suppose you can write nested if statements. Not sure if there are other more elegant methods. Assuming facter $operatingsystemrelease for SLES 11 returns 11.x, is this what you are looking for? $os_release = "${operatingsystem}-${operatingsystemrelease}" $pkg = ${os_release} ? { /^OEL-/ => redhat-lsb, /^SLES-11./ => lsb, default => redhat-lsb, } package { $pkg: ensure => installed, } Thanks, Nan -- 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
2010-Aug-11 16:52 UTC
Re: [Puppet Users] install package based on operatingsystem AND operatingsystemrelease
On Wed, Aug 11, 2010 at 9:48 AM, Nan Liu <nan@puppetlabs.com> wrote:> On Wed, Aug 11, 2010 at 11:55 AM, Jason Amato <amato_jason@yahoo.com> wrote: >> >> How can I create a class to install a RPM based on the o/s type and >> the o/s release. >> I want to install a package on SLES, but only if it''s release 11, not >> 10. >> > > I suppose you can write nested if statements. Not sure if there are other > more elegant methods. Assuming facter $operatingsystemrelease for SLES 11 > returns 11.x, is this what you are looking for? > > $os_release = "${operatingsystem}-${operatingsystemrelease}" > > $pkg = ${os_release} ? { > /^OEL-/ => redhat-lsb, > /^SLES-11./ => lsb, > default => redhat-lsb, > } > > package { $pkg: > ensure => installed, > }Won''t that try to install ''redhat-lsb'' on SLES 10 ? I think you want ensure => undef for SLES 10 if you truly want to not manage it. I tend to be more of a fan of explicit conditional statements outside resource definitions these days, nested selectors are harder to parse quickly, and now we have decent conditional logic, it''s much easier.> > Thanks, > > Nan > > -- > 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 -- 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.
Gustavo Soares
2010-Aug-11 18:55 UTC
Re: [Puppet Users] install package based on operatingsystem AND operatingsystemrelease
I''ve been doing like this. (Don''t know if it is the better ways.. but.. :)) if ($operatingsystemrelease >= 4) and ($operatingsystemrelease < 5) { $release = "el4" } else { if ($operatingsystemrelease >= 5) and ($operatingsystemrelease < 6) { $release = "el5" } } package { abc: ensure => "0.25.5-1.${release}" } PS.: I am running puppet 0.25.x in 2.6 I believe there is a elsif or something like that... Gus On Wed, Aug 11, 2010 at 1:52 PM, Nigel Kersten <nigelk@google.com> wrote:> On Wed, Aug 11, 2010 at 9:48 AM, Nan Liu <nan@puppetlabs.com> wrote: > > On Wed, Aug 11, 2010 at 11:55 AM, Jason Amato <amato_jason@yahoo.com> > wrote: > >> > >> How can I create a class to install a RPM based on the o/s type and > >> the o/s release. > >> I want to install a package on SLES, but only if it''s release 11, not > >> 10. > >> > > > > I suppose you can write nested if statements. Not sure if there are other > > more elegant methods. Assuming facter $operatingsystemrelease for SLES 11 > > returns 11.x, is this what you are looking for? > > > > $os_release = "${operatingsystem}-${operatingsystemrelease}" > > > > $pkg = ${os_release} ? { > > /^OEL-/ => redhat-lsb, > > /^SLES-11./ => lsb, > > default => redhat-lsb, > > } > > > > package { $pkg: > > ensure => installed, > > } > > Won''t that try to install ''redhat-lsb'' on SLES 10 ? > > I think you want > > ensure => undef > > for SLES 10 if you truly want to not manage it. > > I tend to be more of a fan of explicit conditional statements outside > resource definitions these days, nested selectors are harder to parse > quickly, and now we have decent conditional logic, it''s much easier. > > > > > > > Thanks, > > > > Nan > > > > -- > > 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<puppet-users%2Bunsubscribe@googlegroups.com> > . > > For more options, visit this group at > > http://groups.google.com/group/puppet-users?hl=en. > > > > > > -- > nigel > > -- > 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<puppet-users%2Bunsubscribe@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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nan Liu
2010-Aug-11 19:15 UTC
Re: [Puppet Users] install package based on operatingsystem AND operatingsystemrelease
On Wed, Aug 11, 2010 at 12:52 PM, Nigel Kersten <nigelk@google.com> wrote:> > > $os_release = "${operatingsystem}-${operatingsystemrelease}" > > > > $pkg = ${os_release} ? { > > /^OEL-/ => redhat-lsb, > > /^SLES-11./ => lsb, > > default => redhat-lsb, > > } > > > > package { $pkg: > > ensure => installed, > > } > > Won''t that try to install ''redhat-lsb'' on SLES 10 ? >Yes, that''s wrong. Originally, I wanted to set /^SLES-10/ to something standard that comes with the distro, but didn''t seem like the right solution, and leaving out that line ended up with something that''s definitely incorrect.> I think you want > > ensure => undef > > for SLES 10 if you truly want to not manage it. >I did some testing, undef doesn''t appear to work since ensure is a required parameter and undef is not a valid value. Setting package ensure=>undef will install the package rather than unmanaged. I guess absent would be acceptable? package { $pkg: ensure => ${os_release} ? /^SLES-10/ = absent, default => installed, } } Thanks, Nan -- 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.
DaveQB
2010-Aug-11 23:10 UTC
[Puppet Users] Re: install package based on operatingsystem AND operatingsystemrelease
Here''s how I do it. if ( $operatingsystem == "SLES" ) and ( $operatingsystemrelease ="10" ){ include SLES_10 } if ( $operatingsystem == "SLES" ) and ( $operatingsystemrelease ="11" ){ include SLES_11 } Of course run facter to check the variables. But you get the idea. On Aug 12, 5:15 am, Nan Liu <n...@puppetlabs.com> wrote:> On Wed, Aug 11, 2010 at 12:52 PM, Nigel Kersten <nig...@google.com> wrote: > > > > $os_release = "${operatingsystem}-${operatingsystemrelease}" > > > > $pkg = ${os_release} ? { > > > /^OEL-/ => redhat-lsb, > > > /^SLES-11./ => lsb, > > > default => redhat-lsb, > > > } > > > > package { $pkg: > > > ensure => installed, > > > } > > > Won''t that try to install ''redhat-lsb'' on SLES 10 ? > > Yes, that''s wrong. Originally, I wanted to set /^SLES-10/ to something > standard that comes with the distro, but didn''t seem like the right > solution, and leaving out that line ended up with something that''s > definitely incorrect. > > > I think you want > > > ensure => undef > > > for SLES 10 if you truly want to not manage it. > > I did some testing, undef doesn''t appear to work since ensure is a required > parameter and undef is not a valid value. Setting package ensure=>undef will > install the package rather than unmanaged. I guess absent would be > acceptable? > > package { $pkg: > ensure => ${os_release} ? > /^SLES-10/ = absent, > default => installed, > } > > } > > Thanks, > > Nan-- 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.