Hello again,

> The hash needs a name for the key!!! 
>

Which hash are you talking about exactly?

sshkeys_keys: 
>   puppetkey:                # <——— key name 
>     key: ‘aaa…’ 
>     keytype: ‘ssh-das’ 
>     keyuser: ‘root’ 
>

Is this correct Hiera syntax at all? I mean the first two rows. What are we 
defining here, a hash of hashes?

In the end I want my module to automatically load all the host specific SSH 
keys from Hiera and build the ssh_authorized_key resources. I do not want 
to pick them one by one by names I defined in Hiera.
The most annoying thing is that this module used to work wit ruby Version 
<= ruby 1.8.7 (patchlevel 72). I am now using ruby 1.8.7 (2011-12-28 
patchlevel 357) and the module crashes with the error from my original post.

Here is the code I have now: 

class sshkeys() {

include 'stdlib'

    define keyentry() {
        $keyname = $title['keyname']
        $key         = $title['key']
        $keytype   = $title['keytype']
        $keyuser   = $title['keyuser']
        $ensure     = $title['ensure'] ? {
            'present' => 'present',
            'absent'  => 'absent',
            default   => 'present'
        }

        ssh_authorized_key {$keyname:
            ensure => $ensure,
            key    => $key,
            type   => $keytype,
            user   => $keyuser
        }
    }

  # returns all matches throughout the hierarchy, not only the first one    
  $sshkeys = hiera("sshkeys_keys")
  
  # Return the keys of a hash as an array
  $sshkeys_keys = keys($sshkeys)
    
  sshkeys::keyentry { $sshkeys_keys: }

}

Any my hieradata looks like this:

sshkeys_keys:
    TEST:
        key: 
'asdfasdfasdf123412341234asdfasdfasdf123412341234asdfasdfasdf123412341234asdfasdfasdf123412341234=='
        keytype: 'ssh-rsa'
        keyuser: 'root'
    TEST2:
        key: 
'asdfasdfasdf123412341234asdfasdfasdf123412341234asdfasdfasdf123412341234asdfasdfasdf123412341234=='
        keytype: 'ssh-rsa'
        keyuser: 'root'

I still get the error:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: 
syntax error on line 28, col 6: `    TEST:' at 
/puppet/environments/development/manifests/site.pp:15 on node 
mynode.mydomain.my

so I am fairly sure the Hiera syntax is not right. It cannot be THAT hard 
to get structured data out of Hiera and use it to automatically define a 
lot of standard resources.
Any thoughts?

Cheers and thanks again for you outstanding support!
Konstantin

-- 
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/9d161f5a-c45a-4ea4-9f62-df589e0b8bf9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to