aboutsummaryrefslogtreecommitdiffstats
path: root/qtip/util/env.py
diff options
context:
space:
mode:
Diffstat (limited to 'qtip/util/env.py')
-rw-r--r--qtip/util/env.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/qtip/util/env.py b/qtip/util/env.py
index d00320c4..9299f8c0 100644
--- a/qtip/util/env.py
+++ b/qtip/util/env.py
@@ -94,7 +94,8 @@ class AnsibleEnvSetup(object):
if not all_files_exist(PRIVATE_KEY, PUBLIC_KEY):
logger.info("Generate default keypair {0} under "
"{1}".format(KEYNAME, os.environ['HOME']))
- cmd = '''ssh-keygen -t rsa -N "" -f {0} -q -b 2048'''.format(PRIVATE_KEY)
+ cmd = '''ssh-keygen -t rsa -N "" -f {0} -q -b 2048
+ -C qtip@insecure'''.format(PRIVATE_KEY)
os.system(cmd)
self.keypair['private'] = PRIVATE_KEY
self.keypair['public'] = PUBLIC_KEY
@@ -192,14 +193,19 @@ class AnsibleEnvSetup(object):
def cleanup(self):
CI_DEBUG = os.getenv('CI_DEBUG')
- if CI_DEBUG:
+ if CI_DEBUG is not None and CI_DEBUG.lower() == 'true':
logger.info("DEBUG Mode: please do cleanup by manual.")
else:
- for ip in self.host_ip_list:
- logger.info("Cleanup authorized_keys from {0}...".format(ip))
- cmd = 'bash {0}/cleanup_creds.sh {1} {2}'.format(
- SCRIPT_DIR, ip, self.keypair['private'])
- os.system(cmd)
+ with open(self.keypair['public'], 'r') as f:
+ key = f.read().strip('\n').replace('/', '\/')
+ if key:
+ for ip in self.host_ip_list:
+ logger.info("Cleanup authorized_keys from {0}...".format(ip))
+ cmd = '''bash {0}/cleanup_creds.sh {1} {2} "{3}"'''.format(
+ SCRIPT_DIR, ip, self.keypair['private'], key)
+ os.system(cmd)
+ else:
+ logger.error("Nothing in public key file.")
logger.info("Cleanup hostfile and keypair.")
clean_file(self.hostfile,