Skip to content
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

Add Vault Pillar/SDB Module #27020

Closed
arnisoph opened this issue Sep 10, 2015 · 57 comments
Closed

Add Vault Pillar/SDB Module #27020

arnisoph opened this issue Sep 10, 2015 · 57 comments
Labels
Execution-Module Feature new functionality including changes to functionality and code refactors, etc. P2 Priority 2 Pillar Platform Relates to OS, containers, platform-based utilities like FS, system based apps
Milestone

Comments

@arnisoph
Copy link
Contributor

Vault secures, stores, and tightly controls access to tokens, passwords, certificates, API keys, and other secrets in modern computing. Vault handles leasing, key revocation, key rolling, and auditing. Vault presents a unified API to access multiple backends: HSMs, AWS IAM, SQL databases, raw key/value, and more.

@jfindlay jfindlay added Feature new functionality including changes to functionality and code refactors, etc. Platform Relates to OS, containers, platform-based utilities like FS, system based apps labels Sep 10, 2015
@jfindlay jfindlay added this to the Approved milestone Sep 10, 2015
@jfindlay
Copy link
Contributor

@bechtoldt, thanks for the report.

@techhat
Copy link
Contributor

techhat commented Sep 10, 2015

@bechtoldt that sounds fantastic!

@eedgar
Copy link
Contributor

eedgar commented Sep 28, 2015

@bechtoldt do you have any implementation ideas for this?

@eedgar
Copy link
Contributor

eedgar commented Sep 28, 2015

@arnisoph
Copy link
Contributor Author

arnisoph commented Oct 2, 2015

@eedgar Nope, I haven't planned to provide a patch so far.

@eedgar
Copy link
Contributor

eedgar commented Oct 6, 2015

I did a little research and there are a few problems with the sdb implementation that make this challenging. currently sdb allows for module/key where modules are defined inside the minion or master config. this does not allow you to specify the full path within the vault very easily .. eg myvault/secret/hello ... sdb would only pass secret to the vault module and loose the hello parameter. Additionally vault secrets can store more than one key value pair inside them .. How can we support which one to retrieve. I think this functionality would be better served creating a vault module with read and write methods.

then use them inside a jinja template like this. {{ salt.vault.read('myvault/secret/hello', key='value1') }}
key can be an optional parameter.

@techhat
Copy link
Contributor

techhat commented Oct 6, 2015

SDB is designed to be simple to call; long URIs defeat the purpose. The intent is that an sdb:// URI would be just enough to refer to a profile configuration which can be much more complex, if necessary.

My suggestion here would be to implement full paths inside the profile, not the URI. Think of the profiles like stored procedures, rather than just connection parameters.

@eedgar
Copy link
Contributor

eedgar commented Oct 7, 2015

the only thing I was thinking was that the number of profiles could get to be quite numerous depending on the number of paths you need to traverse. I think a more feature complete vault module is the way to go here. maybe implement a subset of that for sdb if the demand is there.

@eedgar
Copy link
Contributor

eedgar commented Oct 7, 2015

eg think dynamic paths such as /secret/server1/auth /secret/aws_domain1/credentials /secret/aws_domain2/credentials .. these things can add up fast.

@DanyC97
Copy link

DanyC97 commented Dec 2, 2015

@eedgar have you made any progress on it or you hit a dead end with the sdb? (asking as i'm trying to do the same thing but i'm a bit limited by the options )

@jbussdieker
Copy link

+1 for a vault module

@jfindlay jfindlay added the P3 Priority 3 label Jan 11, 2016
@coen-hyde
Copy link

I hate to just add another +1, but this would be good.

@jfindlay jfindlay added P2 Priority 2 and removed P3 Priority 3 labels Jan 19, 2016
@ketzacoatl
Copy link
Contributor

Would there be interest in a modules implementation that is not using SDB?

If only as a first pass, I believe it would be more valuable to get this working in a simple form, and leave the SDB interface questions for a later date. The simplest form I can see would have a vault module that could get a key, similar to pillar.get, and which could be used in a template like:

{%- set my_secret = salt['vault.get']('path/to/key') %}
{{ my_secret }}

This could also keep it simple (on first pass), by using VAULT_TOKEN from the environment.

EDIT: to implement this as a pillar module would put the secrets in the salt log (right?)

@dmangot
Copy link

dmangot commented Jan 28, 2016

@ketzacoatl I had always envisioned vault as just another pillar back end (like hiera, mysql, s3, etc.) so I'm interested whether it's implemented using SDB or not.

@techhat
Copy link
Contributor

techhat commented Jan 28, 2016

A pillar or execution module would be awesome.

@ketzacoatl
Copy link
Contributor

An execution module means the secrets don't inadvertently end up in the salt log, but a pillar module means users can make use of this more seamlessly (retain loose coupling with salt formula).. but maybe the pillar module could use the execution module, so that both are available?

One thing I am not sure of is how you would retrieve all child keys from a parent path in Vault. I will look into that.

If that sounds good, I would be willing to take a first pass on this. I would use https://github.com/ianunruh/hvac, and keep authentication bare-minimum (use token to start).

@tspecht
Copy link

tspecht commented Feb 18, 2016

Any progress on this? Would be awesome if we could get vault as a pillar backend for Salt!

@ketzacoatl
Copy link
Contributor

@tspecht, I have it on my todo list, but I have not started on it. I hope to do so in the next week or two. Anyone else is welcome to as well, I'm not looking to block, I am just interested in meeting this need but also tied up at the moment.

@jfindlay jfindlay added P1 Priority 1 and removed P2 Priority 2 labels Feb 18, 2016
@thatch45
Copy link
Contributor

@techhat would be the best one to implement this one, but if you start before he does @ketzacoatl let us know. I will slate this for the Carbon release, since the boron release has been frozen

@meggiebot meggiebot modified the milestones: B 2, Approved Feb 18, 2016
@ketzacoatl
Copy link
Contributor

@carlpett, to put in voice in for those with ultra-simplified (or non-existent) salt-masters - I generally run consul + salt-call in a way that avoids the HA burdens for a salt-master. While I like the architectural options available with salt-minions retrieving temp tokens from vault, through their salt-master, a solution that explicitly requires the salt-master can be problematic, and where possible, I like to advocate for the minion retaining the same capabilities. FWIW.

@carlpett
Copy link
Contributor

@ketzacoatl Interesting point, had not thought of that one. The issue with that is how to manage what the minions can read? Configuring all the minions with a Vault root token would sort of default the point of using Vault? If the machine is compromised, it is capable of reading or altering anything within Vault, and even locking everyone else out.

Do you agree, or am I missing something? Is there a benefit of using Vault over just having the credentials in pillar?

@ketzacoatl
Copy link
Contributor

@carlpett, well, with ACLs, you are not required to use a root token - https://www.vaultproject.io/docs/concepts/tokens.html.

@carlpett
Copy link
Contributor

@ketzacoatl Yes, but non-root tokens expire, though, so you'll need to have a system that renews them periodically (you can do mount-tunes to make the expiry time longer, but still something to be aware of). And it might be a pain to manually generate all those tokens with the correct policies.

But if this is a common thing, I could add some support for setting the token in the minion config as well, instead of going to the master, shouldn't be very complicated. I probably wouldn't recommend using it to anyone, though.

@carlpett
Copy link
Contributor

@ketzacoatl I just pushed a branch for masterless, care to have a look if it looks like it would fill you requirements? https://github.com/carlpett/salt-vault/tree/f/masterless

@ketzacoatl
Copy link
Contributor

@carlpett, It's a tiny bit difficult for me to see the details (not sure if that's end of week or something else). Maybe you can add a short doc example for how that would be used with the minion or salt-call?

@carlpett
Copy link
Contributor

@ketzacoatl Sorry about that. I've updated the README (last section) with instructions for masterless.

@ketzacoatl
Copy link
Contributor

ketzacoatl commented May 27, 2016

LGTM, thanks for all your work on this!

@eliasp
Copy link
Contributor

eliasp commented May 28, 2016

is there a good way to share code between state and execution modules?

@carlpett You might want to move common code to a utils module…

@carlpett
Copy link
Contributor

@eliasp That sounds like just the thing :) Does that work for modules that are not distributed along with salt itself, though? Inhouse, we add our custom modules by adding their git-repos as gitfs_remotes; but this may not be the best way to do it?

@carlpett
Copy link
Contributor

@techhat Since I took my time in getting this ready and you built a module in the meantime, what are the plans for this issue?

@techhat
Copy link
Contributor

techhat commented May 29, 2016

@carlpett, I don't mind my code being replaced with superior code.

@eliasp
Copy link
Contributor

eliasp commented May 30, 2016

@carlpett The best way to distribute custom modules (including utils) is to use Dynamic Module Distribution.
For this reason I maintain a local salt-dynmods repo containing the corresponding module directories.

Although it's not perfect yet (#24488), it's quite useful for distributing newer or development versions of specific modules.

@carlpett
Copy link
Contributor

@eliasp Aha, didn't know about _utils. I had already put the state, exec and runners in underscored directories. I'll extract the shared logic to _utils then.

@meggiebot meggiebot added P2 Priority 2 and removed P1 Priority 1 labels Jun 8, 2016
@carlpett
Copy link
Contributor

carlpett commented Jul 9, 2016

Took quite some time again between work and refactoring to get _utils to work, but I've pushed the changes now. What's the process of getting it into "mainline salt"? Just create a PR?

@DanyC97
Copy link

DanyC97 commented Jul 12, 2016

@carlpett yes

@ahammond
Copy link
Contributor

ahammond commented Oct 6, 2016

+1 for anything which allows me to use decentralized vault as an alternative to pillars for secrets management.

@carlpett
Copy link
Contributor

carlpett commented Oct 7, 2016

Sorry - I totally forgot to create the PR for this. Got stuck with some linting problem or similar. I'll try to get it done during the weekend!

@mchugh19
Copy link
Contributor

@carlpett Has there been an update? Is your module releasable?

@carlpett
Copy link
Contributor

@mchugh19 Wow, good reminder... Sorry about being so slow. We've been using it internally for over half a year without any problems, so I guess so. With 2016.11 having support for utils-syncing on the master it should actually be pretty simple to just add it as another file_root (or gitfs remote, that is what we are doing). For 2016.3 you need to do a manual copy of the util to the master's extmod, which is a bit of a bother.

Anyway, it would be better to get it into the distribution. I'll give it a go and hope I can finish it up this time.

@carlpett
Copy link
Contributor

@mchugh19 As an update, I've merged the code into a branch on the main saltstack repo now, and removed the majority of linting issues. I'm still working on minimizing the breakage from the existing code, hopefully I can finalize it tomorrow.

@carlpett
Copy link
Contributor

This has now been merged, a year later. There were a few fixes on the separate repo just the last days, which I'll port over in a separate PR.
But I think this issue can be closed now?

@techhat techhat closed this as completed Feb 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Execution-Module Feature new functionality including changes to functionality and code refactors, etc. P2 Priority 2 Pillar Platform Relates to OS, containers, platform-based utilities like FS, system based apps
Projects
None yet
Development

No branches or pull requests