salt icon indicating copy to clipboard operation
salt copied to clipboard

How can a binary file, such as a license key, be distributed via Pillar?

Open clearclaw opened this issue 12 years ago • 45 comments

There doesn't seem to be a way to provision binary data into pillar values in order to feed to file.contents_pillar.

clearclaw avatar Jan 04 '14 10:01 clearclaw

Thanks for creating this new issue. I'm still not sure of the best way to go about this, but we definitely want to support this!

basepi avatar Jan 06 '14 23:01 basepi

+1 for this.

foxx avatar Jan 19 '14 19:01 foxx

Is there a limit for how much can be put in a normal pillar key?

kaithar avatar Jan 19 '14 23:01 kaithar

YAML (1.1) already suppors a binary storage type -- e.g. http://yaml.org/type/binary.html -- and since pillar is already just "arbitrary data", adding it should be as simple as using the syntax outlined there.

That said, just how useful this would be in a particular context would depend on your willingness to decode it back from base64 -- fairly simple in a mako situation, but admittedly trickier in jinja...

On Sun, Jan 19, 2014 at 3:20 PM, kaithar [email protected] wrote:

Is there a limit for how much can be put in a normal pillar key?

— Reply to this email directly or view it on GitHubhttps://github.com/saltstack/salt/issues/9569#issuecomment-32725756 .

tkwilliams avatar Jan 19 '14 23:01 tkwilliams

Yeah, thinking on it further, it would be better to have a sort of pillar_file_root with a top.sls like pillar_root and file_root, and then the .sls files specify a mapping of virtual/file/path: real/file/path. That would allow a state to specify it wants, say, apache/private_key.pem and the mapping could rewrite that to a different file for each server, simplifying the state.

Another alternative would be to provide a masking and/or mapping option within the normal file_root so that the files can be kept along side the rest of the state files. That does have the risk of information leak due to misconfiguration though, which makes me wary of it.

kaithar avatar Jan 19 '14 23:01 kaithar

Among the reasons I'd like to use a pillar (or pillar-like system) are:

-- I don't want it in the state tree because I don't want it copied to every faintly related minion and the state tree repository is visible to more people than I want to have access to the secure data -- I want to limit visibility of the value to just those relevant minions (by targeting) for similar reasons of limiting the exposure and audience

I'd really just like to be able to say get-this-file-from-the-pillar without caring whether it is 7bit ASCII or binary, much as I do with file.managed/name/source in state trees.

And no, I don't want to much about with binhex, uuencode, xxencode, base64 or like binary->ASCII->binary encoding transformations.

clearclaw avatar Jan 20 '14 00:01 clearclaw

@clearclaw that's why I don't really like the idea of using a masking solution laid on the normal state tree, even though it is technically cleaner w.r.t. keeping related files in the same place.

The more I think about it, the more I definitely like the notion of a separated explicit access file server as I described in the first paragraph above.

kaithar avatar Jan 20 '14 01:01 kaithar

I quite like the idea of a pillar_file_root with its own top.sls It seems quite logical that given the pillar is clearly just a data tree that arbitrary blobs of binary don't belong. So perhaps instead of needing to add files into the pillar we need a new thing like the pillar that is designed just for handling files.

In my case i really dont want to be storing most importantly SSL keys and to a lesser extent SSH keys in a way that delivers them onto every server managed by the master.

techdragon avatar Mar 14 '14 06:03 techdragon

Same as techdragon; I have the need to deploy ssl key/cert pairs to five machines, not the whole fleet of minions, and I'd rather a) keep them separate in pillar and b) w/o shoe-horning a bunch of lengthy strings into a single config file.

LeTink avatar Apr 22 '14 03:04 LeTink

+1

arnisoph avatar Apr 22 '14 07:04 arnisoph

@basepi Any idea how much work it would take to implement this? I'd be happy to donate some time to get this into the core, but would need some guidance on implementation.

foxx avatar Apr 22 '14 13:04 foxx

@foxx I honestly am unsure what it would take. Currently, pillar is implemented as a single dictionary that we send down to the minions after compiling it. How do we implement binary files in this model? We could potentially encoded the file using the base64 library, which is designed to encoded arbitrary data for easy ascii sending. That's probably our best bet, but we would have to find a way to mark the fact that it's binary data, or make some utils to utilize the data on the other end.

basepi avatar Apr 23 '14 15:04 basepi

Gah, sent early. Editing original comment to finish it.

basepi avatar Apr 23 '14 15:04 basepi

+1, has any progress been made with this?

mr337 avatar Sep 24 '14 04:09 mr337

@mr337 Not yet, as far as I know. It's on the list.

basepi avatar Sep 24 '14 20:09 basepi

@basepi thx for the update!

mr337 avatar Sep 24 '14 20:09 mr337

This might be a related issue https://github.com/saltstack/salt/issues/14980.

srkunze avatar Sep 24 '14 21:09 srkunze

I'm looking for the best way to distribute kerberos keytab files which are binary (see: http://www.gnu.org/software/shishi/manual/html_node/The-Keytab-Binary-File-Format.html). That seems to fall into the realm of this issue.

+1

charleshbaker avatar Nov 18 '14 18:11 charleshbaker

maybe file_roots on a per-minion/match/nodegroup basis. $0.02

ghost avatar Dec 11 '14 02:12 ghost

Not a replacement for a true, file-based Pillar transport but a base64-based workaround that just uses plain ol' state and execution functions is in #19935.

whiteinge avatar Jan 22 '15 01:01 whiteinge