-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Populate entire files via Pillar #1543
Comments
Good call, remind me to place this on 0.10.3 when the time comes |
This attempted workaround via jinja just results in a blank /tmp/date; should it work, or am I being too optimistic?
|
I addressed a similar problem doing something along the lines of the following example: top.sls: (the same for both /srv/pillar and /srv/salt directories)
/srv/pillar/ssh.sls:
/srv/salt/ssh.sls:
/srv/salt/ssh/files/private_key:
It's a little bit convoluted, but works just fine for me... Of course this approach wouldn't work very well for binary data or any kind of data that might cause PyYaml or Jinja2 problems.... |
I've been looking into this as well as I need to be able to manage systems for multiple unconnected companies and came up with the following: tf198/salt@SHA: 8a30f60 Basically it adds a /etc/salt/master - hide the
/srv/pillar/private.sls - distribute the secret through pillar mechanism
/srv/salt/private/gK9yOuETT9pKdnsvWAhbbHoYqJlchxDD/cert.pem
/srv/salt/ssl.sls - install the file
minions cant see the files $ salt 'server1.*' cp.list_master
{'server1.example.com': ['top.sls', 'ssl.sls']}
$ salt 'server1.*' cp.list_master_dirs
{'server1.example.com': ['.', 'private']} The only issue I can see (until some security guru pops up and shoots this down in flames) is that you cannot use the From my reading of the ZMQ docs then any other access control would require a relatively major change to the transport layer involving tokens so I cant imagine it coming any time soon unless Thatch has something in the wings. Comments welcomed... |
there's issue #636 that was closed wrt pillar ;-) |
This is not a bad idea @tf198, although it does seem too hacky. I have been thinking about this a little, I am wondering if we could allow files to be stored in pillar and then realized via a pillar file request, then the files can be enabled within the pillar data itself for the specific minion, otherwise direct file downloads from the pillar_roots is restricted. |
Man this project moves fast - I was only away for a week :-) The problem as I see it is that you'll end up duplicating a lot of code to allow file requests from the pillar - new handler for pillar:// etc... Am glad to hear that you are still looking into this though as it is a blocker for several usage scenarios at the moment. Have reworked my patch for the new fileserver backends tf198/salt@4f9c713 so that you can declare environments as private which seems like a more natural separation and gives cleaner code. Usage is pretty much the same as above except you need to specify the /etc/master/salt
/srv/pillar/private.sls - distribute the secret through pillar mechanism
/srv/private/gK9yOuETT9pKdnsvWAhbbHoYqJlchxDD/cert.pem
/srv/salt/ssl.sls
minions cant see the files $ salt 'server1.*' cp.list_master
{'server1.example.com': ['top.sls', 'ssl.sls']}
$ salt 'server1.*' cp.list_master private
{'server1.example.com': []} |
Hmm, this is a good direction, but we would need to evaluate some of the security implications more. |
Agreed - I'm still at the evaluation stage so am just kicking a few ideas about to see whether we can make SaltStack bend to our particular needs. Obviously full granular access control is preferable but this gives me enough to be going on with. Assuming of course that there is no way the secret leaks through any of the logging/caching internals... BTW. I can't find anywhere in the current test suite to add master/config behaviour tests - is this currently not covered? |
Yes, you can set config values on the master, in here: |
I've worked around this via mako (er, python).
Then, have a state that references this:
and ssl-file prints the data:
Won't work for binary data, obviously, but if you encode it base64 at the start and decode it in ssl-file (use mako instead if jinja) you'd get there eventually. |
I've solved this by writing custom ext_pillar: https://gist.github.com/jollyroger/6037683. This module has some assumptions but is pretty straightforward:
You need to configure ext_pillar in master's config as well as to point out the path to the ext_pillar (for example, the code above is written to
In this example ext_pillar will populate pillar key
The actual states using this pillar can look like this:
Thanks to @Mrten for inspiration since most of the ideas are his, I just better like the ext_pillar idea. |
One extra thing to add to this discussion - any solution that uses pillars results in the file being transferred every time regardless. Hardening salt envs in some way retains all the benefits of file.managed so is preferable from a network overheads point of view... |
+1 |
This was implemented about 7 weeks ago in 3077e63 and will be in 0.17.0. Closing. |
I don't quite understand the difference. Pillar data aren't files, they're strings, integers, etc. This issue asked for the ability to populate an entire file from pillar data, and the above commit does that. |
@terminalmage Yes, it isn't very clear how to interpret what the original poster wanted; however, he gives an example in his second post, where the pillar contains` date: {% include "blah" %} Apparently he wants the pillar to store "blah" as a separate file, not as as a string inside the pillar. I think that this is not possible; the "include" trick above won't work if "blah" contains newlines, and I don't see any way in jinja to make it work; you'd need something like date: |
{% include "blah" | replace("\n", "\n ") %} which doesn't work of course (is there anything like this? I'm far from a jinja guru). The only workaround seems to be to have the required contents inside the pillar file: date: |
This is an important date
just because it is important:
2013-11-13 However, I think that in complicated pillars it might be beneficial to be able to store the stuff in a separate file. |
@aptiko What I wanted was the ability to store SSL certificates in Pillar. This has been working for me for ages now, but I see where you're going with it. |
@aptiko I thought this ticket referenced this need too - I share your opinion. Storing SSL certificates on separate files inside pillar would be much easier to manage rather than inlining the content. Should this be ticketed as a new issue? |
@ruimarinho So far inlining the content works for me (I have PGP and SSL keys, and also small html templates - see, for example, https://github.com/openmeteo/salt-enhydris/blob/master/pillar.example#L41-L47). I can imagine that this could become messy, so I chose to share this thought in this ticket.I don't know if it should be ticketed. I'm relatively new to Salt and I don't know how it's managed and where it's going. |
@aptiko I also inline SSL keys like you did. Nice tip about jinja templates too, though. Thanks! So, what's the outcome of this issue? Can anyone related to Salt shed some light? |
So, how do we distribute binary file data (eg binary license keys) from pillars? |
@clearclaw I'm not sure that this is supported by the contents_pillar option. One roadblock would be getting the actual binary data into the pillar data structure. Even then, I'd be worried about that data being mangled in some way by msgpack. Then again, we distribute binary files from the fileserver just fine, so maybe it wouldn't be a problem. That said, I think you should still open a new issue specifically for the binary file data problem. I think we would need a special external pillar module to get this data in, plus probably an additional file module function to deliver it. |
+1 |
+1 for this feature (otherwise, a helper script that generates key files as YAML would be appreciated LOL) |
At it's simplest this script would be absolutely trivial: script.py: #!python
import sys
print("key: |"
for line in sys.stdin.splitlines():
print(" " * 4 + line) call it with Adjust it to suit your needs... |
+1 |
So is it still not possible to reference full files as pillar data? I also want to store different client SSL certificates out from my pillar folder? |
The solutions here are hacky -- is there really not a solution for this? I need to keep SSL keys private, so pillar data is the only logical answer with salt, but inline data in pillar files for this is a bit of an upkeep nightmare. Just bumping this issue so someone can point me in the right direction if there's a more elegant solution I don't know about. |
@kevinquinnyo This is being tracked in a new issue, #9569. |
Lack of major features like this, makes me wonder if there is actually anyone using salt in production environments as their primary configuration management software, and if people do, to what extent? |
We have many thousands of users managing millions of servers with salt. My guess is most people have gotten around this by putting their keys in pillar in a similar fashion to this:
Then you can use Little hacky, but workable. I do agree that this feature (#9579) would be great, and have labeled it such that it will be reviewed for inclusion in our next feature release of salt. |
Yeah, I do it exactly like this... hacky.. but works.. |
We do not have millions of servers, just hundreds and we do exactly same workaround for ssh keys, keytabs, right now. The problem is we have different ssh keys and different keytab for every server. So that means 100s of ssh-keys and keytabs and they all have to go into yaml files exactly like you just like you described. What happens when you want to redo all ssh=keys or keytabs on all servers? You need to take out old entries (manually, or we'd have to write smething that manipulates .yml files) and put in new entries. Repeat 100s of times. Having something like this:
Is soo much easier to manage and cleaner. If we want to rekey all servers all we do is:
That would be great. |
I agree with you, but I'd rather shove secrets management into Vault before having to manage that many keys in Pillar. Alternately, I'd generate those Pillar files programmatically; there's little value in doing them by hand. |
You guys know http://docs.saltstack.com/en/develop/ref/pillar/all/salt.pillar.file_tree.html#module-salt.pillar.file_tree, though it lacks some features (#19263)? |
Oh, looks interesting.. thanks... but: doesn't work in salt-ssh because of not working nodegroups in salt-ssh.. or? |
Ourselves we do not use nodegroups so the file_tree would not work for us. We use reclass adapter which is awesome. QuinnyPig: of course, we could also just write a whole configuration management software ourselves... So far we resorted to converting files to base64, and pasting them into .yml files. I find this solution unacceptable and hacky. Imagine if 'source: salt://' did not exist and you just had to paste all contents into .yml pillar file. There is also a matter of supporting and making it understandable by other team members. I could come up with a bizarre and complex solution that I only understand, but I'd prefer something supported, standard and available at http://docs.saltstack.com/ (i'd like to add support is something my company would pay money for ). |
Can you please take the discussion to the mailinglists? |
It's a closed issue, I'm fine with the discussion happening here. Remember you can unsubscribe in the sidebar on the right so you don't get e-mails for this issue. |
Hi all, I have hard time using
|
|
@terminalmage thx for your feedback. The problem is:
and putting an gpg-encrypted file in
I tried to add The gpg renderer works fine with regular pillar data though. |
The ext_pillar is working as expected, as is |
I have opened #31006 for this. |
@fbretel I have exactly the same issue. I am trying to use gpg renderer (works perfectly with regular pillars) but no luck to have this working with ext_pillar. Pillar date is not decrypted. I've tried to debug it a bit and looks like ext_pillar only use yaml renderer even then |
I've been reading this and related threads - as many of you looking for a solution for pkis. |
If I want to populate a file (say, /etc/ssl/cert.pem) that not every minion should be able to see, Pillar is ideal for this; however right now I don't have that option.
The text was updated successfully, but these errors were encountered: