Add an option to move a key from the denied state to the accepted state
The use case is; A salt-minion is happily running along. The hardware that was running that minion dies and is replaced. The replacement hardware has the same minion_id as it has the same hostname. We now have a key in denied state and a key in accept state with the same name. The only operation available via salt-key is to delete both.
Workaround Move the key from the minions_denied folder to minions, overwriting the accepted key with the denied one.
Further thoughts Should --accept --force work on either unaccepted/rejected keys as well as denied keys? Rather than having to do one of two things, one action could do either of them that way. Alternatively, --accept --promote could do that.
Colton did an architecture review on this, committed for Boron
ZD - 455
As a bonus, allow the same using the wheel key commands...
Implemented.
- Added the following options to salt-key:
--include-accepted Include accepted keys when rejecting.
--include-rejected Include rejected keys when accepting.
--include-denied Include denied keys when accepting/rejecting.
- Deprecated
--include-alloption. Didn't changed its behavior.
@s0undt3ch I've updated the wheel.key interface, but not sure how can I test it?
As a bonus normalized help output for all cmdline salt scripts: capital letters and dots in the sentences, unified "default" and "deprecated" notes.
@whiteinge can I get you to have a look at #30901? I think it also takes care of #30570.
Looks like it'll fulfil my use-case.
Ok, it looks I can close this.
The include options are completely undocumented (at least as of salt-key 2016.11.5 (Carbon)). Can it please be documented? I can submit such doc if necessary. Trying a comment here first.
I stumbled upon this git hub page, the includes were exactly what we needed for an HPC environment where compute nodes are often re-imaged with the same host name (minion ID). This is an important option, even if a mv or cp would do the same thing.
@TreverN thanks for the mention! Looks like docs were added to the Python API but not the CLI reference. If you'd like to add those we would definitely appreciate it. The doc in question lives here:
https://github.com/saltstack/salt/blob/develop/doc/ref/cli/salt-key.rst
...plus any other places you see that warrant a mention or link.
Before I try to update any doc, I don't see any documentation on this:
Is there a tie in with auto_accept or autosign_file on a master? That is, can we specify autosign for a minion such that when a new key accept happens, if that creates a denied key for the minion, it will overwrite the existing accepted key for the minion with the denied key?
I don't want to veer into support questions here, but I can't find such an option but it seems natural to have that, so wondering if that too is just undocumented.
I am not aware of overlap with auto_accept. For that workflow I would recommend using a Reactor file instead that listens for the salt/auth event and accepts the key by calling the key.accept wheel module, which does support that flag.
There's a full example of how to do that in the Reactor docs.
Okay thanks.