Ask Your Question
0

hiera lookup evaluation error on puppet agent

asked 2015-06-05 11:53:06 -0500

ranjeet k gupta gravatar image

updated 2015-06-05 15:21:06 -0500

ramindk gravatar image

I am using hiera-http backend for puppet configuration store in couchdb. My puppet setup is a PE 3.8 master agent setup. When running puppet agent -t on the agent node, i get the following error,

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Function Call, Could not find data item vHosts in any Hiera data file and no default supplied at /etc/puppetlabs/puppet/environments/production/custommodules/emchaproxy/manifests/init.pp:23:20 on node a gent4.example.com

I can run the hiera lookup puppet code snippet in the master as puppet apply -e '$apache_servers = hiera(vHosts) notify { $apache_servers: } and it runs fine. Am I missing something here ? Posting my puppet code and the hiera.xml

---
:backends:
  - http
  - yaml
:hierarchy:
  - defaults
  - "%{clientcert}"
  - "%{environment}"
  - global
  - common

:yaml:
# datadir is empty here, so hiera uses its defaults:
# - /var/lib/hiera on *nix
# - %CommonAppData%\PuppetLabs\hiera\var on Windows
# When specifying a datadir, make sure the directory exists.
  :datadir: /etc/puppetlabs/puppet/environments/production/hiera/
:http:
  :host: 10.0.2.2
  :port: 5984
  :output: json
  :failure: graceful
  :paths:
    - /agents/
    - /agents/newdoc
    - /agents/_design/Summary/_list/vHosts/vHosts

puppet code

class emchaproxy {

  class { 'haproxy': }

  haproxy::listen { 'puppet00':
    collect_exported => false,
    ipaddress        => $::ipaddress,
    ports            => '8140',
  }

  $apache_servers = hiera(vHosts)

  each($apache_servers) |Integer $index, Array $hosts| {

    haproxy::balancermember { "apache${index}":
      listening_service => "puppet${index}",
      server_names      => $hosts[0],
      ipaddresses       => $hosts[1],
      ports             => '8140',
    }
  }
}
edit retag flag offensive close merge delete

Comments

I am using 4.2 and the http_backend.rb does not exist. Can you please help? THis works as expected in 3.8

winningpanthers gravatar imagewinningpanthers ( 2015-09-02 15:34:35 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-09-02 15:31:20 -0500

winningpanthers gravatar image

I am using 4.2 and the http_backend.rb does not exist. Can you please help?

THis works as expected in 3.8

edit flag offensive delete link more
0

answered 2015-06-09 00:46:48 -0500

ranjeet k gupta gravatar image

The issue got resolved. After enabling debug mode on puppet master, figured that the actual issue is "Cannot load backend http: cannot load such file -- hiera/backend/http_backend" This link helped me github.com/crayfishx/hiera-http/issues/14

Had to create a softlink to the http_backend.rb in puppet lib directory.

edit flag offensive delete link more

Comments

a useful way of debugging hiera is from the command line outside of puppet e.g. hiera -c /path-to-hiera.yaml/file profiles::path::packages environment=yourenv variable1=blah variabl2=blah also to check the hiera syntax: ruby -e "require 'yaml'; YAML.parse(File.open('yourhierafile'))"

sahumphries gravatar imagesahumphries ( 2015-06-09 05:18:36 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-06-05 11:53:06 -0500

Seen: 4,204 times

Last updated: Sep 02 '15