Commit ac710981 authored by Spiros Koulouzis's avatar Spiros Koulouzis

added task to get key

parent 6172a79f
This diff is collapsed.
......@@ -76,3 +76,17 @@
- name: print nodes
debug:
var: nodes_out
- name: get api key
shell: kubectl describe secret $(kubectl get secrets | grep default | cut -f1 -d ' ') | grep -E '^token' | cut -f2 -d':' | tr -d '\t'
register: api_key
- name: print api_key
debug:
var: api_key
......@@ -65,6 +65,7 @@ def write_ansible_files(vms, interfaces, tmp_path):
print('ansible_ssh_user=' + ansible_ssh_user, file=k8s_hosts_file)
image_url = interfaces['Kubernetes']['install']['inputs']['playbook']
r = requests.get(image_url)
with open(tmp_path + "/install.yml", 'wb') as f:
f.write(r.content)
......@@ -90,11 +91,13 @@ def run(interfaces, vms):
p = Popen(["ansible-playbook", "-i", tmp_path + "/k8s_hosts", tmp_path + "/create.yml"], stdin=PIPE, stdout=PIPE,
stderr=PIPE)
output, err = p.communicate()
print(output.decode('utf-8'))
print(err.decode('utf-8'))
out = output.decode('utf-8')
err = err.decode('utf-8')
print(out)
print(err)
rc = p.returncode
return tmp_path
api_key = out
return api_key
def execute_playbook(hosts, playbook_path, user, ssh_key_file, extra_vars, passwords):
......
def get_dockers(tosca_template_json):
pass
dockers = []
node_templates = tosca_template_json['topology_template']['node_templates']
for node_name in node_templates:
if node_templates[node_name]['type'] == 'tosca.nodes.ARTICONF.Container.Application.Docker':
dockers.append(node_templates[node_name])
return dockers
def write_k8s_files(dockers):
pass
def run(tosca_template_json):
dockers = get_dockers(tosca_template_json)
tmp_dir = write_k8s_files(dockers)
return None
\ No newline at end of file
return tmp_dir
\ 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