Christopher Wood
2012-Jan-17 21:09 UTC
[Puppet Users] ignoring a service that doesn''t exist
I definitely need some assistance in conceptualizing something. If I want to configure syslog-ng instead of rsyslog, or configure rsyslog instead of sysklogd, the previous syslog daemon has to be stopped (and disabled) before the new one starts. De-configuring the previous one works just fine when the service (init script) exists on the system: $disable = [''rsyslog'', ''syslog''] service { $disable: enable => false, ensure => stopped, } But when the init script doesn''t exist, I get something like this: Jan 17 15:05:44 dpuppet-01 puppet-agent[4011]: (/Stage[main]/Sysklogd::Disable/Service[syslog]/ensure) change from running to stopped failed: Could not find init script for ''syslog'' How would I say "if it''s there, disable it, if not, ignore it" in puppet DSL? (For completeness, this is with puppet 2.6.2 on various platforms.) -- 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.
Daniel Pittman
2012-Jan-17 21:32 UTC
Re: [Puppet Users] ignoring a service that doesn''t exist
On Tue, Jan 17, 2012 at 13:09, Christopher Wood <christopher_wood@pobox.com> wrote:> I definitely need some assistance in conceptualizing something. > > If I want to configure syslog-ng instead of rsyslog, or configure rsyslog instead of sysklogd, the previous syslog daemon has to be stopped (and disabled) before the new one starts. De-configuring the previous one works just fine when the service (init script) exists on the system: > > $disable = [''rsyslog'', ''syslog''] > service { $disable: > enable => false, > ensure => stopped, > } > > But when the init script doesn''t exist, I get something like this: > > Jan 17 15:05:44 dpuppet-01 puppet-agent[4011]: (/Stage[main]/Sysklogd::Disable/Service[syslog]/ensure) change from running to stopped failed: Could not find init script for ''syslog'' > > How would I say "if it''s there, disable it, if not, ignore it" in puppet DSL?exec { "damn!": … } Sadly, there isn''t any way to express this in the DSL. I suspect there might be a feature request already, but I can''t find one, so can you file one? This seems like a useful thing to do, without thinking too deeply about it. -- Daniel Pittman ⎋ Puppet Labs Developer – http://puppetlabs.com ♲ Made with 100 percent post-consumer electrons -- 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.
On Tue, Jan 17, 2012 at 1:09 PM, Christopher Wood <christopher_wood@pobox.com> wrote:> I definitely need some assistance in conceptualizing something. > > If I want to configure syslog-ng instead of rsyslog, or configure rsyslog instead of sysklogd, the previous syslog daemon has to be stopped (and disabled) before the new one starts. De-configuring the previous one works just fine when the service (init script) exists on the system: > > $disable = [''rsyslog'', ''syslog''] > service { $disable: > enable => false, > ensure => stopped, > } > > But when the init script doesn''t exist, I get something like this: > > Jan 17 15:05:44 dpuppet-01 puppet-agent[4011]: (/Stage[main]/Sysklogd::Disable/Service[syslog]/ensure) change from running to stopped failed: Could not find init script for ''syslog'' > > How would I say "if it''s there, disable it, if not, ignore it" in puppet DSL?You can''t use the init.d script (or hasstatus=true) to check for service, so you fall back and specify the service command in this case: service { ''rsyslog'': ensure => stopped, # this is normally first attribute. enable => false, status => ''source /etc/init.d/functions; status rsyslogd'', # provide a way to check status regardless if the init.d script is available. } 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.
John Simpson
2013-May-09 20:58 UTC
Re: [Puppet Users] ignoring a service that doesn''t exist
I''ve done the following, it ended up being a bit simpler for me when I''m not sure what random services a new CentOS install has installed and/or enabled... define no_service ( ) { service { "${name}" : ensure => stopped , enable => false , status => "stat -t /etc/rc?.d/S??${name} > /dev/null 2>&1" , } } You can then declare individual service names, or lists of service names, each of which will be disabled and shut down if the service is enabled. If a particular service doesn''t exist, the puppet agent does nothing. no_service { ''ip6tables'' : } no_service { [ ''nfslock'' , ''portmap'' , ''xyzzy'' ] : } The only caveat is, if a service is disabled (i.e. "chkconfig service off") but the service is still running, the puppet agent won''t stop it. Of course, if you have a service which is normally off and you''ve only enabled it to test something, this could be a good thing... -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Stefan Schulte
2013-May-09 21:53 UTC
Re: [Puppet Users] ignoring a service that doesn''t exist
On Thu, 9 May 2013 13:58:45 -0700 (PDT) John Simpson <jms1@voalte.com> wrote:> I''ve done the following, it ended up being a bit simpler for me when > I''m not sure what random services a new CentOS install has installed > and/or enabled... > > define no_service ( ) { > service { "${name}" : > ensure => stopped , > enable => false , > status => "stat -t /etc/rc?.d/S??${name} > /dev/null 2>&1" , > } > } > > You can then declare individual service names, or lists of service > names, each of which will be disabled and shut down if the service is > enabled. If a particular service doesn''t exist, the puppet agent does > nothing. > > no_service { ''ip6tables'' : } > no_service { [ ''nfslock'' , ''portmap'' , ''xyzzy'' ] : } > > The only caveat is, if a service is disabled (i.e. "chkconfig service > off") but the service is still running, the puppet agent won''t stop > it. Of course, if you have a service which is normally off and you''ve > only enabled it to test something, this could be a good thing... >you should be able to just specify `hasstatus => false`. This way puppet will check the process list in order to get the current status and will not run the (absent) initscript to get the status. -Stefan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.