Skip to content

[Bug]: puppetdb_query function fails with "Unknown function" in built images #159

Description

@bootc

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

  1. Build/run an image from this repo against OpenVoxDB.
  2. In a manifest, call puppetdb_query(...) (e.g. for an exported-resource-style lookup).
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions