A few days ago another user posted an issue with complex hashes[1]; it looks 
like a parser bug, and a bug report was opened[2].  I seem to be having a 
similar problem, but I haven't been able to make the same workaround function.

This is the data structure I'd like to be using, but puppet doesn't like the 
array nested inside a hash:
    $dev_numbers = {
        'null' => {
            'freebsd'   = [ 0,  6 ],
            'ubuntu'    = [ 1,  3 ],
        },
        'random' => {
            'freebsd'   = [ 0, 12 ],
            'ubuntu'    = [ 1,  8 ],
        },
        'zero' => {
            'freebsd'   = [ 0,  7 ],
            'ubuntu'    = [ 1,  5 ],
        },
    }

--parseonly produces an error when checking this one
err: Could not parse for environment production: Syntax error at '='; expected 
'}' 

The alternative is to replace the array with a hash, like this:
    $dev_numbers = {
        'null' => {
            'freebsd'   => { 'major' => 0, 'minor' =>  6 },
            'ubuntu'    => { 'major' => 1, 'minor' =>  3 },
        },
        'random' => {
            'freebsd'   => { 'major' => 0, 'minor' => 12 },
            'ubuntu'    => { 'major' => 1, 'minor' =>  8 },
        },
        'zero' => {
            'freebsd'   => { 'major' => 0, 'minor' =>  7 },
            'ubuntu'    => { 'major' => 1, 'minor' =>  5 },
        },
    }

Puppet lets me define this data structure, but I can't find a way to access it.

If I use this:
    $major = $dev_numbers[$type][$operatingsystem]['major']
    $minor = $dev_numbers[$type][$operatingsystem]['minor']
then --parseonly gives me a syntax error:
err: Could not parse for environment production: Syntax error at '['; expected 
']'

If I use the alternative proposed to the OP, which looks like this:
    $device = $dev_numbers[$type][$operatingsystem]
    $major = $device['major']
    $minor = $device['minor']
then --parseonly passes everything, but when puppet actually tries to build the 
catalog for the client it fails and logs this error:
device is not an hash or array when accessing it with major at...


Does anyone have any other suggestions for how to work around this problem with 
the parser?

Thanks in advance!
   Matt



[1] 
<http://groups.google.com/group/puppet-users/browse_thread/thread/8840c275ca677cd9/58d7adea821fc49f>
[2] <http://projects.puppetlabs.com/issues/6269>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to