Puppet 0.24.8. I''m building a custom type and have run into a bit of a snag. If I try to require another plugin, my type fails to load on the "Retrieving plugins" stage of the client run. I''ve tried to isolate this from my code by running extremely simple plugins. Here''s my custom type (called by the relevant init.pp): --------------------------------------------- # puppet/modules/testmodule/plugins/puppet/type/testtype.rb require ''puppet/external/testing'' module Puppet newtype(:testtype) do newparam(:target) do desc "The path to the configuration file we''re editing" defaultto "/usr/local/etc/testfile" end newparam(:name, :namevar => true) do desc "The name" end newproperty(:ensure) do desc "Basic state" newvalue :present newvalue :absent def retrieve File.exists?(@resource[:target]) ? :present : :absent end end end end --------------------------------------------- Here''s puppet/external/testing: --------------------------------------------- # puppet/modules/testmodule/plugins/puppet/external/testing.rb class JustTesting end --------------------------------------------- Both plugins are getting synced up correctly to the client machine (under /var/puppet/lib), but if the client runs like this I end up with the following error: err: Could not retrieve catalog: Could not find resource type testtype at /usr/local/etc/puppet/modules/testmodule/manifests/init.pp:119 on node testbox If I comment out the "require" line in testtype.rb, it runs just fine. If I change that line to require something builtin like puppet/external/lock, it works. Am I doing something wrong here? -Shawn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
jcbollinger
2009-Jul-21 14:14 UTC
[Puppet Users] Re: Custom type fails when requiring another plugin
On Jul 16, 4:48 pm, S H <shdashb...@gmail.com> wrote:> Puppet 0.24.8. > > I''m building a custom type and have run into a bit of a snag. If I try to > require another plugin, my type fails to load on the "Retrieving plugins" > stage of the client run. > > I''ve tried to isolate this from my code by running extremely simple plugins. > Here''s my custom type (called by the relevant init.pp): > --------------------------------------------- > # puppet/modules/testmodule/plugins/puppet/type/testtype.rb > require ''puppet/external/testing''...> Here''s puppet/external/testing: > --------------------------------------------- > # puppet/modules/testmodule/plugins/puppet/external/testing.rb > class JustTesting > end > --------------------------------------------- > > Both plugins are getting synced up correctly to the client machine (under > /var/puppet/lib), but if the client runs like this I end up with the > following error: > > err: Could not retrieve catalog: Could not find resource type testtype at > /usr/local/etc/puppet/modules/testmodule/manifests/init.pp:119 on node > testbox > > If I comment out the "require" line in testtype.rb, it runs just fine. If I > change that line to require something builtin like puppet/external/lock, it > works. > > Am I doing something wrong here?It would seem so. :-) I don''t claim to be an expert here, but since you haven''t gotten any other answers yet, I''ll throw out an idea or two. Mainly, I suspect you have a path problem. In my limited experience, puppet both performs and relies upon a fair amount of path magic. If you put your plugin classes in the right (relative) directories then everything Just Works; if you don''t, then it falls flat. I haven''t done what you''re attempting, but the first things I would try are to cut prefixes from your require path one at a time, and to attempt to use the class without first ''require''ing it. Good luck. John --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
S H
2009-Jul-22 15:11 UTC
[Puppet Users] Re: Custom type fails when requiring another plugin
On Tue, Jul 21, 2009 at 10:14 AM, jcbollinger <John.Bollinger@stjude.org>wrote:> > > On Jul 16, 4:48 pm, S H <shdashb...@gmail.com> wrote: > > Puppet 0.24.8. > > > > I''m building a custom type and have run into a bit of a snag. If I try to > > require another plugin, my type fails to load on the "Retrieving plugins" > > stage of the client run. > > > > I''ve tried to isolate this from my code by running extremely simple > plugins. > > Here''s my custom type (called by the relevant init.pp): > > --------------------------------------------- > > # puppet/modules/testmodule/plugins/puppet/type/testtype.rb > > require ''puppet/external/testing'' > > ... > > > Here''s puppet/external/testing: > > --------------------------------------------- > > # puppet/modules/testmodule/plugins/puppet/external/testing.rb > > class JustTesting > > end > > --------------------------------------------- > > > > Both plugins are getting synced up correctly to the client machine (under > > /var/puppet/lib), but if the client runs like this I end up with the > > following error: > > > > err: Could not retrieve catalog: Could not find resource type testtype at > > /usr/local/etc/puppet/modules/testmodule/manifests/init.pp:119 on node > > testbox > > > > If I comment out the "require" line in testtype.rb, it runs just fine. If > I > > change that line to require something builtin like puppet/external/lock, > it > > works. > > > > Am I doing something wrong here? > > It would seem so. :-) > > I don''t claim to be an expert here, but since you haven''t gotten any > other answers yet, I''ll throw out an idea or two. Mainly, I suspect > you have a path problem. In my limited experience, puppet both > performs and relies upon a fair amount of path magic. If you put your > plugin classes in the right (relative) directories then everything > Just Works; if you don''t, then it falls flat. I haven''t done what > you''re attempting, but the first things I would try are to cut > prefixes from your require path one at a time, and to attempt to use > the class without first ''require''ing it. > > Good luck. > > JohnThanks for the response. Just using it without requiring it leads to an (expected) exception: "uninitialized constant Puppet::testing" Moving the path about also hasn''t yielded any change. -Shawn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Luke Kanies
2009-Jul-22 17:56 UTC
[Puppet Users] Re: Custom type fails when requiring another plugin
On Jul 16, 2009, at 2:48 PM, S H wrote:> Puppet 0.24.8. > > I''m building a custom type and have run into a bit of a snag. If I > try to require another plugin, my type fails to load on the > "Retrieving plugins" stage of the client run.Puppet immediately loads all downloaded ruby files, with the expectation that it is often reloading files that are already in memory. If the plugins are downloaded in the wrong order (i.e., the requiring file and then the required file), you''ve got a problem. Truthfully, this is the first time this has ever come up. A reasonable fix would be to wait until all files are downloaded before we load any files. If I publish a branch with a fix for this, would you be able to test it? It''d be against the ''master'' branch.> > I''ve tried to isolate this from my code by running extremely simple > plugins. Here''s my custom type (called by the relevant init.pp): > --------------------------------------------- > # puppet/modules/testmodule/plugins/puppet/type/testtype.rb > require ''puppet/external/testing'' > > module Puppet > newtype(:testtype) do > > newparam(:target) do > desc "The path to the configuration file we''re editing" > defaultto "/usr/local/etc/testfile" > end > > newparam(:name, :namevar => true) do > desc "The name" > end > > newproperty(:ensure) do > desc "Basic state" > newvalue :present > newvalue :absent > > def retrieve > File.exists?(@resource[:target]) ? :present : :absent > end > > end > end > end > --------------------------------------------- > > > Here''s puppet/external/testing: > --------------------------------------------- > # puppet/modules/testmodule/plugins/puppet/external/testing.rb > class JustTesting > end > --------------------------------------------- > > Both plugins are getting synced up correctly to the client machine > (under /var/puppet/lib), but if the client runs like this I end up > with the following error: > > err: Could not retrieve catalog: Could not find resource type > testtype at /usr/local/etc/puppet/modules/testmodule/manifests/ > init.pp:119 on node testbox > > If I comment out the "require" line in testtype.rb, it runs just > fine. If I change that line to require something builtin like puppet/ > external/lock, it works. > > Am I doing something wrong here?I *highly* recommend you do all your development in a non-networked test environment relying entirely on the ''puppet'' executable, rather than puppetd and puppetmasterd. Isolate your problems there, and only once you''re sure it''s all working should you switch to the client/ server testing. What behaviour do you get there? -- In science, ''fact'' can only mean ''confirmed to such a degree that it would be perverse to withhold provisional assent.'' I suppose that apples might start to rise tomorrow, but the possibility does not merit equal time in physics classrooms. -- Stephen Jay Gould --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
S H
2009-Jul-22 18:32 UTC
[Puppet Users] Re: Custom type fails when requiring another plugin
On Wed, Jul 22, 2009 at 1:56 PM, Luke Kanies <luke@madstop.com> wrote:> > On Jul 16, 2009, at 2:48 PM, S H wrote: > > > Puppet 0.24.8. > > > > I''m building a custom type and have run into a bit of a snag. If I > > try to require another plugin, my type fails to load on the > > "Retrieving plugins" stage of the client run. > > Puppet immediately loads all downloaded ruby files, with the > expectation that it is often reloading files that are already in > memory. If the plugins are downloaded in the wrong order (i.e., the > requiring file and then the required file), you''ve got a problem. > > Truthfully, this is the first time this has ever come up. A > reasonable fix would be to wait until all files are downloaded before > we load any files. > > If I publish a branch with a fix for this, would you be able to test > it? It''d be against the ''master'' branch.Sure, that''s no problem.> > > > I''ve tried to isolate this from my code by running extremely simple > > plugins. Here''s my custom type (called by the relevant init.pp): > > --------------------------------------------- > > # puppet/modules/testmodule/plugins/puppet/type/testtype.rb > > require ''puppet/external/testing'' > > > > module Puppet > > newtype(:testtype) do > > > > newparam(:target) do > > desc "The path to the configuration file we''re editing" > > defaultto "/usr/local/etc/testfile" > > end > > > > newparam(:name, :namevar => true) do > > desc "The name" > > end > > > > newproperty(:ensure) do > > desc "Basic state" > > newvalue :present > > newvalue :absent > > > > def retrieve > > File.exists?(@resource[:target]) ? :present : :absent > > end > > > > end > > end > > end > > --------------------------------------------- > > > > > > Here''s puppet/external/testing: > > --------------------------------------------- > > # puppet/modules/testmodule/plugins/puppet/external/testing.rb > > class JustTesting > > end > > --------------------------------------------- > > > > Both plugins are getting synced up correctly to the client machine > > (under /var/puppet/lib), but if the client runs like this I end up > > with the following error: > > > > err: Could not retrieve catalog: Could not find resource type > > testtype at /usr/local/etc/puppet/modules/testmodule/manifests/ > > init.pp:119 on node testbox > > > > If I comment out the "require" line in testtype.rb, it runs just > > fine. If I change that line to require something builtin like puppet/ > > external/lock, it works. > > > > Am I doing something wrong here? > > I *highly* recommend you do all your development in a non-networked > test environment relying entirely on the ''puppet'' executable, rather > than puppetd and puppetmasterd. Isolate your problems there, and only > once you''re sure it''s all working should you switch to the client/ > server testing. > > What behaviour do you get there?Until now, I was unaware of the puppet executable. Good to know, thanks. The output I get is: # puppet init.pp /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31: command not found: # The context of that line: 30 def require(path) # :doc: 31 gem_original_require path 32 rescue LoadError => load_error 33 if load_error.message =~ /#{Regexp.escape path}\z/ and 34 spec = Gem.searcher.find(path) then 35 Gem.activate(spec.name, "= #{spec.version}") 36 gem_original_require path 37 else 38 raise load_error 39 end 40 end Maybe I''m not running this executable correctly? Thanks for the help. -Shawn> > > -- > In science, ''fact'' can only mean ''confirmed to such a degree that it > would be perverse to withhold provisional assent.'' I suppose that > apples might start to rise tomorrow, but the possibility does not > merit equal time in physics classrooms. -- Stephen Jay Gould > --------------------------------------------------------------------- > Luke Kanies | http://reductivelabs.com | http://madstop.com > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---