Ask Your Question

How do I use hiera's calling_class_path pseudo variable from the command line?

asked 2016-04-18 03:37:53 -0600

schowdhury gravatar image

Whenever I do any hiera troubleshooting, I do hiera lookups via hiera's cli utility, e.g.:

$ hiera {key} ::environment=dev ::role=webserver --config /etc/puppetlabs/code/hiera.yaml

However in hiera.yaml, I am also making use of the "callingclasspath" pseudo-variable:

Therefore my hiera.yaml file looks like this:

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

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

In this scenario, does anyone know how to write my hiera command to feed in a value for this pseudo variable?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-04-18 09:39:39 -0600

schowdhury gravatar image

Ok, I've figured it out.

Let's assume in my example we have:

role=webserver (i.e. roles and profiles) environment=dev (i.e. directory environment)

Now let's say I have a class parameter called "portnumber" which a class called apachex requires. and this class is stored inside a modules called "profiles", then my hiera lookup would be:

$ hiera profiles::apachex::portnumber ::environment='dev' ::role='webserver' calling_class_path="profiles/apachex"
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


Asked: 2016-04-18 03:37:53 -0600

Seen: 156 times

Last updated: Apr 18 '16