Ask Your Question
0

Can I make use of multiple datadir paths for hiera?

asked 2016-04-04 08:13:06 -0500

schowdhury gravatar image

updated 2016-04-14 14:37:46 -0500

I want to make use of multiple hiera datadir, so I configured my hiera.yaml file to look like this:

$  cat /etc/puppetlabs/code/hiera.yaml
---
:backends:
  - yaml
:hierarchy:
  - "%{::role}"
  - common

:yaml:
  :datadir:
    - "/etc/puppetlabs/code/environments/%{::environment}/hieradata"
    - "/etc/puppetlabs/code/hieradata/company_wide_hiera_data"

Notice that for 'datadir' I have specified an array. That's because some of my hieredata isn't specific to a particular environment, instead they are general across the whole company.

When I do a puppet run, I get:

# puppet agent -t
Notice: Local environment: 'production' doesn't match server specified node environment 'castle_production', switching agent to 'castle_production'.
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, Lookup of key 'profiles::web_server::sampledata' failed: DataBinding 'hiera': datadir for yaml cannot be an array at /etc/puppetlabs/code/environments/castle_production/site/roles/manifests/web_server_ng.pp:47:3 on node i-77690cff
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

This error message indicates that datadir for yaml cannot be an array.

Is there another way to get round this issue?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-04-04 08:56:52 -0500

schowdhury gravatar image

Ok I found a workaround, not great, but it works. Since 'datadir' doesn't accept an array, whereas 'hierarchy', I tried using relative path for hierarchy instead, like this:

$  cat /etc/puppetlabs/code/hiera.yaml
---
:backends:
  - yaml

:hierarchy:
  - "%{::role}"
  - common
  - "../../../hieradata/company_wide_hiera_data/common"      

:yaml:
  :datadir:
    - "/etc/puppetlabs/code/environments/%{::environment}/hieradata"

Notice my "../../../" hack. Next I created the following yaml data file:

/etc/puppetlabs/code/hieradata/company_wide_hiera_data/common.yaml

This approach worked. Does anyone else have a better approach?

edit flag offensive delete link more
0

answered 2016-10-15 10:19:07 -0500

How about creating a symlink for the additional hiera hierarchy into the primary?

edit flag offensive delete link more

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: 2016-04-04 08:13:06 -0500

Seen: 701 times

Last updated: Apr 14 '16