summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docker/Dockerfile3
-rw-r--r--docker/ansible.cfg.default2
-rw-r--r--func/env_setup.py67
3 files changed, 28 insertions, 44 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 9ed0980e..8ec775eb 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -45,6 +45,9 @@ RUN mkdir -p ${REPOS_DIR}
RUN mkdir -p /root/.ssh
RUN chmod 700 /root/.ssh
+#Config ansible
+COPY ansible.cfg.default /root/.ansible.cfg
+
#Cloning Repos
RUN git config --global http.sslVerify false
diff --git a/docker/ansible.cfg.default b/docker/ansible.cfg.default
new file mode 100644
index 00000000..0451870a
--- /dev/null
+++ b/docker/ansible.cfg.default
@@ -0,0 +1,2 @@
+[defaults]
+callback_whitelist = profile_tasks
diff --git a/func/env_setup.py b/func/env_setup.py
index ea49337d..96f984cb 100644
--- a/func/env_setup.py
+++ b/func/env_setup.py
@@ -57,52 +57,31 @@ class Env_setup:
f_name_2.close()
@staticmethod
- def ssh_test(lister):
- print 'list: ', lister
- for k, v in lister:
- ip_var = k
- print '\nBeginning SSH Test!\n'
- if v != '':
- print ('\nSSH->>>>> {0} {1}\n'.format(k, v))
- time.sleep(2)
-
- ssh_c = 'ssh-keyscan {0} >> ~/.ssh/known_hosts'.format(k)
- os.system(ssh_c)
- ssh_cmd = './data/qtip_creds.sh {0}'.format(ip_var)
- print ssh_cmd
- os.system(ssh_cmd)
- for infinity in range(100):
- try:
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- ssh.connect(k, key_filename='./data/QtipKey')
- stdin, stdout, stderr = ssh.exec_command('ls')
+ def ssh_test(hosts):
+ for ip, pw in hosts:
+ print '\nBeginning SSH Test: %s \n' % ip
+ os.system('ssh-keyscan %s >> ~/.ssh/known_hosts' % ip)
+ time.sleep(2)
+
+ ssh_cmd = './data/qtip_creds.sh %s' % ip
+ print "run command: %s " % ssh_cmd
+ os.system(ssh_cmd)
+
+ ssh = paramiko.SSHClient()
+ ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+ ssh.connect(ip, key_filename='./data/QtipKey')
+
+ for attempts in range(100):
+ try:
+ stdin, stdout, stderr = ssh.exec_command('uname')
+ if not stderr.readlines():
print('SSH successful')
- for line in stdout:
- print '... ' + line.strip('\n')
break
- except socket.error:
- print 'Retrying aSSH %s' % infinity
- time.sleep(1)
- if v == '':
- print ('SSH->>>>>', k)
- ssh_c = 'ssh-keyscan {0} >> ~/.ssh/known_hosts'.format(k)
-
- time.sleep(3)
- os.system(ssh_c)
-
- for infinity in range(10):
- try:
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- ssh.connect(k, key_filename='./data/QtipKey')
- stdin, stdout, stderr = ssh.exec_command('ls')
- print('SSH successful')
- for line in stdout:
- print '... ' + line.strip('\n')
- break
- except socket.error:
- print 'Retrying SSH %s' % infinity
+ except socket.error:
+ print 'SSH is still unavailable, retry!'
+ time.sleep(2)
+ if attempts == 99:
+ print "Try 99 times, SSH failed: %s" % ip
@staticmethod
def ping_test(lister, attempts=30):