mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
minionswarm.py: allow re-use of temporary files
This commit is contained in:
parent
b2f7d3e3cf
commit
382cf21b5f
1 changed files with 18 additions and 15 deletions
|
@ -171,16 +171,17 @@ class Swarm(object):
|
|||
Create the shared pki directory
|
||||
'''
|
||||
path = os.path.join(self.swarm_root, 'pki')
|
||||
os.makedirs(path)
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
|
||||
print('Creating shared pki keys for the swarm on: {0}'.format(path))
|
||||
subprocess.call(
|
||||
'salt-key -c {0} --gen-keys minion --gen-keys-dir {0} '
|
||||
'--log-file {1} --user {2}'.format(
|
||||
path, os.path.join(path, 'keys.log'), self.opts['user'],
|
||||
), shell=True
|
||||
)
|
||||
print('Keys generated')
|
||||
print('Creating shared pki keys for the swarm on: {0}'.format(path))
|
||||
subprocess.call(
|
||||
'salt-key -c {0} --gen-keys minion --gen-keys-dir {0} '
|
||||
'--log-file {1} --user {2}'.format(
|
||||
path, os.path.join(path, 'keys.log'), self.opts['user'],
|
||||
), shell=True
|
||||
)
|
||||
print('Keys generated')
|
||||
return path
|
||||
|
||||
def start(self):
|
||||
|
@ -282,7 +283,8 @@ class MinionSwarm(Swarm):
|
|||
)
|
||||
|
||||
dpath = os.path.join(self.swarm_root, minion_id)
|
||||
os.makedirs(dpath)
|
||||
if not os.path.exists(dpath):
|
||||
os.makedirs(dpath)
|
||||
|
||||
data.update({
|
||||
'id': minion_id,
|
||||
|
@ -295,11 +297,12 @@ class MinionSwarm(Swarm):
|
|||
|
||||
if self.opts['transport'] == 'zeromq':
|
||||
minion_pkidir = os.path.join(dpath, 'pki')
|
||||
os.makedirs(minion_pkidir)
|
||||
minion_pem = os.path.join(self.pki, 'minion.pem')
|
||||
minion_pub = os.path.join(self.pki, 'minion.pub')
|
||||
shutil.copy(minion_pem, minion_pkidir)
|
||||
shutil.copy(minion_pub, minion_pkidir)
|
||||
if not os.path.exists(minion_pkidir):
|
||||
os.makedirs(minion_pkidir)
|
||||
minion_pem = os.path.join(self.pki, 'minion.pem')
|
||||
minion_pub = os.path.join(self.pki, 'minion.pub')
|
||||
shutil.copy(minion_pem, minion_pkidir)
|
||||
shutil.copy(minion_pub, minion_pkidir)
|
||||
data['pki_dir'] = minion_pkidir
|
||||
elif self.opts['transport'] == 'raet':
|
||||
data['transport'] = 'raet'
|
||||
|
|
Loading…
Add table
Reference in a new issue