Quantcast
Channel: Ask Puppet: Puppet DevOps Q&A Community - RSS feed
Viewing all articles
Browse latest Browse all 75

How to declare a selectable hash class parameter?

$
0
0
Salut, I need a selectable hash parameter in my class definition:
class colors (
  $flavor      = 'myfavorites',
  $nice_colors = $flavor ? {
    'myfavorites' => {
      'red'   => false,
      'green' => true,
      'blue'  => false,
    },
    default => {
      'red'   => true,
      'green' => true,
      'blue'  => true,
    },
  },
) inherits colors::params {
  Class['colors::install'] -> Class['colors::config']
  contain 'colors::install'
  contain 'colors::config'
}
Since hash literals can't be specified in a '?'-selector I need to go around this problem. Later I need to iterate over the hash in a template.
<%- @nice_colors.each do |color, isnice| -%><%- if not isnice %>no<% end %><%= color %><%# -%><%- end -%>
Does anyone have an idea (and when yes, what's your idea?)? Thx a lot.

Viewing all articles
Browse latest Browse all 75

Trending Articles