With this hiera data I think I would be a lot easier to use the
create_resources function.
Regards,
El 22/04/2014 18:13, "Martin Alfke" <tux...@gmail.com> escribió:

> Hi Konstantin,
> On 22.04.2014, at 15:27, Konstantin Boyanov <kkboya...@gmail.com> wrote:
>
> > Hello,
> >
> > I am running into the following problem - I have a Puppet Module for
> managing SSH keys. The information about the keys is stored in Hiera in the
> following form:
> >
> > sshkeys_keys:
> >         -
> >             keyname: 'puppet_rootkey'
> >             key:
> 'adsfadsfadfadfadfasdfadfadf123123123123asdfasfasf123123123'
> >             keytype: 'ssh-rsa'
> >             keyuser: 'root'
> >         -
> >             keyname: 'puppet_rootkey2'
> >             key:
> 'qwerqwerqwerqwerqwer9878976qwerqwerqw9e876rqw9e87r6q9w8e7r6'
> >             keytype: 'ssh-dss'
> >             keyuser: 'root'
> >
> > etc...
> >
> > So, I want to create multiple ssh_authorized_keys resources and for that
> I use a defined type in my module class:
> >
> > define keyentry() {
> >
> >            $keyname = $title['keyname']
> >            $key = $title['key']
> >            $keytype = $title['keytype']
> >            $keyuser = $title['keyuser']
> >            $ensure = $title['ensure']
> >
> >            ssh_authorized_keys {
> >                ensure=$ensure,
> >                key = $key,
> >                type = $type,
> >                user = $user
> >            }
> > }
> >
> > $sshkeys_keys = hiera_array("sshkeys_keys")
> > keyentry {"sshkeys_keys:}
>
> You can use the keys function to extract the key names.
> Note: keys function is available in stdlib module.
>
> But: this requires to change your hiera data:
>
> sshkeys_keys:
>   puppet_rootkey:
>     key: 'aadd...'
>     keytype: 'ssh-rsa'
>     keyuser: 'root'
>   puppet_rootkey2:
>     key: 'bbss..'
>     keytype: 'ssh-dss'
>     keyuser: 'root'
>
> within your code:
> manifests/init.pp:
>
> class sshkeys {
>   $sshkeys = hiera("sshkeys_keys")
>   $sshkeys_keys = keys($sshkeys)
>   sshkeys::keyentry { $sshkey_keys: }
>
> }
>
> manifests/keyentry.pp
> define keyentry (...) {
>   .....
> }
>
> (in my example I put the define into a separate manifest file.)
>
>
> >
> > This gives me the following error and I cannot seem to understand why:
> >
> > Error: Could not retrieve catalog from server: Could not intern from
> pson: Could not find relationship target "Sshkeys::keyentry[]"
> >
> > Does anyone have some ideas what could be the problem, and how to get
> rid of it?
> > Thanks in andvance!
> >
> > Cheers,
> > Konstantin Boyanov
> >
> > --
> > 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/d6471316-d593-4f57-a8fb-cc2187e77562%40googlegroups.com
> .
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> Martin Alfke
> IT Consulting & Training
> Dipl.-Ing.(FH)
> LPIC-2, Puppet Certified Professional
>
>
>
> --
> 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/D31D8E32-A54E-499A-BC8D-C82664B5D46D%40gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAF_B3dfE3EsF9B8zRc8gpmhOh8W0EMUOO1F4O%2BD726%3DwpDE0rg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to