Ask Your Question
0

How to read entire files in Puppet verbatim (without parsing like template)?

asked 2016-11-23 13:59:35 -0500

UnitedMarsupials gravatar image

I need to create a bunch of ssh_authorized_keys resources. The resource expects its key-attribute to be the public key itself -- there is no way to refer to a file containing the key.

Because the keys are very long and because I already have them in files, I'd rather Puppet read them from the files instead of me quoting them in the manifest.

I can imagine a few other use-cases too.

Is there already a function to read a specified file verbatim, without attempting to interpret them as template() does?

For public-keys I can, actually, get away with template(), but that carries an overhead of a parsing-attempt. Also, in some other cases, depending on the file's contents, the parsing may, actually, "fail" or, worse, not fail, but quietly alter the contents...

edit retag flag offensive close merge delete

Comments

You could define an array of keys in hiera and then define your ssh_authorized_key's inside a loop. See https://docs.puppet.com/puppet/latest/reference/lang_iteration.html

Red Cricket gravatar imageRed Cricket ( 2016-11-23 16:52:04 -0500 )edit

That still requires me to open up the existing key-files myself. And it solves only this one use-case...

UnitedMarsupials gravatar imageUnitedMarsupials ( 2016-11-23 19:54:17 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-11-23 18:51:43 -0500

updated 2016-11-23 18:53:44 -0500

the file function maybe in conjunction with loops, depending on how you'd like to save your keys

edit flag offensive delete link more

Comments

Awesome! That's exactly, what I was looking for...

UnitedMarsupials gravatar imageUnitedMarsupials ( 2016-11-23 19:55:02 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-11-23 13:59:35 -0500

Seen: 39 times

Last updated: Nov 23 '16