salt icon indicating copy to clipboard operation
salt copied to clipboard

Add an option to move a key from the denied state to the accepted state

Open meggiebot opened this issue 11 years ago • 14 comments

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.

meggiebot avatar Oct 20 '15 20:10 meggiebot

Colton did an architecture review on this, committed for Boron

meggiebot avatar Oct 20 '15 20:10 meggiebot

ZD - 455

meggiebot avatar Oct 20 '15 20:10 meggiebot

As a bonus, allow the same using the wheel key commands...

s0undt3ch avatar Jan 25 '16 19:01 s0undt3ch

Implemented.

  1. 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.
  1. Deprecated --include-all option. Didn't changed its behavior.

@s0undt3ch I've updated the wheel.key interface, but not sure how can I test it?

DmitryKuzmenko avatar Feb 04 '16 16:02 DmitryKuzmenko

As a bonus normalized help output for all cmdline salt scripts: capital letters and dots in the sentences, unified "default" and "deprecated" notes.

DmitryKuzmenko avatar Feb 04 '16 16:02 DmitryKuzmenko

@whiteinge can I get you to have a look at #30901? I think it also takes care of #30570.

s0undt3ch avatar Feb 04 '16 17:02 s0undt3ch

Looks like it'll fulfil my use-case.

whiteinge avatar Feb 04 '16 20:02 whiteinge

Ok, it looks I can close this.

DmitryKuzmenko avatar Feb 10 '16 08:02 DmitryKuzmenko

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 avatar Jun 14 '17 18:06 TreverN

@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.

whiteinge avatar Jun 14 '17 23:06 whiteinge

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.

TreverN avatar Jun 15 '17 16:06 TreverN

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.

whiteinge avatar Jun 15 '17 20:06 whiteinge

There's a full example of how to do that in the Reactor docs.

whiteinge avatar Jun 15 '17 20:06 whiteinge

Okay thanks.

TreverN avatar Jun 15 '17 20:06 TreverN