Andre Timmermann wrote:
Hi Silviu,

Am Donnerstag, den 14.01.2010, 12:59 +0200 schrieb Silviu Paragina:

If that is all take a look at:
http://reductivelabs.com/static_files/TypeReference.html#ssh-authorized-key
it does just what you need. :)

Ok, thanks, that looks great. One single problem left ;)

How do I read those keys from a file?

$read_key_file =
file("/etc/puppet/${environment}/templates/authorized_keys/${key_file}",
"/dev/null")

You should use modules, they get the stuff more organized, not a spinning vortex of files, templates, manifests and plugins. :-) http://reductivelabs.com/trac/puppet/wiki/ModuleOrganisation - this documentation is a tad old, but the only thing different now is that you should use lib instead of plugins (if you will need those) in the directory structure.

If you use templates use the template function not the file function. But I don't know why you would have a template instead of a file in this case

You can use the template function like here http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#functions . Pretty much like you used it. The advantage is that you don't have to fully qualify the files, opposed to the file function.

Example (let's your module is called sshkeys, and you have in /etc/puppet/modules/sshkeys/templates/$key_filename the right file)
ssh_authorized_key
{
.....
key => template('sshkeys/$key_filename')
}

Silviu
appends an newline at the key so that the comment will be on a new
line.
You probably have a newline after the key in the file, remove the newline. This will happen with templates also. As an alternative you may use the resubst function, but that will make the manifest more hard to read and uses more cpu cycles.

It would be cool if I coult "type" and "name" diriectly from the
keyfile. (Sorry these are my first steps with puppet and ruby)


You could with resubst, but I think it will get things more complicated, rather than easy.


Silviu

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


Reply via email to