hiera-http icon indicating copy to clipboard operation
hiera-http copied to clipboard

Can't make v3 to work, undefined method `exist?' for :URI::HTTP

Open den-is opened this issue 7 years ago • 5 comments

Trying to add hiera_http to my PE for couple days already. But no luck :/ Already can't see where to look for the issue.

hiera-http v3 puppet pe 2017.1 lookup_http 1.0.3

Debug: Runtime environment: puppet_version=4.9.4, ruby_version=2.1.9, run_mode=agent, default_encoding=UTF-8

Only error I'm getting is:

Info: Using configured environment 'development'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Puppet::Parser::Compiler failed with error NoMethodError: undefined method `exist?' for :URI::HTTP on node i-048d3b34aa9cdce30.elastic.aws.example.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

debug output shows nothing special can't see anything useful in server logs as well :/

installed lookup_http like everywhere And yes, first trying to run setup on my test node in development environment.. but have installed hiera_http module in production as well.

here is hiera config

version: 5
defaults:
  datadir: data
  data_hash: yaml_data
hierarchy:
  - name: "REST datastore"
    lookup_key: hiera_http
    uris:
      - http://localhost:5984/hiera/common
    options:
      output: json
      ignore_404: true
curl -s 'http://localhost:5984/hiera/common' | jq
{
  "_id": "common",
  "_rev": "1-7da81ab091a7992a62d9aae7281f70a8",
  "hierahttp": "hooray! it works"
}

tried uri instead of uris tried to disable hiera 'defaults' and couple other classic yaml hierarchies leaving only hiera_http... Nothing changes this error

den-is avatar May 19 '17 17:05 den-is

  1. Thought that i forgot to restart pe-puppetserver, was doing only reloads - restart didn't help
  2. Again, removed everything from dev-envs hiera.yaml except hiera_http hierarchy definition - same, nothing worked
  3. Tried to enable hiera_http in production environment - same error
puppet lookup hierahttp
Error: Could not run: Puppet::Parser::Compiler failed with error NoMethodError: undefined method `exist?' for #<URI::HTTP:0x000000048f5ee0>

Installed absolutely fresh puppet pe 2017.2.1, without anything else installed. Only hiera_http in production env - worked

Confused

den-is avatar May 20 '17 18:05 den-is

Updating to 2017.1.0 -> 2017.2.1 helped. Everything worked - magic, haven't found actual cause of the issue.

These install steps were sufficient:

puppetserver gem install lookup_http
puppet module install crayfishx-hiera_http

Also good to have notice in instructions that puppet reload won't work, only complete restart of service.

den-is avatar May 22 '17 10:05 den-is

Had the same problem. We were using the version 9.4.2 of Puppet. We found out that the problem was in this file: /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/lookup/lookup_key_function_provider.rb

More precisely in this method:

def lookup_key(key, lookup_invocation, location, merge) 
    unless location.nil? || location.exist? # This line is the origin of the exception
      lookup_invocation.report_location_not_found
      throw :no_such_key
    end
    ctx = function_context(lookup_invocation, location)
    ctx.data_hash ||= {
    ...
end

The direct cause is that the object URI used in hiera hierarchy does not have an exist? method, causing the undefined method exception. Here is the link for the correction: https://tickets.puppetlabs.com/browse/PUP-7327

It's a bug that is fixed in the version 4.10.x of Puppet. So I guess that it started working because you used a newer version of Puppet. :)

Best regards

thedronekiller avatar Jun 13 '17 18:06 thedronekiller

@thedronekiller @den-is hiera-http 3.0 (the data provider function) is only meant for use in Puppet 4.10 - as stated in the README, so if this doesn't affect 4.10+ then theres no further action needed here

crayfishx avatar Jun 14 '17 06:06 crayfishx

Actually, the docs say 4.9+ - if this issue affects 4.9 then we should change the documentation - so re-opening this ticket as a reminder

crayfishx avatar Jun 14 '17 06:06 crayfishx