Issue #13429 has been updated by Chris Price.
I've explored this a bit further. There are several things going on, not all of which are entirely related to this ticket... but recording them for posterity. 1. The code in the puppetral agent attempts to use the Resource.indirector directly, which is not officially part of the API as far as I know... and this breaks because of changes related to #7749. The changes related to that introduce an expectation that your application/face will have called Puppet::Util::Settings#initialize_app_defaults before you try to do anything. If you run any puppet "application"--or any Face via the cli (which therefore inherits from Application), you're OK. Here, we're not doing that, so the state is never fully initialized... so it fails. 2. There is a puppet "resource" application which appears to be entirely separate from the puppet "resource" face--this is very confusing, both w/rt help documentation and for users/developers. If you run "puppet resource" from the CLI, I think you are getting the application (and *not* the face), although "puppet help" appears to show documentation for the face only. 3. The puppet "resource" face documentation shows an example that looks like it is meant to support exactly what the puppetral agent needs. However, it seems that the changes from #7749 have broken the ability to use the face in this way. I need to dig into this a bit further but my initial expectations are that: 1. We will probably need to create a new ticket to explore issue # 2 above re: "puppet help" and how it behaves when there are (unrelated) faces and applications that share the same name, and 2. To address the problem highlighted by this ticket, we will need to provide some for faces that are instantiated programatically (i.e. not from the CLI, not via their application-stub counterparts) to do the equivalent of "Puppet::Util::Settings#initialize_app_defaults"... or the equivalent of what happens in the first few steps of "Puppet::Util::CommandLine#execute" (#parse_global_options and Puppet.settings.parse). That shouldn't be too hard as long as we can find a common code path that allows us to identify that a Face is being loaded without having been launched from the command line. Will revisit in the morning with a fresh set of eyes. ---------------------------------------- Bug #13429: Puppet::Resource fails when used from scripts https://projects.puppetlabs.com/issues/13429#change-61308 Author: Matt Robinson Status: Accepted Priority: Normal Assignee: Chris Price Category: Target version: Telly Affected Puppet version: Keywords: Branch: Something changed in the master branch in commit:e465c160d6d6c592a86aba2db74c5c9e5cb0ecab that broke the way mcollective's puppetral agent uses Puppet::Resource. It used to be the following would work to create a puppet resource: require 'puppet' Puppet.settings.parse resource = Puppet::Resource.new('file', '/tmp/blahd', :parameters => { :ensure ='present', :content => "blahd" }) result, report = Puppet::Resource.indirection.save(resource) Now running that gets the following error: /Users/matthewrobinson/work/puppet/lib/puppet/util/settings.rb:838:in `value': Error converting value for param 'statedir': Could not find value for $vardir (Puppet::SettingsError) from /Users/matthewrobinson/work/puppet/lib/puppet/util/settings.rb:50:in `[]' from /Users/matthewrobinson/work/puppet/lib/puppet.rb:65:in `[]' from /Users/matthewrobinson/work/puppet/lib/puppet/util/storage.rb:47:in `load' from /Users/matthewrobinson/work/puppet/lib/puppet/resource/catalog.rb:130:in `apply' from /Users/matthewrobinson/work/puppet/lib/puppet/indirector/resource/ral.rb:30:in `save' from /Users/matthewrobinson/work/puppet/lib/puppet/indirector/indirection.rb:271:in `save' from /Users/matthewrobinson/resource.rb:4 -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://projects.puppetlabs.com/my/account -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
