Hello I need some help with a problem I cant figure out. I tried to look for the same problem in the puppet forums but I couldn''t find anything. I have created a custom Type and a custom Provider but I keep getting the same error not matter what I do. So any help will very appreciated. My Type is called ''servicemanager'' My Provider is called ''hostmanager'' Please see attachment for these files. And my manifest file looks like: servicemanager{ "some_name": artifact => "some_name", action => stopped, release => $releases_file, provider => hostmanager; } But I keep getting the following error message: err: /Stage[main]/some_name/Servicemanager[some_name]: Could not evaluate: No ability to determine if servicemanager exists OR err: Could not run Puppet configuration client: No ability to determine if servicemanager exists I even tried adding a def exists? function in hostmanager.rb and that didnt help. BTW.. I have "pluginsync = true" on both client and the master in puppet.conf. Also my Type "servicemanager.rb" is in " /etc/puppet/modules/custom/lib/puppet/type", and my Provider "hostmanager.rb" is in " /etc/puppet/modules/custom/lib/puppet/provider/servicemanager" Thanks Umair -- 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 Thu, Dec 16, 2010 at 01:45:17PM -0600, Umair Ghani wrote:> Hello >[...]> > But I keep getting the following error message: > err: /Stage[main]/some_name/Servicemanager[some_name]: Could not evaluate: > No ability to determine if servicemanager exists > > OR > err: Could not run Puppet configuration client: No ability to determine if > servicemanager exists > > I even tried adding a def exists? function in hostmanager.rb and that didnt > help. >Puppet handles states not actions. So if you want to define that a service is running, puppet must have the ability to query if it''s running already. my comments (your problem is #3 and #4) 1. you use one property for two things. What if you want to say that your service is installed and running? 2. restarted is not really a state. But you can define that your restart method should get called upon refresh (look in service.rb how such a refresh method can be defined) 3. you said ensurable. That''s just a shortcut to say that you have an ensure property which handles absent and present. This means that your type (or preferable the provider) must have three functions: - exists? to retrieve the current state - create to create your type if it does not exist while it should - destroy to delete your type if it does exists while it should not If an ensure property doesnt make any sense for your type dont say ensurable 4. Your action property doesnt have any retrieve method so puppet cannot check if this property is in sync or not. Because I guess a servicemanager resource can be installed AND running, you should split that at least in two properties. Then you have to define a retrieve method. The default (defined in property.rb) is to just call provider.propertyname so just add a method called »action« in hostmanager.rb. That method must return a valid value (:stopped or :running). 5. If you define commands :hostmanager => ''...'' you get a hostmanager method for free so you can just say: hostmanager ''-s'', @resource[:name], ''-r'', @resource[:release], ''--install'' If you want to have the command as a string #{:hostmanager} just converts the symbol hostmanager to a string (which is "hostmanager"). I think what you wanted to say is #{command(:hostmanager)} which will give you "/usr/local/bin/hostmanager.py" Hope that helps. -Stefan
Umair Ghani
2010-Dec-16 22:12 UTC
Re: [Puppet-dev] Re: [Puppet Users] What am I doing wrong?
YES ...that helped alot...I got it working now.. Thank you very much Umair On Thu, Dec 16, 2010 at 3:03 PM, Stefan Schulte < stefan.schulte@taunusstein.net> wrote:> On Thu, Dec 16, 2010 at 01:45:17PM -0600, Umair Ghani wrote: > > Hello > > > [...] > > > > But I keep getting the following error message: > > err: /Stage[main]/some_name/Servicemanager[some_name]: Could not > evaluate: > > No ability to determine if servicemanager exists > > > > OR > > err: Could not run Puppet configuration client: No ability to determine > if > > servicemanager exists > > > > I even tried adding a def exists? function in hostmanager.rb and that > didnt > > help. > > > > Puppet handles states not actions. So if you want to define that a service > is > running, puppet must have the ability to query if it''s running already. > > my comments (your problem is #3 and #4) > 1. you use one property for two things. What if you want to say > that your service is installed and running? > 2. restarted is not really a state. But you can define that your restart > method should get called upon refresh (look in service.rb how such a > refresh method can be defined) > 3. you said ensurable. That''s just a shortcut to say that you have an > ensure property which handles absent and present. This means that your > type (or preferable the provider) must have three functions: > - exists? to retrieve the current state > - create to create your type if it does not exist while it should > - destroy to delete your type if it does exists while it should not > If an ensure property doesnt make any sense for your type dont say > ensurable > 4. Your action property doesnt have any retrieve method so puppet cannot > check if this property is in sync or not. Because I guess a > servicemanager resource can be installed AND running, you should split > that at least in two properties. Then you have to define a retrieve > method. The default (defined in property.rb) is to just call > provider.propertyname so just add a method called »action« in > hostmanager.rb. That method must return a valid value > (:stopped or :running). > 5. If you define commands :hostmanager => ''...'' you get a hostmanager > method for free so you can just say: > hostmanager ''-s'', @resource[:name], ''-r'', @resource[:release], ''--install'' > If you want to have the command as a string #{:hostmanager} just > converts the symbol hostmanager to a string (which is "hostmanager"). I > think what you wanted to say is #{command(:hostmanager)} which will give > you "/usr/local/bin/hostmanager.py" > > Hope that helps. > > -Stefan >-- 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.
Umair Ghani
2010-Dec-17 00:34 UTC
Re: [Puppet-dev] Re: [Puppet Users] What am I doing wrong?
One more question. How can I run hostmanager as a particular user? By default it runs it as user root. Thanks Umair On Thu, Dec 16, 2010 at 4:12 PM, Umair Ghani <umairghani@gmail.com> wrote:> YES ...that helped alot...I got it working now.. > Thank you very much > Umair > > > On Thu, Dec 16, 2010 at 3:03 PM, Stefan Schulte < > stefan.schulte@taunusstein.net> wrote: > >> On Thu, Dec 16, 2010 at 01:45:17PM -0600, Umair Ghani wrote: >> > Hello >> > >> [...] >> > >> > But I keep getting the following error message: >> > err: /Stage[main]/some_name/Servicemanager[some_name]: Could not >> evaluate: >> > No ability to determine if servicemanager exists >> > >> > OR >> > err: Could not run Puppet configuration client: No ability to determine >> if >> > servicemanager exists >> > >> > I even tried adding a def exists? function in hostmanager.rb and that >> didnt >> > help. >> > >> >> Puppet handles states not actions. So if you want to define that a service >> is >> running, puppet must have the ability to query if it''s running already. >> >> my comments (your problem is #3 and #4) >> 1. you use one property for two things. What if you want to say >> that your service is installed and running? >> 2. restarted is not really a state. But you can define that your restart >> method should get called upon refresh (look in service.rb how such a >> refresh method can be defined) >> 3. you said ensurable. That''s just a shortcut to say that you have an >> ensure property which handles absent and present. This means that your >> type (or preferable the provider) must have three functions: >> - exists? to retrieve the current state >> - create to create your type if it does not exist while it should >> - destroy to delete your type if it does exists while it should not >> If an ensure property doesnt make any sense for your type dont say >> ensurable >> 4. Your action property doesnt have any retrieve method so puppet cannot >> check if this property is in sync or not. Because I guess a >> servicemanager resource can be installed AND running, you should split >> that at least in two properties. Then you have to define a retrieve >> method. The default (defined in property.rb) is to just call >> provider.propertyname so just add a method called »action« in >> hostmanager.rb. That method must return a valid value >> (:stopped or :running). >> 5. If you define commands :hostmanager => ''...'' you get a hostmanager >> method for free so you can just say: >> hostmanager ''-s'', @resource[:name], ''-r'', @resource[:release], >> ''--install'' >> If you want to have the command as a string #{:hostmanager} just >> converts the symbol hostmanager to a string (which is "hostmanager"). I >> think what you wanted to say is #{command(:hostmanager)} which will give >> you "/usr/local/bin/hostmanager.py" >> >> Hope that helps. >> >> -Stefan > >-- 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.
Stefan Schulte
2010-Dec-17 16:12 UTC
Re: [Puppet-dev] Re: [Puppet Users] What am I doing wrong?
On Thu, Dec 16, 2010 at 06:34:53PM -0600, Umair Ghani wrote:> One more question. How can I run hostmanager as a particular user? By > default it runs it as user root. > > Thanks > UmairI never used that one but puppet has a util function for that purpose (asuser defined in util/suidmanager.rb). This SHOULD work: Puppet::Util::SUIDManager.asuser(myuid, mygid) do hostmanager ''-s'', @resource[:name], ''-r'', @resource[:release], ''--install'' end You should also test @resource[:release].nil? because the user might not provide every parameter. Or you should define a default value. -Stefan
Umair Ghani
2010-Dec-17 17:26 UTC
Re: [Puppet-dev] Re: [Puppet Users] What am I doing wrong?
this works...thanks again.. Umair On Fri, Dec 17, 2010 at 10:12 AM, Stefan Schulte < stefan.schulte@taunusstein.net> wrote:> On Thu, Dec 16, 2010 at 06:34:53PM -0600, Umair Ghani wrote: > > One more question. How can I run hostmanager as a particular user? By > > default it runs it as user root. > > > > Thanks > > Umair > > I never used that one but puppet has a util function for that purpose > (asuser defined in util/suidmanager.rb). This SHOULD work: > > Puppet::Util::SUIDManager.asuser(myuid, mygid) do > hostmanager ''-s'', @resource[:name], > ''-r'', @resource[:release], ''--install'' > end > > You should also test @resource[:release].nil? because the user might not > provide every parameter. Or you should define a default value. > > -Stefan >-- 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.