Replies: 6 comments 12 replies
-
I don't use the Ansible vault collection things much any more, and even then, not much either. But I have been doing a lot of command line building lately using hvac. The cli had a ton of work around making things being named consistently with respect to type, mount_point (which is type of mount_point isn't set), and the backend configuration paths. Being from a Rails background before my Python time, I'm rather fond of "batteries included, but swappable".
I'm a +1 for convention over configuration here, especially if it means there is no more "where does data go" in the middle of In this case, if it's If someone needs to set it because convention is failing us, My only concern then is one of naming, and consistency with hvac that people might be familiar with. In that case, in hvac: read_secret_version(path, version=None, mount_point='secret') I would lobby for the same key/variable names in ansible/yaml:
But then, I get stuck on
Generally for the idea though! |
Beta Was this translation helpful? Give feedback.
-
Thanks for working on this. Path parsingI see another catch: the mount point name may contain the I see two viable alternatives:
These two tasks would do exactly the same: - community.hashi_vault.vault_kv_get:
mount_point: secret
path: relative/path/to/secret
- community.hashi_vault.vault_kv_get:
path: secret/relative/path/to/secret When using a - community.hashi_vault.vault_kv_get:
mount_point: some/mount/point
path: relative/path/to/secret
NamingI would use |
Beta Was this translation helpful? Give feedback.
-
Hello from the Vault Developer Experience team at HashiCorp! I wanted to chime in on this discussion since our team has actually been talking about the pathing differences between KV v1 and v2 a lot these days. My team has actually observed that the shortened path used by the KV CLI commands ( While Because of that work which is currently in progress, it might be better for other tooling to avoid following the "shortened path" style of the current CLI. If you feel it works better for you then of course feel free to pursue it, but you will likely run into what we did with the CLI: that even though it looks simpler, you may find many users bang their heads against it as they wonder why the real path Something like:
could be a more similar approach to what we're trying to do going forward, and similar to what HVAC and other libraries do today. On the Ansible side, when you see that version is "2", that means the Ansible plugin will insert the /data in between the mount path and secret path in the API call. When version is "1", no need to add /data in there. Metadata could be worked with the same way but with (I'm personally not very familiar with Ansible so forgive me if I've missed anything here or said something that obviously wouldn't work with Ansible collection syntax!) |
Beta Was this translation helpful? Give feedback.
-
Is that true and tested? I swear I tried mount points with / in them a few weeks ago, and it wasn't allowed in the vault cli, as the enabling if auth methods griped about the value. If I changed / to -, it was fine. Now I have to revisit this myself. :-) Maybe this was only true for some backends and not others? |
Beta Was this translation helpful? Give feedback.
-
I hope I am misunderstanding this because this feels worse. You currently have 2 ways of doing this.. the CLI path and the API path.. and instead of solving this by unifying to the proper (API) path, you add a 3rd way to add more confusion? Please just add a new subcommand "vault kv2" that allows you to use the API path but still does the pretty presentation of data.. this means if I want to list I would do "vault kv2 list kv/metadata/blah" and if I want to read it's "vault kv2 get kv/data/blah". Uniform paths are the number 1 complaint from my users and this simple backward compatible solution solves it. |
Beta Was this translation helpful? Give feedback.
-
For anyone who was interested, I have started implementation of the first KV content (for reads): |
Beta Was this translation helpful? Give feedback.
-
I'd like to introduce modules and plugins for the
kv
secrets engine soon, but I'm debating about how to specify the mount point and path.In most of the Vault libraries (include the
hvac
library we use in this collection), the mount point of the secret engine must be specified separately, and the path is specified relative to that, for example:https://hvac.readthedocs.io/en/stable/source/hvac_api_secrets_engines.html#hvac.api.secrets_engines.KvV2.read_secret_version
So if you want to read a secret at the path
secret/something/else/password
, you would call that as:(or in this case you can leave out
mount_point
because the default mount is used).Notably though, the Vault CLI does not make this separation:
As it relates to us, the way of calling as a module could be like this:
or like this:
The way the CLI does it is probably more user friendly in the case of say, copy/pasting your path from the Vault Web UI into a command, but other modules dealing with secret backends will likely need to take a mount point parameter of some kind, and consistency with those might be better, especially when you consider
module_defaults
and being able to set it once.I'm somewhat torn on which direction to go.
There's also the option to take both forms, but this becomes a parsing and testing burden. Any form of accepting a single complete path requires internal parsing anyway because we need to separate it to pass it to
hvac
,but when theActually, we can't assume this, because mounts can contain zero or more slashespath
is always assumed full, we can always assume the first component behind/
is the mount./
, see #229 (comment)If a path can be either full or not full, and we take a mount point option, we need a way to determine whether or not to use the mount option. If the mount had no default, that would be relatively straightforward, but having no default runs counter to both the CLI and most of the libraries out there.
Having a default means we can't tell whether a given path is meant to be full unless we take another option to control that (
use_mount_point
?path_is_full
?), or we assume that if the first component matches the default that the path is full, but that is error prone: if you have asecret
path under thesecret
mount, thenpath: secret/my_secret
withmount: secret
could not be used to access it.Also for consideration: if we want to define a
backend_mount_point
option in one place for say, all kv content, we can put that in a doc fragment. But if we have a module like this that won't use it, because it parses it out of path, we can't opt-out for that one option, so we either show the option in docs with a note not to use it, or we make a redundant doc fragments, or we define this option separately in every module and plugin.So I'm opening this discussion in the hopes of getting feedback from users of the collection!
Beta Was this translation helpful? Give feedback.
All reactions