Commit 02ad2930 authored by Spiros Koulouzis's avatar Spiros Koulouzis

added ansible tower client

parent 48d2188c
......@@ -82,6 +82,7 @@ def handle_delivery(message):
vms = tosca.get_vms(tosca_template_dict)
inventory_path = ansible_service.write_inventory_file(tmp_path, vms)
paths = ansible_service.write_playbooks_from_tosca_interface(tosca_interfaces, tmp_path)
tokens = {}
for playbook_path in paths:
out, err = ansible_service.run(inventory_path, playbook_path)
......
pika==1.1.0
names==0.3.0
networkx==2.4
requests==2.22.0
wheel==0.34.1
requests==2.23.0
wheel==0.34.2
pyyaml==5.3
tosca-parser ==1.7.0
matplotlib==3.1.2
matplotlib==3.2.0
ansible==2.9.6
`ansible-tower-cli==3.3.8
ansible-tower-cli==3.3.8
......@@ -8,20 +8,24 @@ import time
import unittest
from service import k8s_service, tosca, ansible_service
from tower_cli import get_resource
from tower_cli.exceptions import Found
from tower_cli.conf import settings
class TestDeployer(unittest.TestCase):
# def test_parse_token(self):
# tosca_path = "../../ansible_playbooks/"
# example_ansible_output_file_path = tosca_path + '/example_ansible_output.out'
# if not os.path.exists(example_ansible_output_file_path):
# tosca_path = "../ansible_playbooks/"
# example_ansible_output_file_path = tosca_path + '/example_ansible_output.out'
#
# with open(example_ansible_output_file_path, 'r') as file:
# out = file.read()
# token = ansible_service.parse_dashboard_tokens(out)
def test_parse_token(self):
tosca_path = "../../ansible_playbooks/"
example_ansible_output_file_path = tosca_path + '/example_ansible_output.out'
if not os.path.exists(example_ansible_output_file_path):
tosca_path = "../ansible_playbooks/"
example_ansible_output_file_path = tosca_path + '/example_ansible_output.out'
with open(example_ansible_output_file_path, 'r') as file:
out = file.read()
token = ansible_service.parse_dashboard_tokens(out)
def test(self):
logger = logging.getLogger(__name__)
......@@ -36,6 +40,16 @@ class TestDeployer(unittest.TestCase):
print(parsed_json_message)
# settings.runtime_values()
# with settings.runtime_values(host='localhost',username='admin', password='password'):
# try:
# res = get_resource('organization')
# new_org = res.create(name='foo', description='bar', fail_on_found=True)
# except Found:
# print('This organization already exists.')
# assert isinstance(new_org, dict)
# print(new_org['id'])
if __name__ == '__main__':
import unittest
......
version: '3'
services:
postgres:
image: "postgres:9.6"
environment:
POSTGRES_USER: awx
POSTGRES_PASSWORD: awxpass
POSTGRES_DB: awx
#postgres:
#image: "postgres:12.2"
#environment:
#POSTGRES_USER: awx
#POSTGRES_PASSWORD: awxpass
#POSTGRES_DB: awx
#POSTGRES_HOST_AUTH_METHOD: trust
#ports:
#- "5432:5432"
#volumes:
#- db-data:/var/lib/postgresql/data
rabbit:
image: rabbitmq:3.8-management
......@@ -13,70 +18,72 @@ services:
- "5671-5672:5671-5672"
- "15672:15672"
- "4369:4369"
- "15671:15671"
environment:
RABBITMQ_DEFAULT_VHOST: awx
- "15671:15671"
#environment:
#RABBITMQ_DEFAULT_VHOST: awx
memcached:
image: "memcached:alpine"
#memcached:
#image: "memcached:alpine"
awx_web:
image: "geerlingguy/awx_web:latest"
#image: "ansible/awx_web:latest"
depends_on:
- rabbit
- memcached
- postgres
ports:
- "8052:8052"
#volumes:
#- /tmp/SECRET_KEY:/etc/tower/SECRET_KEY #echo aabbcc > /tmp/SECRET_KEY
user: root
environment:
SECRET_KEY: aabbcc
DATABASE_USER: awx
DATABASE_PASSWORD: awxpass
DATABASE_NAME: awx
DATABASE_PORT: 5432
DATABASE_HOST: postgres
RABBITMQ_USER: guest
RABBITMQ_PASSWORD: guest
RABBITMQ_HOST: rabbit
RABBITMQ_PORT: 5672
RABBITMQ_VHOST: awx
MEMCACHED_HOST: memcached
MEMCACHED_PORT: 11211
#awx_web:
#image: "geerlingguy/awx_web:latest"
##image: "ansible/awx_web:latest"
#depends_on:
#- rabbit
#- memcached
#- postgres
#ports:
#- "8051-8052:8051-8052"
##volumes:
##- /tmp/SECRET_KEY:/etc/tower/SECRET_KEY #echo aabbcc > /tmp/SECRET_KEY
#user: root
#environment:
#SECRET_KEY: aabbcc
#DATABASE_USER: awx
#DATABASE_PASSWORD: awxpass
#DATABASE_NAME: awx
#DATABASE_PORT: 5432
#DATABASE_HOST: postgres
#RABBITMQ_USER: guest
#RABBITMQ_PASSWORD: guest
#RABBITMQ_HOST: rabbit
#RABBITMQ_PORT: 5672
#RABBITMQ_VHOST: awx
#MEMCACHED_HOST: memcached
#MEMCACHED_PORT: 11211
awx_task:
image: "geerlingguy/awx_task:latest"
#image: "ansible/awx_task:latest"
depends_on:
- rabbit
- memcached
- awx_web
- postgres
#awx_task:
#image: "geerlingguy/awx_task:latest"
##image: "ansible/awx_task:latest"
##volumes:
##- /tmp/SECRET_KEY:/etc/tower/SECRET_KEY #echo aabbcc > /tmp/SECRET_KEY
#depends_on:
#- rabbit
#- memcached
#- awx_web
#- postgres
#hostname: awx
user: root
environment:
SECRET_KEY: aabbcc
DATABASE_USER: awx
DATABASE_PASSWORD: awxpass
DATABASE_NAME: awx
DATABASE_PORT: 5432
DATABASE_HOST: postgres
RABBITMQ_USER: guest
RABBITMQ_PASSWORD: guest
RABBITMQ_HOST: rabbit
RABBITMQ_PORT: 5672
RABBITMQ_VHOST: awx
MEMCACHED_HOST: memcached
MEMCACHED_PORT: 11211
#user: root
#environment:
#SECRET_KEY: aabbcc
#DATABASE_USER: awx
#DATABASE_PASSWORD: awxpass
#DATABASE_NAME: awx
#DATABASE_PORT: 5432
#DATABASE_HOST: postgres
#RABBITMQ_USER: guest
#RABBITMQ_PASSWORD: guest
#RABBITMQ_HOST: rabbit
#RABBITMQ_PORT: 5672
#RABBITMQ_VHOST: awx
#MEMCACHED_HOST: memcached
#MEMCACHED_PORT: 11211
#mongo:
#image: mongo:4
#ports:
#- "27017:27017"
mongo:
image: mongo:4
ports:
- "27017:27017"
#jupyter:
#ports:
......@@ -97,24 +104,28 @@ services:
#ports:
#- "30000:8080"
#sure-tosca:
#image: alogo53/sure-tosca:3.0.0
#ports:
#- "8081:8081"
sure-tosca:
image: alogo53/sure-tosca:3.0.0
ports:
- "8081:8081"
#planner:
#depends_on:
#- rabbit
#- sure-tosca
#image: alogo53/planner:3.0.0
#environment:
#RABBITMQ_HOST: rabbit
planner:
depends_on:
- rabbit
- sure-tosca
image: alogo53/planner:3.0.0
environment:
RABBITMQ_HOST: rabbit
#provisioner:
#depends_on:
#- rabbit
#- sure-tosca
#image: alogo53/provisioner:3.0.0
#environment:
#RABBITMQ_HOST: rabbit
#SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
provisioner:
depends_on:
- rabbit
- sure-tosca
image: alogo53/provisioner:3.0.0
environment:
RABBITMQ_HOST: rabbit
SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
#volumes:
#db-data:
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