Ask Your Question
0

How to iterate over a hiera hash to create another hash [closed]

asked 2016-08-23 09:00:48 -0500

Styr gravatar image

Hello Puppet users,

I'm doing my best to put all my data into hiera and using only generic manifests, but I'm stuck here.

I have a hiera structure like this one :


  bind1:
    ipport: '1.2.3.4:443'
    options:
    - 'ssl'
    - 'crt'
    - '/var/lib/ssl/example.org.pem'
    - 'ciphers'
    - 'DHE-RSA-AES128-GCM-SHA256:.....'
  bind2:
    ipport: '1.2.3.4:80'
    options:

And I want to use puppetlabs-haproxy to create a frontend ressource with different bind options. Finally, I would like that hiera structure to become :


bind => {
  '1.2.3.4:443'=> ['ssl', 'crt', '/var/lib/ssl/example.org.pem', 'ciphers',  'DHE-RSA-AES128-GCM-SHA256:.....'],
  '1.2.3.4:80' => [],
}

What I supposed I'd have to do would be to iterate over the hiera hash to create a new hash in the manifest but I cannot find how to do that.

Do you have any idea how to do that?

Thanks

Jérémy

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Styr
close date 2016-08-23 11:09:05.068559

1 Answer

Sort by » oldest newest most voted
0

answered 2016-08-23 11:08:42 -0500

Styr gravatar image

Looks like I was headachingover nothing, I just had to create the hash as-is in hiera :

bind:
  '1.2.3.4:80': []
  '1.2.3.4:443':
    - 'ssl'
    - 'crt'
    - '/var/lib/ssl/example.org.pem'
    - 'ciphers'
    - 'DHE-RSA-AES128-GCM-SHA256:.....'

And then call bind directly in manifest.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2016-08-23 09:00:48 -0500

Seen: 16 times

Last updated: Aug 23 '16