hiera could not find item

111 views
Skip to first unread message

Renan Vicente

unread,
Mar 21, 2014, 4:19:33 PM3/21/14
to puppet...@googlegroups.com

Any one had this problem to find a attribute or know how to solve this? In my case I separated hiera files by osfamily when I execute

 # hiera packages_utils

return me

nil

BUT if I execute

# hiera packages_utils osfamily=Debian

it's works

["tzdata",
 "dnsutils",
 "bash-completion",
 "unzip",
 "bzip2",
 "htop",
 "vim",
 "ntpdate",
 "mlocate",
 "nfs-common",
 "sysstat"]

the facter osfamily works.

# facter osfamily
Debian

my hiera.yaml

---
:backends:
  - yaml
:hierarchy:
  - "nodes/%{fqdn}"
  - "osfamily/%{osfamily}"
  - "osfamily/%{operatingsystem}"
  - defaults/users
  - defaults/hosts
  - "%{clientcert}"
  - "%{environment}"
  - global

: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/puppet/hiera

my osfamily directory content

# ls -l /etc/puppet/hiera/osfamily/
total 12
lrwxrwxrwx 1 root root  11 Mar 21 15:44 CentOS.yaml -> RedHat.yaml
-rw-r--r-- 1 root root 248 Mar 21 16:11 Debian.yaml
-rw-r--r-- 1 root root  29 Mar 21 16:13 default.yaml
-rw-r--r-- 1 root root 223 Mar 21 15:44 RedHat.yaml
lrwxrwxrwx 1 root root  11 Mar 21 15:44 Ubuntu.yaml -> Debian.yaml

my Debian.yaml

---
packages_utils:
  - tzdata
  - dnsutils
  - bash-completion
  - unzip
  - bzip2
  - htop
  - vim
  - ntpdate
  - mlocate
  - nfs-common
  - sysstat
conf_ntp:
  - ntpdate
conf_ntp_path:
  - /etc/default/ntpdate
conf_vim_path:
  - /etc/vim/vimrc

José Luis Ledesma

unread,
Mar 21, 2014, 8:01:35 PM3/21/14
to puppet...@googlegroups.com

The hiera command doesn't use facter, its a tool to check the values returned by hiera in different circumstances.

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/11625c93-4c89-4fd6-8c82-6b9c170ebddb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Renan Vicente

unread,
Mar 22, 2014, 2:09:49 PM3/22/14
to puppet...@googlegroups.com
How can I check this , 'Cause in my nodes I received this?
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find data item  in any Hiera data file and no default supplied at /etc/puppet/modules/ananke-base-utils/manifests/init.pp:42 on node tm-ld168-senac
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

this is the part of my code that I am having trouble:

 38 class ananke-base-utils {
 39
 40 # variables from hiera
 41
 42   $conf_file    = hiera($conf_ntp)
 43   $cpath_ntp    = hiera($conf_ntp_path)
 44   $cpath_vim    = hiera($conf_vim_path)
 45   $package_name = hiera_array($packages_utils)
 46
 47
 48 # install package based on distribuition
 49   package {$package_name:
 50     ensure         => 'present',
 51   }
 52

Renan Vicente

unread,
Mar 22, 2014, 4:14:33 PM3/22/14
to puppet...@googlegroups.com
problem solved I just was using hiera of the wrong way, I was using hiera($conf_ntp) instead hiera('conf_ntp'), I need to provide a keyname that hiera should look up as a string.So , the error indicates that I was trying to look up a key that is stored in `$conf_ntp` and $conf_ntp is not set to a value so hiera tries to lookup an empty key.
Reply all
Reply to author
Forward
0 new messages