Ask Your Question
0

hiera.yaml doubts about config files

asked 2017-03-17 05:18:15 -0500

rssh22 gravatar image

My /etc/puppetlabs/puppet/hiera.yaml on master host looks like:

---
:backends:
  - yaml
:hierarchy:
  - "fussion/common"
  - "nodes/%{::trusted.certname}"
  - common


:yaml:
# datadir is empty here, so hiera uses its defaults:
# - /etc/puppetlabs/code/environments/%{environment}/hieradata on *nix
# - %CommonAppData%\PuppetLabs\code\environments\%{environment}\hieradata on Windows
# When specifying a datadir, make sure the directory exists.
  :datadir:

The master runs on vm-lab-linux-1 host and the agent on puppet-pil00

The file /etc/puppetlabs/code/environments/production/hieradata/fussion/common.yaml on master host looks like:

---
mdw_os_user:       &mdw_os_user         bea
mdw_os_group:      &mdw_os_group        bea
mdw_os_uid:        &mdw_os_uid          1001
mdw_os_gid:        &mdw_os_gid          1001

software_vol_name:             app/software
software_vol_quota:            10G
software_vol_mountpoint:       /software
software_vol_mountpoint_owner: root
software_vol_mountpoint_group: root
software_vol_mountpoint_mode:  '0555'

domains_vol_name:               app/domains
domains_vol_quota:              10G
domains_vol_mountpoint:         /domains
domains_vol_mountpoint_owner:   *mdw_os_user
domains_vol_mountpoint_group:   *mdw_os_group
domains_vol_mountpoint_mode:    '0755'
domain_os_user:                 *mdw_os_user
domain_os_group:                *mdw_os_group

mdw_vol_name:             app/middleware
mdw_vol_quota:            10G
mdw_vol_mountpoint:       /middleware
mdw_vol_mountpoint_owner: &mdw_os_user
mdw_vol_mountpoint_group: &mdw_os_group
mdw_vol_mountpoint_mode:  '0755'

When I do a lookup from the master host I can find the key mdwosgroup:

[root@vm-lab-linux-1 puppetlabs]# hiera -d mdw_os_group environment=production
DEBUG: 2017-03-17 11:17:12 +0100: Hiera YAML backend starting
DEBUG: 2017-03-17 11:17:12 +0100: Looking up mdw_os_group in YAML backend
DEBUG: 2017-03-17 11:17:12 +0100: Looking for data source fussion/common
DEBUG: 2017-03-17 11:17:12 +0100: Found mdw_os_group in fussion/common
bea

However, the agent can't find the key properly:

root@puppet-pil00:/usr/jdk#  /opt/puppetlabs/bin/puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Function lookup() did not find a value for the name 'mdw_os_group' on node puppet-pil00.msc.es
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

I'm new on puppet and I am not sure if I am configuring hiera properly. Why the agent can't find the mdwosgroup key?

edit retag flag offensive close merge delete

Comments

2

Hiera works differently than lookup. On your server, try 'puppet lookup --node <agent-name> mdw_os_group --explain' and see if your files are properly resolved and found.

Richard Berwald gravatar imageRichard Berwald ( 2017-03-18 09:35:52 -0500 )edit
1

You probably do not need the yaml aliases. Maybe you could try changing your common.yaml file to use the hiera function instead. For example your common.yaml could have entries that look like this instead: mdw_os_group: bea mdw_vol_mountpoint_group: "%{hiera('mdw_os_group')}"

Red Cricket gravatar imageRed Cricket ( 2017-03-21 10:36:24 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2017-03-22 05:47:39 -0500

Henrik Lindberg gravatar image

The hiera command line tool is broken in many ways, and this may be one of them. The hiera tool is deprecated and will be removed sometime in the future. Use the lookup command line tool instead if you are on a recent version of puppet. The lookup CLI will do the same as what the compiler does. This in contrast to the hiera tool which does its own thing when resolving how to look things up.

edit flag offensive delete link more
0

answered 2017-03-21 11:09:22 -0500

rssh22 gravatar image

I ask myself (with some doubts).

The problem seems to be that I was using lookup() instead of hiera() in a class because I read somewhere that Puppet currently included hiera files in the lookup function. However, it must be for some specific version of puppet. I'm currently working with 4.8.1

edit flag offensive delete link more

Comments

Looks like the error is occuring when the agent is "Loading facts". Have you written your own custom resource type/ruby code?

Red Cricket gravatar imageRed Cricket ( 2017-03-21 11:23:05 -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

1 follower

Stats

Asked: 2017-03-17 05:18:15 -0500

Seen: 49 times

Last updated: 2 days ago