Catalog compilation that calls the puppetdb_query function fails with Unknown function: 'puppetdb_query', even though the PuppetDB termini are installed in the image and the indirector terminus and report processor (storeconfigs, reports) work correctly.
Affected versions
- openvox-server image built from this repo (observed on the Ubuntu image)
openvox 8.27.0 / openvoxdb 8.14.1
Steps to reproduce
- Build/run an image from this repo against OpenVoxDB.
- In a manifest, call
puppetdb_query(...) (e.g. for an exported-resource-style lookup).
- Compile a catalog for any node.
Expected
puppetdb_query resolves and queries PuppetDB.
Actual
Compilation fails:
Puppet Evaluation Error: Unknown function: 'puppetdb_query'. (file: .../manifests/sshd.pp, line: 77, column: 3)
.../openvox-8.27.0/lib/puppet/pops/evaluator/runtime3_support.rb:40:in `optionally_fail'
...
Root cause
prep_build_container.sh installs the termini into /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/, which is on puppetserver's ruby-load-path. That covers the terminus and report processor, which load via Ruby require — hence storeconfigs/reports work.
But modern Puppet 4 functions (puppet/functions/puppetdb_query.rb) are not loaded via ruby-load-path. They are loaded by Puppet's Pops system loader, which is rooted only at puppet's own lib directory (module_loaders.rb, system_loader_from):
puppet_lib = File.realpath(File.join(File.dirname(__FILE__), '../../..'))
Before #141 the images installed from the OS packages, where the openvoxdb-termini deb colocated the termini with the vendored puppet in vendor_ruby, so the system loader found them. #141 moved the build onto a gem-installed openvox, so that root is now the gem's lib dir (.../jruby-gems/gems/openvox-<ver>/lib), not vendor_ruby. The termini's puppet/functions/ is therefore no longer on any function-loader search root, and puppetdb_query is never found.
Possible fixes
- Colocate the termini's
puppet/ tree with the openvox gem lib (mirrors the OS-package layout; no pluginsync impact).
- Or ship the termini as a module on
basemodulepath (version-independent; note this also exposes them to agent pluginsync).
I'll open a PR using the first approach, but happy to switch to the second if you'd prefer it.
Catalog compilation that calls the
puppetdb_queryfunction fails withUnknown function: 'puppetdb_query', even though the PuppetDB termini are installed in the image and the indirector terminus and report processor (storeconfigs, reports) work correctly.Affected versions
openvox8.27.0 /openvoxdb8.14.1Steps to reproduce
puppetdb_query(...)(e.g. for an exported-resource-style lookup).Expected
puppetdb_queryresolves and queries PuppetDB.Actual
Compilation fails:
Root cause
prep_build_container.shinstalls the termini into/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/, which is on puppetserver'sruby-load-path. That covers the terminus and report processor, which load via Rubyrequire— hence storeconfigs/reports work.But modern Puppet 4 functions (
puppet/functions/puppetdb_query.rb) are not loaded viaruby-load-path. They are loaded by Puppet's Pops system loader, which is rooted only at puppet's own lib directory (module_loaders.rb,system_loader_from):Before #141 the images installed from the OS packages, where the
openvoxdb-terminideb colocated the termini with the vendored puppet invendor_ruby, so the system loader found them. #141 moved the build onto a gem-installedopenvox, so that root is now the gem's lib dir (.../jruby-gems/gems/openvox-<ver>/lib), notvendor_ruby. The termini'spuppet/functions/is therefore no longer on any function-loader search root, andpuppetdb_queryis never found.Possible fixes
puppet/tree with the openvox gem lib (mirrors the OS-package layout; no pluginsync impact).basemodulepath(version-independent; note this also exposes them to agent pluginsync).I'll open a PR using the first approach, but happy to switch to the second if you'd prefer it.