All-

We're using puppet (opensource) 3.4.2 master and clients.  We've been
using puppet a few years, including create_resources, but this is my
first foray into creating complicated nested hashes.

I've boiled the problem I'm running into down to this example:

$ cat /tmp/foo.pp
class foo {
  foo::bar { 'somevalue':
    stuff => {
      'one' => 'doesnt_matter',
      'two' => 'doesnt_matter',
    }
  }
}

define foo::bar (
  $stuff = {},
) {

  #
  # not valid: fails with a parser validation error on the key $name:
  #
  # Error: Could not parse for environment production: Syntax error at
  # 'name';
  # expected '}' at /tmp/foo.pp:21
  #
  $new_hash = {
    $name => $stuff,
  }

  #
  # this works, using a constant key
  #
  $new_hash = {
    'a_constant' => $stuff,
  }
}


This comes from a larger, more complicated example, but what I'm trying to
do is

- take a hash ($stuff) that has all the parameters I need
- create a new hash with a single key that's the $name/$title for the define,
  and a value that contains the hash $stuff that I was passed.

As you might guess, this is to make $new_hash suitable for passing
to create_resources.

Is there some other way to create a new hash, give it a single top-level
key that is a variable, and assign a separate (passed-in as a parameter)
hash as the value for that key?  I would be fine with using stdlib::merge,
but I don't see any obvious way to accomplish this task with stdlib::merge
either.

Thanks,

Tim
--
Tim Mooney                                             tim.moo...@ndsu.edu
Enterprise Computing & Infrastructure                  701-231-1076 (Voice)
Room 242-J6, Quentin Burdick Building                  701-231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/alpine.SOC.2.11.1411061531150.12196%40dogbert.cc.ndsu.NoDak.edu.
For more options, visit https://groups.google.com/d/optout.

Reply via email to