Flag to preserve minion cache on key delete

Refs #15673
This commit is contained in:
Mike Place 2014-10-03 11:43:33 -06:00 committed by C. R. Oldham
parent 6df52780eb
commit a4c524176f
3 changed files with 14 additions and 3 deletions

View File

@ -140,6 +140,14 @@
# 'aes_key_rotate' event with the 'key' tag and acting appropriately.
# ping_on_rotate: False
# By default, the master deletes its cache of minion data when the key for that
# minion is removed. To preserve the cache after key deletion, set
# 'preserve_minion_cache' to True.
#
# WARNING: This may have security implications if compromised minions auth with
# a previous deleted minion ID.
#preserve_minion_cache: False
# If max_minions is used in large installations, the master might experience
# high-load situations because of having to check the number of connected
# minions for every authentication. This cache provides the minion-ids of

View File

@ -186,6 +186,7 @@ VALID_OPTS = {
'pillar_source_merging_strategy': str,
'ping_on_key_rotate': bool,
'peer': dict,
'preserve_minion_cache': bool,
'syndic_master': str,
'runner_dirs': list,
'client_acl': dict,
@ -474,6 +475,7 @@ DEFAULT_MASTER_OPTS = {
'pillar_source_merging_strategy': 'smart',
'ping_on_key_rotate': False,
'peer': {},
'preserve_minion_cache': False,
'syndic_master': '',
'runner_dirs': [],
'outputter_dirs': [],

View File

@ -485,9 +485,10 @@ class Key(object):
minions = []
for key, val in keys.items():
minions.extend(val)
for minion in os.listdir(m_cache):
if minion not in minions:
shutil.rmtree(os.path.join(m_cache, minion))
if self.opts.get('preserve_minion_cache', False):
for minion in os.listdir(m_cache):
if minion not in minions:
shutil.rmtree(os.path.join(m_cache, minion))
def check_master(self):
'''