Ask Your Question

Passing Variables to Hiera Using Puppet Apply

asked 2013-08-18 16:03:42 -0500

louis gravatar image


Is it possible to send variable values to hiera database by using puppet apply command line?

puppet apply remove-all.pp --modulepath=modules --hiera_config=hiera/hiera.yaml --parser future

Let say i have a hiera data.yaml with the following references.

rootdir : "%{::basedir}"
loggingdir: "%{::logdir}"

In this case i am using a hiera.yaml config file and a custom data.yaml that contains certain values that i can use later with the Puppet 3.2 future parser mechanisms.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-08-19 13:33:31 -0500

GregLarkin gravatar image

Yes, you can set those variables by exporting custom facts to the environment in which puppet apply executes, e.g.:

[root@puppet glarkin]# facter -p | grep ^basedir
[root@puppet glarkin]# env FACTER_basedir=/tmp facter -p | grep ^basedir
basedir => /tmp

You can add the appropriate FACTERbasedir and FACTERlogdir environment variables, and puppet apply will pick them up from facter when it runs.

edit flag offensive delete link more


i thought about the same but using the same command in windows fails for some reason. Wondering if this is the only way of doing this.

louis gravatar imagelouis ( 2013-08-19 14:45:41 -0500 )edit

Windows probably has a different way of setting the environment variables. Do these values change, or can they be set permanently in the Control Panel system environment variables?

GregLarkin gravatar imageGregLarkin ( 2013-08-19 19:30:21 -0500 )edit

Yeah. I am using the future parser feature that allows me to get all values from a yaml file and create resources dynamically with **create_resources**. I am using this puppet ...(more)

louis gravatar imagelouis ( 2013-08-19 20:14:03 -0500 )edit

You should be able to drop text files with your custom fact values into the external facts directory for processing by facter: ...(more)

GregLarkin gravatar imageGregLarkin ( 2013-08-20 10:28:40 -0500 )edit

The text files are working great. Now i need to pass those parameters to a Rakefile and may be use puppet apply -e "file{}". But i think is going to ...(more)

louis gravatar imagelouis ( 2013-08-21 09:22:31 -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


Asked: 2013-08-18 16:03:42 -0500

Seen: 7,604 times

Last updated: Aug 19 '13