oliver zhang
2013-Feb-13 03:53 UTC
[Puppet Users] how to check whether a linux process is running?
Hi Everyone, I''m new to puppet. How do I do this in puppet: if process A is running, do nothing. else mount share and install package A I couldn''t find any reference about this. Thanks. -- 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.
Paul Tötterman
2013-Feb-13 08:04 UTC
[Puppet Users] Re: how to check whether a linux process is running?
Hi Oliver, if process A is running, do nothing.> > else mount share and install package A >This doesn''t really sit well with the declarative nature of Puppet. It would be better if your package pre-installation scripts were to cleanly implement this imperative procedure. Something like shut down service, mount, install, start service back up. If you really want to try doing this with puppet, look at exec and onlyif/unless ( unless => ''pgrep process'' ) and dependencies. Cheers, Paul -- 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.
Matthew Burgess
2013-Feb-13 09:10 UTC
Re: [Puppet Users] how to check whether a linux process is running?
On Wed, Feb 13, 2013 at 3:53 AM, oliver zhang <oliver.x.zhang@gmail.com> wrote:> Hi Everyone, > > I''m new to puppet. > > How do I do this in puppet: > > if process A is running, do nothing. > > else mount share and install package A > > I couldn''t find any reference about this. > > Thanks.In addition to what Paul says, the way that something like this would normally be handled in Puppet is: 1) If process A is not running, start process A (this could be done via an Exec) 2) Step 1 may fail, because the binary used to launch process A is not installed. So, you''d also have a Package resource that would manage the package that contains that binary. At this point, the Exec can be told to depend on the Package such that trying to start process A will automatically trigger the installation of the necessary Package if it''s not already installed. 3) The Package (or particular configuration thereof) may require a mount point to be available. So, you''d also have a Mount resource that would configure that mount point. At this point, the Package resource configured in step 2 can be told to depend on the Mount resource such that installing the Package will automatically set up and mount the Mount point resource. 4) Your node''s manifest would only contain the Exec set up in step 1; everything else will automatically be configured through the defined dependency relationships. Regards, Matt. -- 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.
Matthias Viehweger
2013-Feb-13 09:41 UTC
Re: [Puppet Users] how to check whether a linux process is running?
Hi Oliver! On Tue, Feb 12, 2013 at 07:53:55PM -0800, oliver zhang wrote:> How do I do this in puppet: > > if process A is running, do nothing. > > else mount share and install package A > > I couldn''t find any reference about this.I would first ensure that the process is running (assuming that it''s a service). The service would require the package which would require the share to be mounted. A rough outline would be: service { ''A'': ensure => running, require => Package[''A'']; } package { ''A'': ensure => installed, require => Exec[''mount share'']; } exec { ''mount share'': command => ''...'', if => command to check if not mounted; } I may be wrong, of course, but this would be my first try to resolve this. Cheers, Matthias -- Serververwaltung und Softwareentwicklung https://www.heute-kaufen.de Prinzessinnenstraße 20 - 10969 Berlin
Peter Brown
2013-Feb-14 01:03 UTC
Re: [Puppet Users] how to check whether a linux process is running?
On 13 February 2013 19:41, Matthias Viehweger <m.viehweger@heute-kaufen.de>wrote:> Hi Oliver! > > On Tue, Feb 12, 2013 at 07:53:55PM -0800, oliver zhang wrote: > > How do I do this in puppet: > > > > if process A is running, do nothing. > > > > else mount share and install package A > > > > I couldn''t find any reference about this. > > I would first ensure that the process is running (assuming that it''s a > service). The service would require the package which would require the > share to be mounted. >+1 I was just about to recommend doing it in a similar way. It''s not too tricky to make a service in linux if your application isn''t already one. A rough outline would be:> > service { ''A'': > ensure => running, > require => Package[''A'']; > } > > package { ''A'': > ensure => installed, > require => Exec[''mount share'']; > } > > exec { ''mount share'': > command => ''...'', > if => command to check if not mounted; > } > > I may be wrong, of course, but this would be my first try to resolve > this. >Nope not wrong at all. I would probably recommend putting them in separate subclasses and then using class chaining or require => Class[blah::service] etc to make it easier to add new packages or services later but the theory is the same.> Cheers, > Matthias > -- > Serververwaltung und Softwareentwicklung > > https://www.heute-kaufen.de > Prinzessinnenstraße 20 - 10969 Berlin >-- 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.