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

2012-09-09 Thread Jakov Sosic

On 09/09/2012 06:38 AM, Sébastien Lavoie wrote:

I am not experienced in creating facts, could you give me a better idea
? I fail to see how a fact could detect if a service is required.


And how do you determine if it's required? By hostname, or?


--
Jakov Sosic
www.srce.unizg.hr

--
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 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] Re: Could not render to pson: undefined method 'merge' for []:Array

2012-09-09 Thread Jon McKenzie
I'm having this issue as well, with a nearly identical stack trace (I'm 
running on RHEL, however).

Anyone have any ideas?

I stuck some debugs inside my provider methods, but they don't ever seem to 
get executed.

On Wednesday, July 11, 2012 4:08:42 PM UTC-4, Micah Martin wrote:

 This ones got me absolutely scratching my head. I'm trying to created a 
 custom type for managing couchbase. It may not be the right approach but 
 I'm a total noob and I'm trying to figure this thing out. Here's what I 
 have:

 */Puppet/manifests/site.pp*

 node 'qamachine' {

 include webserver

 }



 */Puppet/modules/webserver/init.pp*

 class webserver {

 couchbase { 'test': }

 }


 */Puppet/modules/couchbase/lib/puppet/type/couchbase.rb*

 Puppet::Type.newtype(:couchbase) do

  newparam(:name) do

 isnamevar

 end

 end


 */Puppet/modules/couchbase/lib/puppet/provider/couchbase/couchbase.rb*

 Puppet::Type.type(:couchbase).provide(:couchbase) do



 end



 When I try to update the machine this is what I get:

 info: Loading downloaded plugin 
 C:/ProgramData/PuppetLabs/puppet/var/lib/puppet/type/couchbase.rb
 info: Loading downloaded plugin 
 C:/ProgramData/PuppetLabs/puppet/var/lib/puppet/provider/couchbase/couchbase.rb
 debug: Reloading couchbase couchbase provider
 debug: catalog supports formats: b64_zlib_yaml dot pson raw yaml; using 
 pson
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/indirector/rest.rb:56:in `deserialize'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/indirector/rest.rb:120:in `find'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/indirector/indirection.rb:196:in `find'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/configurer.rb:240:in `retrieve_new_catalog'
 C:/Program Files (x86)/Puppet Labs/Puppet/puppet/lib/puppet/util.rb:490:in 
 `thinmark'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/sys/ruby/lib/ruby/1.8/benchmark.rb:308:in `realtime'
 C:/Program Files (x86)/Puppet Labs/Puppet/puppet/lib/puppet/util.rb:489:in 
 `thinmark'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/configurer.rb:239:in `retrieve_new_catalog'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/configurer.rb:86:in `retrieve_catalog'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/configurer.rb:112:in 
 `retrieve_and_apply_catalog'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/configurer.rb:152:in `run'
 C:/Program Files (x86)/Puppet Labs/Puppet/puppet/lib/puppet/agent.rb:43:in 
 `run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/agent/locker.rb:21:in `lock'
 C:/Program Files (x86)/Puppet Labs/Puppet/puppet/lib/puppet/agent.rb:43:in 
 `run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/sys/ruby/lib/ruby/1.8/sync.rb:230:in `synchronize'
 C:/Program Files (x86)/Puppet Labs/Puppet/puppet/lib/puppet/agent.rb:43:in 
 `run'
 C:/Program Files (x86)/Puppet Labs/Puppet/puppet/lib/puppet/agent.rb:95:in 
 `with_client'
 C:/Program Files (x86)/Puppet Labs/Puppet/puppet/lib/puppet/agent.rb:41:in 
 `run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application.rb:172:in `call'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application.rb:172:in `controlled_run'
 C:/Program Files (x86)/Puppet Labs/Puppet/puppet/lib/puppet/agent.rb:39:in 
 `run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application/agent.rb:337:in `onetime'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application/agent.rb:311:in `run_command'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application.rb:309:in `run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application.rb:416:in `hook'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application.rb:309:in `run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application.rb:407:in `exit_on_fail'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application.rb:309:in `run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/util/command_line.rb:69:in `execute'
 C:/Program Files (x86)/Puppet Labs/Puppet/puppet/bin/puppet:4
 err: Could not retrieve catalog from remote server: Error 400 on SERVER: 
 Could not render to pson: undefined method `mer
 ge' for []:Array

 when I remove the call to couchbase in the init.pp file it works fine. 


-- 
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/-/5nFH3c0T45oJ.
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] Re: Could not render to pson: undefined method 'merge' for []:Array

2012-09-09 Thread Jon McKenzie
I restarted my puppetmaster and this seemed to resolve the issue. Very 
strange message, though. I suppose if I've defined a new type, but haven't 
restarted puppetmaster it throws a message like this? I will need to test 
that though

On Sunday, September 9, 2012 4:16:53 PM UTC-4, Jon McKenzie wrote:

 I'm having this issue as well, with a nearly identical stack trace (I'm 
 running on RHEL, however).

 Anyone have any ideas?

 I stuck some debugs inside my provider methods, but they don't ever seem 
 to get executed.

 On Wednesday, July 11, 2012 4:08:42 PM UTC-4, Micah Martin wrote:

 This ones got me absolutely scratching my head. I'm trying to created a 
 custom type for managing couchbase. It may not be the right approach but 
 I'm a total noob and I'm trying to figure this thing out. Here's what I 
 have:

 */Puppet/manifests/site.pp*

 node 'qamachine' {

 include webserver

 }



 */Puppet/modules/webserver/init.pp*

 class webserver {

 couchbase { 'test': }

 }


 */Puppet/modules/couchbase/lib/puppet/type/couchbase.rb*

 Puppet::Type.newtype(:couchbase) do

  newparam(:name) do

 isnamevar

 end

 end


 */Puppet/modules/couchbase/lib/puppet/provider/couchbase/couchbase.rb*

 Puppet::Type.type(:couchbase).provide(:couchbase) do



 end



 When I try to update the machine this is what I get:

 info: Loading downloaded plugin 
 C:/ProgramData/PuppetLabs/puppet/var/lib/puppet/type/couchbase.rb
 info: Loading downloaded plugin 
 C:/ProgramData/PuppetLabs/puppet/var/lib/puppet/provider/couchbase/couchbase.rb
 debug: Reloading couchbase couchbase provider
 debug: catalog supports formats: b64_zlib_yaml dot pson raw yaml; using 
 pson
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/indirector/rest.rb:56:in `deserialize'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/indirector/rest.rb:120:in `find'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/indirector/indirection.rb:196:in `find'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/configurer.rb:240:in `retrieve_new_catalog'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/util.rb:490:in `thinmark'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/sys/ruby/lib/ruby/1.8/benchmark.rb:308:in `realtime'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/util.rb:489:in `thinmark'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/configurer.rb:239:in `retrieve_new_catalog'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/configurer.rb:86:in `retrieve_catalog'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/configurer.rb:112:in 
 `retrieve_and_apply_catalog'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/configurer.rb:152:in `run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/agent.rb:43:in `run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/agent/locker.rb:21:in `lock'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/agent.rb:43:in `run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/sys/ruby/lib/ruby/1.8/sync.rb:230:in `synchronize'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/agent.rb:43:in `run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/agent.rb:95:in `with_client'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/agent.rb:41:in `run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application.rb:172:in `call'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application.rb:172:in `controlled_run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/agent.rb:39:in `run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application/agent.rb:337:in `onetime'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application/agent.rb:311:in `run_command'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application.rb:309:in `run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application.rb:416:in `hook'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application.rb:309:in `run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application.rb:407:in `exit_on_fail'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/application.rb:309:in `run'
 C:/Program Files (x86)/Puppet 
 Labs/Puppet/puppet/lib/puppet/util/command_line.rb:69:in `execute'
 C:/Program Files (x86)/Puppet Labs/Puppet/puppet/bin/puppet:4
 err: Could not retrieve catalog from remote server: Error 400 on SERVER: 
 Could not render to pson: undefined method `mer
 ge' for []:Array

 when I remove the call to couchbase in the init.pp file it works fine. 



-- 
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/-/aD2AXUCkWhMJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe 

Re: [Puppet Users] Question: Custom puppet type for semanage, converting inputs to flags?

2012-09-09 Thread Jon McKenzie
Hi Dan, 

Thanks for the input. If I were to implement this in the provider, what 
would be the proper way to do that? Is there a validation/conversion hook I 
can override?

On Sunday, September 9, 2012 1:55:17 PM UTC-4, Dan Bode wrote:



 On Sun, Sep 9, 2012 at 10:46 AM, Jon McKenzie jcm...@gmail.comjavascript:
  wrote:

 Hi,

 I'm just trying to get an idea about the best way to implement this:

 I want a type that uses the 'semanage' binary to manage targeted policy 
 (in this case for files).

 So for example to create a targeted policy, I might do something like:

 semanage fcontext -a -f -d -t some_domain_t /path/to/files(/.*)?

 ... which would add a target policy that sets 'some_domain_t' on all 
 directories in /path/to/files/

 The question I have is about the -d, which is a parameter to -f, that 
 directs policy to only cover directories (e.g. -d is for directories,  
 -- is for regular files, -s is for sockets, etc. -- see the help for 
 semanage for the rest).

 I want a property called :filetype that can have a value of :file, 
 :directory, :all, :socket, :character, :block, etc. Once I get valid input, 
 I want to convert the value to the appropriate flag for the command. What's 
 the best way to do this?

 My current idea is to accept any input, and then have a case switch 
 inside of a munge block, e.g.:

 munge do |value|
   case value
   when file
 value = --
   when directory
 value = -d
   ... etc..
   end
 end

 Is this the correct way to implement this?


 The syntax here looks correct. You may also want to use newvalues to 
 restrict the values that are allowed.
  

 Should this even be in the type definition (since these are details of 
 the provider)?


 That is a really good point. It would be more consistent with the model if 
 this munging was done in the provider. Of coarse in only really 'matters' 
 if you think the type will have multiple providers.
  


 Thanks for your help,
 Jon

 -- 
 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/-/1PVDZB_Cw2QJ.
 To post to this group, send email to puppet...@googlegroups.comjavascript:
 .
 To unsubscribe from this group, send email to 
 puppet-users...@googlegroups.com javascript:.
 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 view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/5nVGbDoO7bAJ.
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] access exported resources in template

2012-09-09 Thread Luke Kanies
I don't quite know the answer, and I agree, a running shell would be useful.

I'd be looking in Parser::Scope and the TemplateWrapper class, wherever it is.  
Those should generally cover it, with maybe Parser::Resource.

You should try deeper inspection of the resources.  I think 'resource.to_hash' 
should give you all of the resource's parameters.

On Sep 7, 2012, at 6:01 AM, ctrlc-root root.ct...@gmail.com wrote:

 Well, 3 years old or not, this is still in the first page of google results 
 haha. I'm running puppet version 2.7.9 and the result of that template is a 
 blank comment line for every instance of the Firewall::Rule type. If I 
 replace 'resource[:comment]' with 'resource.type' then I can confirm that the 
 iteration is actually working, because I see comment lines like this '# 
 Firewall::Rule'. I tried 'resources[comment]', 'resources[:comment]', and 
 'resources.comment' (with this one triggering an error).
 
 I wish there was some easy way to get an interactive ruby shell running with 
 the same environment so I could actually test this without running puppet 
 apply every time, if I could I probably would have figured it out on my own 
 already. If you don't know what the answer is, could you maybe point me in 
 the general direction of how you would find out? Perhaps a relevant part of 
 the puppet source code? And thanks for answering.
 
 On Friday, September 7, 2012 12:52:14 AM UTC-4, Luke Kanies wrote:
 Wow, talk about a blast from the past.  I don't get a lot of replies to 3 
 year old email. :)
 
 What happens when you do this?  It looks like it should basically work, 
 although I'd use 'resources' instead of 'vertices', I think.  What version is 
 this?
 
 -- 
 Luke Kanies | http://about.me/lak | http://puppetlabs.com/ | +1-615-594-8199
 
 
 -- 
 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/-/XEXWIRbxz9kJ.
 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.


-- 
Luke Kanies | http://about.me/lak | http://puppetlabs.com/ | +1-615-594-8199

-- 
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] puppet installation on windows7

2012-09-09 Thread Ryan Coleman
On Thu, Aug 30, 2012 at 3:31 AM, valar mathi arimath...@gmail.com wrote:
 when puppet installed in windows7 and when the run puppet agent is clicked
 im getting certificate retrieval error.plz suggest me a solution.thanks.

Hi Valar,

When you installed Puppet on Windows, one of the details you filled in
was the DNS address of your Puppet Master (defaults to puppet). The
agent will contact this address the first time it starts up to create
and submit a certificate for signing on that Puppet Master. Without
more information, my best guess is that the agent isn't pointing at a
Puppet Master to complete this step.

If you're without a Puppet Master, you'll have to use something other
than Windows to run it but it's a fairly trivial install (at least for
Puppet Enterprise). Here's some more information on that from our docs
site: 
http://docs.puppetlabs.com/windows/installing.html#puppet-master-requirements

Hope that helps!

--Ryan

-- 
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.