On Thursday, May 29, 2014 2:39:15 PM UTC-5, Brian Wilkins wrote:
>
> Solved it using this tip.. it's odd but it works: 
> http://serverfault.com/a/538877/26514
>
>

That's odd only inasmuch as the original problem in that serverfault 
question was different from yours.  The OP was trying to achieve a similar 
structure to the one you are working on, though, so it is natural that what 
worked for him also works for you.

For what it's worth, I think your original problem was here:

[...]

  profiles::logstash::config { $name:
       content => $content,
       order   => $order,
  }

[...]

The variables $content and $order had not been assigned any values in that 
scope (class profiles::logstash::shipper), which is exactly what the error 
message said.

I think that create_resources() was a red herring.  It should have been 
possible to use create_resources() more or less as you originally attempted 
to do, though you should have specified the fully-qualified name of the 
resource type ("profiles::logstash::config"), which you did not do.  
Indeed, your final data structure appears still amenable to use with 
create_resources().

 

> shipper.pp
>
> class profiles::logstash::shipper() {
>
>   $shipper_array = hiera_array('profiles::logstash::config_array')
>
>   define hash_extract() {
>     $shipper_hash = hiera_hash('profiles::logstash::config_settings')
>     $shipper_config = $shipper_hash[$name]
>
>     profiles::logstash::config {'shipper':
>        content => $shipper_config['content'],
>        order   => $shipper_config['order'],
>     }
>     notice($shipper_config['content'])
>     notice($shipper_config['order'])
>   }
>
>   hash_extract{$shipper_array:}
>
>   class { 'logstash':
>     ensure  => 'present',
>     version => '1.4.1-1_bd507eb',
>     status  => 'enabled',
>   }
>   include logstash
>


Note that the 'include logstash' is completely redundant (but not directly 
harmful) in that context because Class['profiles::logstash'] is already 
declared (immediately prior).  It would be much better to declare the class 
via its fully-qualified name, though, whichever form you use.

 

> }
>
>

I urge you, however, to avoid nesting classes or defined types.  The 
semantics are not necessarily what you expect (THAT was the serverfault 
questioner's issue), it makes the class or definition harder to find, and 
it contributes to confusion about the actual names of these things.


John

-- 
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/b463cce0-2848-46e1-9e9d-34d6a85fe819%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to