Ask Your Question

hiera 5 hash

asked 2017-05-14 18:41:05 -0500

minimike gravatar image

updated 2017-05-15 10:38:38 -0500

smarlow gravatar image

Hi there

Is there a more deatiled example available on hashes for hiera 5

class profiles::postgresql {

$config_entry = hiera_hash('postgresql::server::config_entry', {})
create_resources(postgresql::server::config_entry, $config_entry)

$pg_hba_rule = hiera_hash('postgresql::server::pg_hba_rule', {})
create_resources(postgresql::server::pg_hba_rule, $pg_hba_rule)

$role = hiera_hash('postgresql::server::role', {})
create_resources(postgresql::server::role, $role)

$db = hiera_hash('postgresql::server::db', {})
create_resources(postgresql::server::db, $db)


the example above is working with hiera 3 that will be depricated in the future. Currently I don't understand how I've to replace hiera_hash and create_resources. After reading the docs I am more and more confused. In the last year I didn't work with puppet but in some weeks I am starting a new longterm project they I'll start with state on the art.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-05-15 10:48:42 -0500

smarlow gravatar image

Only hiera_hash is currently deprecated, and you have a while before it will be removed. However, if you want to replace it you would use the lookup function. This link briefly lists how you might replace various hiera_* functions with the lookup function. Additionally you would want to specify a default value of {}.

For example, you might replace

$config_entry = hiera_hash('postgresql::server::config_entry', {})


$config_entry = lookup('postgresql::server::config_entry', {merge => hash, default_value => {}})


$config_entry = lookup('postgresql::server::config_entry', {merge => deep, default_value => {}})

depending on the merge strategy that you use.

create_resources is not currently deprecated. It's possible to replace it with an iterator over the hash (such as each) and specifying resources inside of it with the splat operator, but I don't think that really buys you much.

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: 2017-05-14 18:41:05 -0500

Seen: 37 times

Last updated: May 15