Ask Your Question

puppet apply -e ' notify { "test": } " ' --environment production

asked 2017-02-08 16:35:53 -0600

karthikeayan gravatar image

how can i pass value for the environment from puppet apply so that it can be used in hiera lookup (hiera config file)?

currently its not working and hiera throwing error saying, it couldn't find any key.

command i tried,

puppet apply -e ' notify { "test": } " ' --environment production

edit retag flag offensive close merge delete


I don't fully understand your question. also your environment is most likely defaulted to production so you don't need the --environment flag for calls like this.

puser gravatar imagepuser ( 2017-02-09 06:40:19 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-02-09 10:51:52 -0600

puser gravatar image

If I am not mistaken, environment refers strictly to the directory your modules reside. For example,



Therefore you wouldn't use environment as a hiera variable. If you do something like:

FACTER_<some fact>=<some val> puppet apply -e 'notify { $::<some variable>: }'

you should see the results you want like:

FACTER_osfamily=myMadeUpFamily puppet apply -e 'notify { $::osfamily: }'

It will output myMadeUpFamily

This is valuable if your hiera router is something like

- osfamily/%{::osfamily}
- global

So if you have a file in the path hieradata/osfamily/myMadeUpFamily.yaml and that contained:

someStringVariable: 'someStringValue'

Then if you did:

 FACTER_osfamily=myMadeUpFamily puppet apply -e 'notify { $::someStringVariable: }'

you would get back


I hope this is helpful

edit flag offensive delete link more


yes, this is what i am looking for.. looks like, --environment parameter is deprecated in newer version..

karthikeayan gravatar imagekarthikeayan ( 2017-02-09 11:26:24 -0600 )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: 2017-02-08 16:35:53 -0600

Seen: 246 times

Last updated: Feb 09 '17