hi Paul,

I am pretty to code the puppet codes. I try the options that you suggested 
about creating the define type. But, I am still stuck in the middle.

Here is my code.
$pub_keys=['XXXXXX', 'YYYYY', 'ZZZZZZ' ]

define add_authkeys (user="hiu", key) {
        ssh_authorized_key { "$hiu":
                name => "hiu@$fqdn",
                ensure => present,
                type => ssh-rsa,
                key => $key,
                user => $user,
        }
}


class base::config_authorized_keys {
        add_authkeys { "hiu@$fqdn":
                 key => $pub_keys,
        }
}


the result is something that unexpected. my authorized keys are something 
like this:

ssh-rsa XXXXYYYYYYYYZZZZZZZZZ

instead of 

ssh-rsa XXXXXXXX
ssh-rsa YYYYYY
ssh-rsa ZZZZZZZ


can you please advise? thank you.



On Thursday, 20 September 2012 17:01:49 UTC+8, Paul Tötterman wrote:
>
> Hi Hiu,
>  
>
>> key1=[ 'XXXXXXXX', 'YYYYY', 'ZZZZZZZ']
>>
> ... 
>
>>                 key => $key1,
>>
>  
> http://docs.puppetlabs.com/references/latest/type.html#sshauthorizedkey does 
> not suggest that the provider would support an array for key.
>
> I suggest doing something like:
>
> $user = 'user'
>
> ssh_authorized_key {
>   "${user}-key1":
>     type => 'ssh-rsa',
>     user => $user,
>     key => $key1;
>   "${user}-key2":
>     type => 'ssh-rsa',
>     user => $user,
>     key => $key2;
> ...
> }
>
> or even a define:
>
> $user = 'user'
> $keys = [$key1, $key2, ...]
>
> define user_key() {
>   ssh_authorized_key { "$user-$name':
>     type => 'ssh-rsa',
>     user => $user,
>     key => $name,
>   }
> }
>
> user_key { $keys: }
>
> (My puppet code may well contain errors, but should give you the idea)
>
> Cheers,
> Paul
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/rI5fzWAqJt0J.
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