Re: [Puppet Users] How can I ensure that a service is started/stopped based on if it is needed or not ?

2012-09-09 Thread R.I.Pienaar


- Original Message -
 From: Sébastien Lavoie sebast...@lavoie.sl
 To: puppet-users@googlegroups.com
 Sent: Friday, September 7, 2012 11:32:55 PM
 Subject: [Puppet Users] How can I ensure that a service is started/stopped 
 based on if it is needed or not ?
 
 I have a several services that I use only for some sites and I would
 like to make sure it is started when a site that uses is activated
 and stopped when it is not needed anymore.
 
 
 Examples: memcache, elasticsearch, rabbitmq, etc.
 
 
 I can easily make a service virtual and realize it before making a
 reference to it like this:
 
 
 class webserver {
 @service {memcache:
 ensure = running,
 }
 }
 
 
 class sites {
 Realize['memcache']
 site {example.com:
 require = Service['memcache']
 }
 }
 
 
 But this will not stop the service if it is never realized.

dont know if this helps but lets say you have a common class
you install on all nodes:

class common {
   include memcache
}

class memcache {
   service{memcache: ensure = stopped, enable = false}
}

at this point if you include common on all machines memcache will
be stopped and disabled everywhere

now you make a class specifically to include on nodes that needs
it running.

class memcache::enable inherits memcache {
   Service[memcache] { ensure = running, enable = true }
}

if you include this class on a node it will be enabled, soon
as you remove the class it will be disabled again

Generally though this is a bad idea because you also have to
consider configs, packages and all this stuff it might make
sense in your case but I think the correct thing to do is just
not to install stuff on machines that you dont need.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] How can I ensure that a service is started/stopped based on if it is needed or not ?

2012-09-09 Thread Sébastien Lavoie
@Jakov I am currently running Puppet on a single host, it is only to manage 
site configurations, so this is not a problem
@R.I. Thanks, worked like a charm. Bonus points for very simple solution.


On Sunday, September 9, 2012 7:34:10 AM UTC-4, R.I. Pienaar wrote:



 - Original Message - 
  From: Sébastien Lavoie seba...@lavoie.sl javascript: 
  To: puppet...@googlegroups.com javascript: 
  Sent: Friday, September 7, 2012 11:32:55 PM 
  Subject: [Puppet Users] How can I ensure that a service is 
 started/stopped based on if it is needed or not ? 
  
  I have a several services that I use only for some sites and I would 
  like to make sure it is started when a site that uses is activated 
  and stopped when it is not needed anymore. 
  
  
  Examples: memcache, elasticsearch, rabbitmq, etc. 
  
  
  I can easily make a service virtual and realize it before making a 
  reference to it like this: 
  
  
  class webserver { 
  @service {memcache: 
  ensure = running, 
  } 
  } 
  
  
  class sites { 
  Realize['memcache'] 
  site {example.com: 
  require = Service['memcache'] 
  } 
  } 
  
  
  But this will not stop the service if it is never realized. 

 dont know if this helps but lets say you have a common class 
 you install on all nodes: 

 class common { 
include memcache 
 } 

 class memcache { 
service{memcache: ensure = stopped, enable = false} 
 } 

 at this point if you include common on all machines memcache will 
 be stopped and disabled everywhere 

 now you make a class specifically to include on nodes that needs 
 it running. 

 class memcache::enable inherits memcache { 
Service[memcache] { ensure = running, enable = true } 
 } 

 if you include this class on a node it will be enabled, soon 
 as you remove the class it will be disabled again 

 Generally though this is a bad idea because you also have to 
 consider configs, packages and all this stuff it might make 
 sense in your case but I think the correct thing to do is just 
 not to install stuff on machines that you dont need. 


-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/6PzT8Tk2cMwJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



[Puppet Users] How can I ensure that a service is started/stopped based on if it is needed or not ?

2012-09-08 Thread Sébastien Lavoie
I have a several services that I use only for some sites and I would like 
to make sure it is started when a site that uses is activated and stopped 
when it is not needed anymore.

Examples: memcache, elasticsearch, rabbitmq, etc.

I can easily make a service virtual and realize it before making a 
reference to it like this:

class webserver {
  @service {memcache:
ensure = running,
  }
}

class sites {
  Realize['memcache']
  site {example.com:
require = Service['memcache']
  }
}

But this will not stop the service if it is never realized.

Any ideas ?

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/UrHwRHoRbTIJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



[Puppet Users] How can I ensure that a service is started/stopped based on if it is needed or not ?

2012-09-08 Thread Glenn Poston
You could create a fact that returns true or false, then use that fact in your 
puppet code to determine whether to start the service.  I'd need more details 
to really say that's the best solution though.  Other options would be to use 
heira or to use a parameterized class and set those parameters in your ENC/mode 
definition.

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/yoOmxcLYlVAJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.