Commit 0ab2be69 authored by Spiros Koulouzis's avatar Spiros Koulouzis

Change permissions of keys

Create separate dir for each invocation 
parent 766640e6
{
"creationDate": 1491309802500,
"parameters": [
{
"url": null,
"encoding": "UTF-8",
"value": null,
"name": "credential",
"attributes": {
"role": "master",
"IP": "52.91.133.78",
"user": "ubuntu"
}
},
{
"url": null,
"encoding": "UTF-8",
"value": null,
"name": "credential",
"attributes": {
"role": "slave",
"IP": "54.144.250.248",
"user": "ubuntu"
}
},
{
"url": null,
"encoding": "UTF-8",
"value": "ansible",
"name": "cluster",
"attributes": null
},
{
"url": null,
"encoding": "UTF-8",
"value": "'---':\n- hosts: all\n tasks:\n - name: install sysbench\n apt: name=\"{{ item }}\" update_cache=yes state=latest\n with_items: [phoronix-test-suite, sysbench, expect, git, python-pexpect, php-zip]\n become: true\n - {name: Phoronix-test-suite accept User Agreement, command: 'expect -c \"spawn phoronix-test-suite;\n expect \\\"Do you agree to these terms and wish to proceed \\(Y/n\\):\\\"; send \\\"Y\n \\\"; expect \\\"Enable anonymous usage / statistics reporting \\(Y/n\\):\\\"; send\n \\\"n \\\"; expect \\\"Enable anonymous statistical reporting of installed software\n / hardware \\(Y/n\\):\\\"; send \\\"n \\\"; interact;\"', become: true}\n - {name: Install stream, command: phoronix-test-suite install-test stream, become: true}\n - {name: Install iozone, command: phoronix-test-suite install-test iozone, become: true}\n - {name: Count vCPU, command: nproc, register: vcpunumber, become: true}\n - {debug: 'msg=\"{{ vcpunumber.stdout }}\"'}\n - {name: Run sysbench, command: 'sysbench --test=cpu --cpu-max-prime=100000 --num-threads={{\n vcpunumber.stdout }} run', register: sysbenchoutput, become: true}\n - {debug: 'msg=\"{{ sysbenchoutput.stdout }}\"'}\n - {name: Run stream, command: 'expect -c \"spawn phoronix-test-suite run-test stream;\n expect \\\"Type:\\\"; send \\\"4 \\\"; expect \\\"\\(Y/n\\):\\\"; send -- \\\"y\\r\\\"; expect\n \\\"Enter a name to save these results under:\\\"; send \\\"out \\\"; expect \\\"Enter\n a unique name to describe this test run / configuration:\\\"; send -- \\\"unique\\r\\\";\n expect \\\"New Description:\\\"; send \\\"\\r\\\"; expect \\\"Would you like to upload\n the results to OpenBenchmarking.org (Y/n):\\\"; send \\\"n\\r\\\"; interact;\"', register: streamoutput,\n become: true}\n - {debug: 'msg=\"{{ streamoutput.stdout }}\"'}\n - {name: Run iozone, command: 'expect -c \"spawn phoronix-test-suite run-test iozone;\n expect \\\"Record Size:\\\"; send \\\"2 \\\"; expect \\\"File Size:\\\"; send \\\"2 \\\"; expect\n \\\"Disk Test:\\\"; send \\\"3 \\\"; expect \\\"\\(Y/n\\):\\\"; send -- \\\"y\\r\\\"; expect \\\"Enter\n a name to save these results under:\\\"; send \\\"out \\\"; expect \\\"Enter a unique\n name to describe this test run / configuration:\\\"; send -- \\\"unique\\r\\\"; expect\n \\\"New Description:\\\"; send \\\"\\r\\\"; expect \\\"Would you like to upload the results\n to OpenBenchmarking.org (Y/n):\\\"; send \\\"n\\r\\\"; interact;\"', register: iozoneoutput,\n become: true}\n - {name: Get stream results, command: phoronix-test-suite result-file-to-csv out,\n register: streamoutput, become: true}\n - {debug: 'msg=\"{{ streamoutput.stdout }}\"'}\n",
"name": "playbook",
"attributes": null
}
]
}
{"creationDate":1491311962544,"parameters":[{"url":null,"encoding":"UTF-8","value":"-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEAm6AALYxkJFNzD3bfVJ4+hMY5j0/kqM9CURLKXMlYuAysnvoG8wZKx9Bedefm\neNSse4zTg798ZA2kDMZFIrwp1AseTwtj8DDu5fhG5DjyI3g6iJltS5zFQdMXneDlHXBX8cncSzNY\nRx0NdjEMAe7YttvI8FNlxL0VnMFli/HB/ftzYMe5+AmkSROncVGHiwoiUpj+vtobCFOYtXsCf6ri\nd4lgWA5wv6DZT/JKCYymiBqgSXu3ueFcEzw5SAukARWVjn1xccjZkokFfBbO/FpYY00TrUTBw9S6\nD3iM+gj8RT6EKILOmhrt71D21S95WAWIT7h2Y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AfY1X5oSccOMYqORjRbxEB3svb4BAoGAGTgFuq9Zojh/KIqY8b4HpEfmh6CQ\nhLVfD98Nqd6GDbxgvIM0v4mFXE92x2jn35Ia0JdFyh3B8Vkl7sqQZfxDFXI9O9pte2mPJxY9ICaY\n55+X/SN1pd53BH+gaPZJy/R+Vpvs5MN48howjUKy5UKpoFeUWrS5QArjtvNCm4SGlXw=\n-----END RSA PRIVATE KEY-----\n","name":"credential","attributes":{"role":"master","IP":"52.91.133.78","user":"ubuntu"}},{"url":null,"encoding":"UTF-8","value":"-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEAm6AALYxkJFNzD3bfVJ4+hMY5j0/kqM9CURLKXMlYuAysnvoG8wZKx9Bedefm\neNSse4zTg798ZA2kDMZFIrwp1AseTwtj8DDu5fhG5DjyI3g6iJltS5zFQdMXneDlHXBX8cncSzNY\nRx0NdjEMAe7YttvI8FNlxL0VnMFli/HB/ftzYMe5+AmkSROncVGHiwoiUpj+vtobCFOYtXsCf6ri\nd4lgWA5wv6DZT/JKCYymiBqgSXu3ueFcEzw5SAukARWVjn1xccjZkokFfBbO/FpYY00TrUTBw9S6\nD3iM+gj8RT6EKILOmhrt71D21S95WAWIT7h2YBsy1KAvMixhNf9VaQIDAQABAoIBAHhVYK3Xl3tr\nN1Xm0ctJTQg3ijxhR2qsUBgGUokqezpdOoD2zbbOz7XvTYsX1GLr967U9pwxzUpELexexwiTvDgk\nnLv8D7ui6qbRsmc4DSsWBRSophVIVFKQmftO8Xow6x+fuYJAYmsicM1KIYHBILtL+PSzV8anenWq\nKQ3r0tfCiQhEzKEk4b1uT3SJWQyHE++JAhVkO7lIeb6S9Dg1jAaAeMnJ/NiMxTarpPRnxe6hsTsH\ngG1iKWo+Skcl4SknOc+CMEfyDjG4FL7MGhKduahsO8vMUrgGsDD7EH3NiX/FweB8La6qpDYAwFpC\nycrooyhiyzw8Wb5gGaYnmvr9l70CgYEAx74O8JleXaHpxEAmh4h7VbLmJ3mOylfBmOdzcHeedJQw\nack2SAv65WBI9S9MEQ7J/vFuyw5HNk3C/mcWgzDQXSNIhHLvl/Z9sux/Qpm3SQWLz0RBxKV3dJ4r\nwcAxzVA93+/L1Nee+VOKnlyRumvVa6+XLsLagpap2AVcTqlerMcCgYEAx3T2pXtqkCE9eU/ov22r\npdaKjgHoGOUg1CMEfWi/Ch6sYIIRyrHz6dhy+yR1pXNgPbLWdrn8l88F3+IsmbaMupMgRmqwEC3G\n9Y2FglGIVvRdZaagvRxLzRCcvcN4v6OYs9ST4o1xlv7Qxphld+0XDKv7VSCv/rASuK8BqlFL3E8C\ngYArMXJRnRjG7qh6g9TRIjZphdI3XxX9s5Rt2D8iZvuhAhqmBZjzY4PR7kxYmO2+EpCjzNnEl0XW\n/GHaWbiIjhnAykx4N9KP7gGom3O5lzwHUme1XnFKcO2wDjQwJbufRmba8iQF1srN577mF+Z7ha4V\nJ1duCTzvWF1KFX6sk/uhKQKBgAcDFai7rgNjJ8YcCRKxyFcMM9LKPl6hr4XFtWKzTAQPEABUkkuN\n9gVClsg9f+VRKRECOIf0Ae1UWeCFEwxUXp4wjfHrzkTDVztKvmbWdvSXorDwKrZ7SC7tZpVFSfly\nxuuLjadpUZT9YFmbAfY1X5oSccOMYqORjRbxEB3svb4BAoGAGTgFuq9Zojh/KIqY8b4HpEfmh6CQ\nhLVfD98Nqd6GDbxgvIM0v4mFXE92x2jn35Ia0JdFyh3B8Vkl7sqQZfxDFXI9O9pte2mPJxY9ICaY\n55+X/SN1pd53BH+gaPZJy/R+Vpvs5MN48howjUKy5UKpoFeUWrS5QArjtvNCm4SGlXw=\n-----END RSA PRIVATE KEY-----\n","name":"credential","attributes":{"role":"slave","IP":"54.144.250.248","user":"ubuntu"}},{"url":null,"encoding":"UTF-8","value":"ansible","name":"cluster","attributes":null},{"url":null,"encoding":"UTF-8","value":"---\n- hosts: all\n tasks:\n - name: install sysbench\n apt: name=\"{{ item }}\" update_cache=yes state=latest\n with_items: [phoronix-test-suite, sysbench, expect, git, python-pexpect, php-zip]\n become: true\n - {name: Phoronix-test-suite accept User Agreement, command: 'expect -c \"spawn phoronix-test-suite;\n expect \\\"Do you agree to these terms and wish to proceed \\(Y/n\\):\\\"; send \\\"Y\n \\\"; expect \\\"Enable anonymous usage / statistics reporting \\(Y/n\\):\\\"; send\n \\\"n \\\"; expect \\\"Enable anonymous statistical reporting of installed software\n / hardware \\(Y/n\\):\\\"; send \\\"n \\\"; interact;\"', become: true}\n - {name: Install stream, command: phoronix-test-suite install-test stream, become: true}\n - {name: Install iozone, command: phoronix-test-suite install-test iozone, become: true}\n - {name: Count vCPU, command: nproc, register: vcpunumber, become: true}\n - {debug: 'msg=\"{{ vcpunumber.stdout }}\"'}\n - {name: Run sysbench, command: 'sysbench --test=cpu --cpu-max-prime=100000 --num-threads={{\n vcpunumber.stdout }} run', register: sysbenchoutput, become: true}\n - {debug: 'msg=\"{{ sysbenchoutput.stdout }}\"'}\n - {name: Run stream, command: 'expect -c \"spawn phoronix-test-suite run-test stream;\n expect \\\"Type:\\\"; send \\\"4 \\\"; expect \\\"\\(Y/n\\):\\\"; send -- \\\"y\\r\\\"; expect\n \\\"Enter a name to save these results under:\\\"; send \\\"out \\\"; expect \\\"Enter\n a unique name to describe this test run / configuration:\\\"; send -- \\\"unique\\r\\\";\n expect \\\"New Description:\\\"; send \\\"\\r\\\"; expect \\\"Would you like to upload\n the results to OpenBenchmarking.org (Y/n):\\\"; send \\\"n\\r\\\"; interact;\"', register: streamoutput,\n become: true}\n - {debug: 'msg=\"{{ streamoutput.stdout }}\"'}\n - {name: Run iozone, command: 'expect -c \"spawn phoronix-test-suite run-test iozone;\n expect \\\"Record Size:\\\"; send \\\"2 \\\"; expect \\\"File Size:\\\"; send \\\"2 \\\"; expect\n \\\"Disk Test:\\\"; send \\\"3 \\\"; expect \\\"\\(Y/n\\):\\\"; send -- \\\"y\\r\\\"; expect \\\"Enter\n a name to save these results under:\\\"; send \\\"out \\\"; expect \\\"Enter a unique\n name to describe this test run / configuration:\\\"; send -- \\\"unique\\r\\\"; expect\n \\\"New Description:\\\"; send \\\"\\r\\\"; expect \\\"Would you like to upload the results\n to OpenBenchmarking.org (Y/n):\\\"; send \\\"n\\r\\\"; interact;\"', register: iozoneoutput,\n become: true}\n - {name: Get stream results, command: phoronix-test-suite result-file-to-csv out,\n register: streamoutput, become: true}\n - {debug: 'msg=\"{{ streamoutput.stdout }}\"'}\n","name":"playbook","attributes":null}]}
\ No newline at end of file
{"creationDate":1491312079020,"parameters":[{"url":null,"attributes":null,"name":"credential","value":"[{"host":"54.144.250.248","result":{"msg":"Failedtoconnecttothehostviassh:Hostkeyverificationfailed.\\r\\n","unreachable":true,"changed":false}},{"host":"52.91.133.78","result":{"msg":"Failedtoconnecttothehostviassh:Warning:Permanentlyadded\"52.91.133.78\"(ECDSA)tothelistofknownhosts.\\r\\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\\r\\n@WARNING:UNPROTECTEDPRIVATEKEYFILE!@\\r\\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\\r\\nPermissions0664for\"/home/alogo/workspace/DRIP/drip-deployer/2.txt\"aretooopen.\\r\\nItisrequiredthatyourprivatekeyfilesareNOTaccessiblebyothers.\\r\\nThisprivatekeywillbeignored.\\r\\nLoadkey\\"/home/alogo/workspace/DRIP/drip-deployer/2.txt\\":badpermissions\\r\\nPermissiondenied(publickey).\\r\\n","unreachable":true,"changed":false}}]","encoding":"UTF-8"}]}
\ No newline at end of file
......@@ -46,8 +46,6 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import nl.uva.sne.drip.api.dao.DeployDao;
import nl.uva.sne.drip.api.dao.KeyDao;
import nl.uva.sne.drip.commons.utils.Converter;
import nl.uva.sne.drip.commons.v1.types.PlaybookRepresentation;
/**
*
......
......@@ -45,12 +45,21 @@ def install_prerequisites(vm):
print "Installing ansible prerequisites in: %s" % (vm.ip)
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
#print "Username : %s" % (vm.user)
ssh.connect(vm.ip, username=vm.user, key_filename=vm.key)
sftp = ssh.open_sftp()
file_path = os.path.dirname(os.path.abspath(__file__))
sftp.chdir('/tmp/')
install_script = file_path + "/" + "ansible_setup.sh"
sftp.put(install_script, "ansible_setup.sh")
stdin, stdout, stderr = ssh.exec_command("sudo hostname ip-%s" % (vm.ip.replace('.','-')))
sshout = stdout.read()
stdin, stdout, stderr = ssh.exec_command("sudo sh /tmp/ansible_setup.sh")
stdout.read()
parentDir = os.path.dirname(os.path.abspath(vm.key))
os.chmod(parentDir, 770)
print "Ansible prerequisites installed in: %s " % (vm.ip)
except Exception as e:
print '%s: %s' % (vm.ip, e)
......
#! /bin/bash
apt-get update
apt-get upgrade
apt-get -y upgrade
apt-get -y install software-properties-common python openssh-server sudo
service ssh restart
\ No newline at end of file
......@@ -29,10 +29,12 @@ def install_manager(vm):
sftp.chdir('/tmp/')
install_script = file_path + "/" + "docker_kubernetes.sh"
sftp.put(install_script, "kubernetes_setup.sh")
stdin, stdout, stderr = ssh.exec_command("sudo hostname ip-%s" % (vm.ip.replace('.','-')))
stdout.read()
stdin, stdout, stderr = ssh.exec_command("sudo sh /tmp/kubernetes_setup.sh")
stdout.read()
stdin, stdout, stderr = ssh.exec_command("sudo kubeadm init --api-advertise-addresses=%s" % (vm.ip))
retstr = stdout.readlines()
stdin, stdout, stderr = ssh.exec_command("sudo cp /etc/kubernetes/admin.conf /tmp/")
......
{
"host": "172.17.0.2",
"result": {
"_ansible_parsed": false,
"_ansible_no_log": false,
"module_stderr": "Shared connection to 172.17.0.2 closed.\r\n",
"changed": false,
"module_stdout": "/bin/sh: 1: sudo: not found\r\n",
"failed": true,
"invocation": {
"module_name": "setup"
},
"msg": "MODULE FAILURE"
}
}
\ No newline at end of file
-----BEGIN RSA PRIVATE KEY-----
MIIEowI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7KplHd0wj9flGy
gz9XffPHpEVySeniqTnVcaetk9nlkoh6WzQ6D9rvJWgL7RjZmw05WK0m/0V2xOuc
TjR/GnDATjf4pJMoDZc2CK+lEKmgBVU++dKYcVhvRLUP4lGVljkwEy5wugQV92kQ
z104GSK/YbFBQTzpmY/ugQKBgCMIalg6nW8wu6Z0ivo1DJ4tZEkLc4CZEdWZAbV5
dALbRfKctgaDVDs0+WF1mATP/r89EmXEVu8YDVj6yU+gQK3zSwO+OVP7iBFODwJN
4i0DcbROgSoMyLmmmG5oVTe6HRTrRnNE7kOzZL5KJsbrowIoErJO7+749f06DOam
ka+RAoGBAJ5+awU/gJusZW1K+dAVIYtY9lwB/HFlTnsPIpgUPpdywilESlowD7dH
JnthsSbFmzl/KorI8megzelC/HDotig78GViL45s/LxnvuSvVmxBK2nb44KmHTV4
ypE44UC+s5BEe/aTUtke5mmVY5lLR2SoCeUCKA2llKhrskvt+/cZ
-----END RSA PRIVATE KEY-----
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/BqyMFkbyUC87T4Wc1a4C1CPKtYnxfexmKOOtUtYup+CtvHfzftTvwMO4VeykcXj+tQ3nJniCC3/cdKs7NNWEvLQrttABR5kbQlD1rjCRjsLAZ+KuCyRBXIBM41mzl+oFrnjjeoVI4uWWawyOi56zt2XX/10aqxvU2TGd4LYdKno4Nve6uL3+zz5bSvp1pzeQilEQJYgTMZka06YB9ZnDCSRJch2MnaBP564NMAJrVg3lOHIKskfNhG4MQO9OaMppv4ryG/3LOTZ1a8pgxi7RZk4+cN/Z7rGVXJuXa5N4NWVdMiW274OK+jx+vPKEBl0wt7z2Ro8BXaAjgZfsibjR alogo@hermes
......@@ -25,9 +25,10 @@ connection = pika.BlockingConnection(pika.ConnectionParameters(host=rabbitmq_hos
channel = connection.channel()
channel.queue_declare(queue='deployer_queue')
path = os.path.dirname(os.path.abspath(__file__)) + "/"
manager_type = ""
def threaded_function(args):
while True:
#print "processing data events"
......@@ -39,18 +40,23 @@ def handleDelivery(message):
params = parsed_json["parameters"]
node_num = 0
vm_list = []
current_milli_time = lambda: int(round(time.time() * 1000))
path = os.path.dirname(os.path.abspath(__file__)) + "/"+ str(current_milli_time()) + "/"
if not os.path.exists(path):
os.makedirs(path)
for param in params:
name = param["name"]
if name == "cluster":
cluster_type = param["value"]
manager_type = param["value"]
elif name == "credential":
value = param["value"]
print "Value: %s" %value
ip = param["attributes"]["IP"]
user = param["attributes"]["user"]
role = param["attributes"]["role"]
node_num += 1
key = path + "%d.txt" % (node_num)
print
fo = open(key, "w")
fo.write(value)
fo.close()
......@@ -63,10 +69,10 @@ def handleDelivery(message):
fo.write(value)
fo.close()
if cluster_type == "kubernetes":
if manager_type == "kubernetes":
ret = docker_kubernetes.run(vm_list)
return ret
elif cluster_type == "swarm":
elif manager_type == "swarm":
ret = docker_engine.run(vm_list)
if "ERROR" in ret: return ret
ret = docker_swarm.run(vm_list)
......@@ -74,7 +80,7 @@ def handleDelivery(message):
ret1 = control_agent.run(vm_list)
if "ERROR" in ret1: ret = ret1
return ret
elif cluster_type == "ansible":
elif manager_type == "ansible":
ret = ansible_playbook.run(vm_list,playbook)
return ret
else:
......@@ -83,9 +89,10 @@ def handleDelivery(message):
def on_request(ch, method, props, body):
ret = handleDelivery(body)
print ret
if "ERROR" in ret:
res_name = "error"
elif manager_type == "ansible":
res_name = "ansible_output"
else:
res_name = "credential"
......@@ -99,7 +106,9 @@ def on_request(ch, method, props, body):
par["url"] = "null"
par["encoding"] = "UTF-8"
par["name"] = res_name
par["value"] = ret
value = ret.replace("\"", "\\\"")
print value
par["value"] = "\""+ret+"\""
par["attributes"] = "null"
response["parameters"].append(par)
......@@ -116,11 +125,11 @@ channel.basic_qos(prefetch_count=1)
channel.basic_consume(on_request, queue='deployer_queue')
thread = Thread(target = threaded_function, args = (1, ))
thread.start()
#thread = Thread(target = threaded_function, args = (1, ))
#thread.start()
print(" [x] Awaiting RPC requests")
channel.start_consuming()
thread.stop()
\ No newline at end of file
#thread.stop()
\ No newline at end of file
{
"host": "172.17.0.3",
"result": {
"msg": "Failed to connect to the host via ssh: ssh: connect to host 172.17.0.3 port 22: No route to host\r\n",
"unreachable": true,
"changed": false
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment