Ask Your Question

Puppet Array in hiera [closed]

asked 2017-05-18 06:43:05 -0500

bigfoot74 gravatar image

updated 2017-05-18 06:46:15 -0500


I am trying to rewrite some puppet apache profiles we have, also trying to remove array etc and move them to hiera. Does anyone know how to add this to hiera:

   $aliases = [{
    scriptalias => '/awstats',
    path        => '/usr/lib/cgi-bin/',   }   ,   {
    alias => '/awstats-icon',
    path  => '/usr/share/awstats/icon/',   }   ,   {
    alias => '/awstatsclasses',
    path  => '/usr/share/awstats/lib/',   }   ,   {
    alias => '/awstatscss',
    path  => '/usr/share/doc/awstats/examples/css', }   ]

I tried something like:

    - alias:
        - '/awstatsclasses'
        - '/awstats-icon'
    - path:
        - '/usr/share/awstats/lib/'
        - '/usr/share/awstats/icon/'

But it keeps overwriting the Alias line with the last values....

Could someone help me please ?

Kind regards,

  • Pascal den Bekker
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by bigfoot74
close date 2017-07-04 01:01:31.090537

3 Answers

Sort by ยป oldest newest most voted

answered 2017-05-18 10:38:47 -0500

smarlow gravatar image

When writing tricky structures in YAML I would recommend using an interactive parser like this one.

In order to convert that over you would need to express it like so:

    - scriptalias: '/awstats'
      path:  '/usr/lib/cgi-bin/'
    - alias: '/awstats-icon'
      path:  '/usr/share/awstats/icon/'
    - alias: '/awstatsclasses'
      path:  '/usr/share/awstats/lib/'
    - alias: '/awstatscss'
      path:  '/usr/share/doc/awstats/examples/css'

Basically you need an array of hashes, each hash with the same keys/values as in the original. There's no need to condense all of the aliases/paths into a single key.

edit flag offensive delete link more


I tend to write out my structures in irb, and dump it to a yaml file to verify, but the interactive parser is probably better. Also, JSON is a subset of yaml, so if you are more comfortable, you can just write it as json and parse it as yaml

DarylW gravatar imageDarylW ( 2017-05-19 21:26:10 -0500 )edit

answered 2017-05-19 01:04:29 -0500

bigfoot74 gravatar image

Thnx smarlow :-) That helped me a lot :-)

edit flag offensive delete link more

answered 2017-05-18 09:37:53 -0500

dcs02d gravatar image

Get rid of the - for the keys (alias and path)

profile::apache::httpd::someapache:aliases: alias: - '/awstatsclasses' - '/awstats-icon' path: - '/usr/share/awstats/lib/' - '/usr/share/awstats/icon/'

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-05-18 06:43:05 -0500

Seen: 129 times

Last updated: May 19