salt.wheel.key.delete_dict does not work on unaccepted keys
Description of Issue
salt.wheel.key.delete_dict does not work on unaccepted keys
Setup
the delete.sls file has the following content:
salt.wheel:
- name: key.delete_dict
- match:
minions:
- <key1>
- <key2>
Steps to Reproduce Issue
if both keys are in Unaccepted state, and we run:
salt salt-master-minion state.apply delete
result in
----------
ID: Delete minion keys
Function: salt.wheel
Name: key.delete_dict
Result: True
Comment: Wheel function 'key.delete_dict' executed.
Started: 09:35:12.698040
Duration: 3539.239 ms
Changes:
----------
return:
----------
minions_pre:
- <key1>
- <key2>
Summary for salt-master-minion
------------
Succeeded: 1 (changed=1)
Failed: 0
------------
Total states run: 1
Total run time: 3.539 s
but the keys are still in the unaccepted state (not removed)
Versions Report
Salt: 2018.3.0
Dependency Versions:
cffi: 1.14.0
cherrypy: unknown
dateutil: 2.5.3
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.11.1
libgit2: 0.24.5
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.8
mysql-python: Not Installed
pycparser: 2.19
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: 0.24.2
Python: 2.7.13 (default, Sep 26 2018, 18:42:22)
python-gnupg: Not Installed
PyYAML: 5.3
PyZMQ: 18.1.1
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.4.3
ZMQ: 4.3.2
System Versions:
dist: debian 9.11
locale: ANSI_X3.4-1968
machine: x86_64
release: 4.14.138+
system: Linux
version: debian 9.11
but seems salt.wheel.key.delete works (for a single minion)
The confusion is caused by incomplete documentation. When examining the code, the delete_dict-function seems to use the contents of the provided match-dict as components of the path in salt's pki-dir.
The fact that your example leaves unaccepted keys alone is because you are using minions as a key, which is the subdirectory that contains the accepted keys. If you would be using minions_pre, then you would be targeting unaccepted keys. (In fact, it looks like the function result shows you the keys present, which are 2 keys in minions_pre).
thanks! will the following work if I want to delete the keys either as unaccepted or accepted?
- name: key.delete_dict
- match:
minions_pre:
- <key1>
- <key2>
minions:
- <key1>
- <key2>