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 @@ ...@@ -76,3 +76,17 @@
- name: print nodes - name: print nodes
debug: debug:
var: nodes_out 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): ...@@ -65,6 +65,7 @@ def write_ansible_files(vms, interfaces, tmp_path):
print('ansible_ssh_user=' + ansible_ssh_user, file=k8s_hosts_file) print('ansible_ssh_user=' + ansible_ssh_user, file=k8s_hosts_file)
image_url = interfaces['Kubernetes']['install']['inputs']['playbook'] image_url = interfaces['Kubernetes']['install']['inputs']['playbook']
r = requests.get(image_url) r = requests.get(image_url)
with open(tmp_path + "/install.yml", 'wb') as f: with open(tmp_path + "/install.yml", 'wb') as f:
f.write(r.content) f.write(r.content)
...@@ -90,11 +91,13 @@ def run(interfaces, vms): ...@@ -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, p = Popen(["ansible-playbook", "-i", tmp_path + "/k8s_hosts", tmp_path + "/create.yml"], stdin=PIPE, stdout=PIPE,
stderr=PIPE) stderr=PIPE)
output, err = p.communicate() output, err = p.communicate()
print(output.decode('utf-8')) out = output.decode('utf-8')
print(err.decode('utf-8')) err = err.decode('utf-8')
print(out)
print(err)
rc = p.returncode rc = p.returncode
api_key = out
return tmp_path return api_key
def execute_playbook(hosts, playbook_path, user, ssh_key_file, extra_vars, passwords): def execute_playbook(hosts, playbook_path, user, ssh_key_file, extra_vars, passwords):
......
def get_dockers(tosca_template_json): 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): def write_k8s_files(dockers):
pass pass
def run(tosca_template_json): def run(tosca_template_json):
dockers = get_dockers(tosca_template_json) dockers = get_dockers(tosca_template_json)
tmp_dir = write_k8s_files(dockers) tmp_dir = write_k8s_files(dockers)
return None return tmp_dir
\ No newline at end of file \ 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