Ask Your Question
0

Hiera how to retrieve values

asked 2014-12-09 02:53:45 -0500

I have a hiera datafile which looks like this:

environments:
    development:
        host: localhost
        password: password
    production:
        host: prod.org.com
        password: password

Using hiera I can get the environments

hiera enviroments
{"development"=>{"host"=>"localhost", "password"=>"password"},
 "production"=>{"host"=>"prod.org.com", "password"=>"password"}}

Say, if would like to retrieve the production password directly with hiera, how could I do that? This command does not return anything.....

hiera environments:production:password
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-12-09 08:44:17 -0500

anthonyclark gravatar image

I think you're looking to use the following syntax:

$database_properties = hiera_hash('example::software::database')

Take a look here: https://docs.puppetlabs.com/hiera/1/p...

And make sure you're using the correct double-colon syntax.

edit flag offensive delete link more

Comments

I think hiera can only retrieve top level keys. See this link: https://docs.puppetlabs.com/hiera/1/puppet.html#interacting-with-structured-data-from-hiera This is what I ended up doing: $env = hiera('environments') $password = $env[development][password] Thanks for the input

Gobin Sougrakpam gravatar imageGobin Sougrakpam ( 2014-12-10 03:09:36 -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: 2014-12-09 02:53:45 -0500

Seen: 57 times

Last updated: Dec 09 '14