def subprocess_with_print(cmd, success_msg, failure_msg, log_file, exit_on_fail=False): """ Create a subprocess call and outputs success and errors if any. Args: cmd (string): docker instance name success_msg (string): success message to be displayed in [OK] format. failure_msg (string): failure text to be displayed with [FAILED] format. log_file (string): log file path exit_on_fail (bool): exit program if failed """ cmd = cmd.replace(";", "") cmd = cmd.replace("|", "") cmd = cmd.replace("$", "") cmd = cmd.replace("{", "") cmd = cmd.replace("}", "") try: process = subprocess.Popen(cmd.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE) output_ok(success_msg, message=process.stdout.read(), stderr=process.stderr.read()) except OSError: if exit_on_fail: output_error(failure_msg + "\n Check logs {0} for more details.".format(log_file), error_message=traceback.format_exc()) exit() else: output_warning(failure_msg + "\n Check logs {0} for more details.".format(log_file), error_message=traceback.format_exc())
def start_services(list): #TODO commit docker images along with start scripts for container in list: output_info("Starting {0} container".format(container)) if container == "videoserver": try: subprocess.call( 'docker cp tasks/{0}/install.sh {0}:/etc/'.format( container), shell=True) subprocess.call( 'docker exec {0} /etc/install.sh'.format(container), shell=True) except Exception as e: print(e) else: try: subprocess.call( 'docker cp tasks/{0}/start.sh {0}:/etc/'.format(container), shell=True) subprocess.call( 'docker exec {0} /etc/start.sh'.format(container), shell=True) except Exception as e: print(e) output_ok("Started {0} container".format(container)) print("")
def download_file(url, filename, success_msg, failure_msg, log_file): """ Downloads the file using urllib and prints error and ok message based on the status. Args: url (string): url to download filename (string): filename for the downloaded file success_msg (string): success message to be displayed when download finishes failure_msg (string): failure message to be displayed when download fails log_file (string): log file path """ if os.path.exists(filename): output_ok(success_msg) else: try: urllib.urlretrieve(url, filename) output_ok(success_msg) except Exception: output_error( failure_msg + "\n Check logs {0} for more details.".format( log_file), error_message=traceback.format_exc()) exit()
def docker_setup(log_file, config_path="/etc/ideam/ideam.conf"): config = ConfigParser.ConfigParser() config.readfp(open(config_path)) subprocess_with_print("docker network create --driver bridge mynet", success_msg="Created a docker network named mynet. ", failure_msg="Already a docker network named mynet exists. ", log_file=log_file, exit_on_fail=False) output_info("Using apigateway-data as apigateway's persistent storage.") output_info("Using broker-data as broker's persistent storage.") output_info("Using webserver-data as webserver's persistent storage.") output_info("Using catalogue-data as Catalogue's persistent storage.") subprocess_with_print("docker volume create --name ldapd-data", success_msg="Created ldapd-data data container ", failure_msg="Creation of ldapd-data data container failed.", log_file=log_file, exit_on_fail=True) subprocess_with_print("docker volume create --name apigateway-data", success_msg="Created apigateway-data data container ", failure_msg="Creation of apigateway-data data container failed.", log_file=log_file, exit_on_fail=True) subprocess_with_print("docker volume create --name broker-data", success_msg="Created broker-data data container ", failure_msg="Creation of broker-data data container failed.", log_file=log_file, exit_on_fail=True) subprocess_with_print("docker volume create --name cat-data", success_msg="Created cat-data data container ", failure_msg="Creation of cat-data data container failed.", log_file=log_file, exit_on_fail=True) subprocess_with_print("docker volume create --name elk-data", success_msg="Created elk-data data container ", failure_msg="Creation of elk-data data container failed.", log_file=log_file, exit_on_fail=True) subprocess_with_print("docker volume create --name webserver-data", success_msg="Created webserver-data data container ", failure_msg="Creation of webserver-data data container failed.", log_file=log_file, exit_on_fail=True) ip, details = create_instance("apigateway", "ideam/apigateway", storage_host="apigateway-data", storage_guest="/var/lib/postgresql/", log_file=log_file, config_path=config_path) output_ok("Created apigateway docker instance. \n " + details) ip, details = create_instance("catalogue", "ideam/catalogue", storage_host="cat-data", storage_guest="/data/db", log_file=log_file, config_path=config_path) output_ok("Created Catalogue docker instance. \n " + details) ip, details = create_instance("broker", "ideam/broker", storage_host="broker-data", storage_guest="/var/lib/rabbitmq/", log_file=log_file, config_path=config_path) output_ok("Created Broker docker instance. \n " + details) ip, details = create_instance("elasticsearch", "ideam/elasticsearch", storage_host="elk-data", storage_guest="/home/ideam/elasticsearch-6.2.4", log_file=log_file, config_path=config_path) output_ok("Created Elastic Search docker instance. \n " + details) ip, details = create_instance("webserver", "ideam/webserver", storage_host="webserver-data", storage_guest="/usr/local/webserver/", log_file=log_file, config_path=config_path) output_ok("Created Webserver docker instance. \n " + details) ip, details = create_instance("ldapd", "ideam/ldapd", storage_host="ldapd-data", storage_guest="/var/db", log_file=log_file, config_path=config_path) output_ok("Created LDAP docker instance. \n " + details) ip, details = create_instance("videoserver", "ideam/videoserver", log_file=log_file, config_path=config_path) output_ok("Created Videoserver docker instance. \n " + details) konga = config.get('KONGA', 'HTTP') cmd = 'docker run -d -e "DB_HOST=apigateway" -p 127.0.0.1:{0}:1337 --net mynet --link apigateway:kong --name konga -e "NODE_ENV=production" pantsel/konga'.\ format(konga) subprocess_with_print(cmd, success_msg="Created KONGA docker instance. ", failure_msg="Creation of KONGA docker instance failed.", log_file=log_file, exit_on_fail=True) for container in ["apigateway","broker","ldapd","catalogue","videoserver","webserver","elasticsearch"]: print("") #Just to separate out the individual installations output_info("Starting {0} installation".format(container)) subprocess.call('tasks/{0}/setup.sh'.format(container), shell=True) output_ok("Installed {0}".format(container))
def limit_install(list): for container in list: output_info("Starting {0} installation".format(container)) subprocess.call('tasks/{0}/setup.sh'.format(container),shell=True) output_ok("Installed {0}".format(container))
def docker_setup(log_file, config_path="/etc/ideam/ideam.conf"): """ Creates docker instances for kong, ca, hypercat, rabbitmq, elastic search, apache storm, ldap, ntp and bind server from an ubuntu-ssh image. First, docker creates certificate authority (CA) instance and then have the CA certify Ansible user's public key. A new docker image with this CA's public key in TrustedUserCAKeys is created to avoid redundant sending of Ansible's public keys to all hosts. Important: This docker setup will remove all the current containers and there will be loss of data. This should be used only for fresh installation. """ instance_details = {} config = ConfigParser.ConfigParser() config.readfp(open(config_path)) subprocess_with_print( "docker network create --driver bridge mynet", success_msg="Created a docker network named mynet. ", failure_msg="Already a docker network named mynet exists. ", log_file=log_file, exit_on_fail=False) kong_storage = config.get('KONG', 'DATA_STORAGE') kong_log_location = config.get('KONG', 'LOG_LOCATION') output_info( "Using {0} as Kong's persistant storage. ".format(kong_storage)) kong_config_storage = config.get('KONG', 'CONFIG_STORAGE') output_info("Using {0} as Kong's config persistant storage. ".format( kong_config_storage)) rabbitmq_storage = config.get('RABBITMQ', 'DATA_STORAGE') output_info("Using {0} as RabbitMQ's persistant storage. ".format( rabbitmq_storage)) tomcat_storage = config.get('TOMCAT', 'DATA_STORAGE') output_info("Using {0} as Apache Tomcat's persistant storage. ".format( tomcat_storage)) catalogue_storage = config.get('CATALOGUE', 'DATA_STORAGE') output_info("Using {0} as Catalogue's persistant storage. ".format( catalogue_storage)) subprocess_with_print( "docker volume create --name ldapd-data", success_msg="Created ldapd-data data container ", failure_msg="Creation of ldapd-data data container failed.", log_file=log_file, exit_on_fail=True) key = config.get('SYSTEM_CONFIG', 'SSH_PUBLIC_KEY') output_info("Using {0} as your ssh key for certification. ".format(key)) home = os.path.expanduser('~') with open(home + "/.ssh/configs", 'w+') as f: f.write("IdentityFile {0}\n".format(key)) key = key.replace("~", home) subprocess_popen( "find " + key, log_file, "Missing ssh public key file in {}. Create one using command ssh-keygen." .format(key)) cmd = 'cp -r ' + key + ' ' + os.getcwd( ) + '/config/certificate_authority/keys/id_rsa.pub' subprocess_popen(cmd, log_file, "Copying to /config/certificate_authority/keys/ failed.") subprocess_with_print( "docker build -t ansible/ubuntu-ssh --no-cache -f images/Dockerfile.ubuntu ." .format(unique_value()), success_msg="Created ansible/ubuntu-ssh docker image. ", failure_msg= "Building ubuntu image from images/Dockerfile.ubuntu failed.", log_file=log_file, exit_on_fail=True) ca_ip, ca_port, details = create_instance("certificate_authority", "ansible/ubuntu-ssh", log_file, config_path=config_path) output_ok("Created Certificate Authority docker instance. \n " + details) instance_details["certificate_authority"] = [ca_ip, ca_port] create_ansible_host_file(instance_details) output_ok("Created Ansible hosts file with CA instance. ") output_info("Starting Ansible Certificate Authority Setup. ") subprocess.call( 'ansible-playbook -i hosts install.yaml --limit "certificate_authority"', shell=True) cmd = "cp config/certificate_authority/keys/id_rsa-cert.pub " + "~/.ssh/".replace( "~", home) subprocess_popen( cmd, log_file, "Copying Certificate Authority's cert file to ansible's .ssh/ failed.") output_ok("Copied Certificate Authority's cert file to Ansible's .ssh. ") cmd = "docker build -t ansible/ubuntu-certified-aptrepo:1.0 --build-arg CACHEBUST={0} " \ "-f images/Dockerfile.ubuntu.certified.aptrepo.readytoserve .".format(unique_value()) subprocess_with_print( cmd, success_msg= "Created ansible/ubuntu-certified-aptrepo:1.0 docker image. ", failure_msg="Building ubuntu image from " "images/Dockerfile.ubuntu.certified.aptrepo.readytoserve failed.", log_file=log_file, exit_on_fail=True) cmd = "docker build -t ansible/ubuntu-certified-catalogue:1.0 --build-arg CACHEBUST={0} " \ "-f images/Dockerfile.ubuntu.certified.catalogue .".format(unique_value()) subprocess_with_print( cmd, success_msg= "Created ansible/ubuntu-certified-catalogue:1.0 docker image. ", failure_msg= "Building ubuntu image from images/Dockerfile.ubuntu.certified.catalogue failed.", log_file=log_file, exit_on_fail=True) cmd = "docker build -t ansible/ubuntu-certified-kong:1.0 --build-arg CACHEBUST={0} " \ "-f images/Dockerfile.ubuntu.certified.kong .".format(unique_value()) subprocess_with_print( cmd, success_msg="Created ansible/ubuntu-certified-kong:1.0 docker image. ", failure_msg= "Building ubuntu image from images/Dockerfile.ubuntu.certified.kong failed.", log_file=log_file, exit_on_fail=True) cmd = "docker build -t ansible/ubuntu-certified-rabbitmq:1.0 --build-arg CACHEBUST={0} " \ "-f images/Dockerfile.ubuntu.certified.rabbitmq .".format(unique_value()) subprocess_with_print( cmd, success_msg= "Created ansible/ubuntu-certified-rabbitmq:1.0 docker image. ", failure_msg= "Building ubuntu image from images/Dockerfile.ubuntu.certified.rabbitmq failed.", log_file=log_file, exit_on_fail=True) failure_msg = "Building ansible/pushpin image from images/Dockerfile.ubuntu.certified.pushpin failed." subprocess_with_print( "docker build --no-cache -t ansible/pushpin -f images/Dockerfile.ubuntu.certified.pushpin .", success_msg="Created ansible/pushpin docker image. ", failure_msg=failure_msg, log_file=log_file, exit_on_fail=True) subprocess_with_print( "docker build -t ansible/tomcat --build-arg CACHEBUST={0} " "-f images/Dockerfile.tomcat .".format(unique_value()), success_msg="Created ansible/tomcat docker image. ", failure_msg= "Building ansible/tomcat image from images/Dockerfile.tomcat failed.", log_file=log_file, exit_on_fail=True) cmd = "docker build -t ansible/ubuntu-certified-elk:1.0 -f images/Dockerfile.ubuntu.certified.elk ." subprocess_with_print( cmd, success_msg="Created ansible/ubuntu-certified-elk:1.0 docker image. ", failure_msg= "Building ubuntu image from images/Dockerfile.ubuntu.certified.elk failed.", log_file=log_file, exit_on_fail=True) cmd = "docker build -t ansible/ubuntu-certified-ldapd:1.0 -f images/Dockerfile.ubuntu.certified.ldapd ." subprocess_with_print( cmd, success_msg="Created ansible/ubuntu-certified-ldapd:1.0 docker image. ", failure_msg= "Building ubuntu image from images/Dockerfile.ubuntu.certified.ldapd failed.", log_file=log_file, exit_on_fail=True) cmd = "docker build -t ansible/video-server:1.0 --build-arg CACHEBUST={0} " \ "-f images/Dockerfile.videoserver .".format(unique_value()) subprocess_with_print( cmd, success_msg="Created ansible/video-server:1.0 docker image. ", failure_msg="Building ubuntu image from " "images/Dockerfile.videoserver failed.", log_file=log_file, exit_on_fail=True) ip, port, details = create_instance("apt_repo", "ansible/ubuntu-certified-aptrepo:1.0", log_file, config_path=config_path) instance_details["apt_repo"] = [ip, port] output_ok("Created Apt Local Repository docker instance. \n " + details) ip, port, details = create_instance("kong", "ansible/ubuntu-certified-kong:1.0", storage_host=kong_storage, storage_guest="/var/lib/postgresql", log_file=log_file, config_path=config_path, log_storage=kong_log_location) instance_details["kong"] = [ip, port] output_ok("Created Kong docker instance. \n " + details) ip, port, details = create_instance( "hypercat", "ansible/ubuntu-certified-catalogue:1.0", storage_host=catalogue_storage, storage_guest="/data/db", log_file=log_file, config_path=config_path) instance_details["hypercat"] = [ip, port] output_ok("Created Catalogue docker instance. \n " + details) ip, port, details = create_instance( "rabbitmq", "ansible/ubuntu-certified-rabbitmq:1.0", storage_host=rabbitmq_storage, storage_guest="/var/lib/rabbitmq", log_file=log_file, config_path=config_path) instance_details["rabbitmq"] = [ip, port] output_ok("Created RabbitMQ docker instance. \n " + details) ip, port, details = create_instance("elasticsearch", "ansible/ubuntu-certified-elk:1.0", log_file=log_file, config_path=config_path) instance_details["elasticsearch"] = [ip, port] output_ok("Created Elastic Search docker instance. \n " + details) ip, port, details = create_instance("tomcat", "ansible/tomcat", storage_host=tomcat_storage, storage_guest="/opt/tomcat/webapps", log_file=log_file, config_path=config_path) instance_details["tomcat"] = [ip, port] output_ok("Created Tomcat docker instance. \n " + details) ip, port, details = create_instance("ldapd", "ansible/ubuntu-certified-ldapd:1.0", storage_host="ldapd-data", storage_guest="/var/db", log_file=log_file, config_path=config_path) instance_details["ldapd"] = [ip, port] output_ok("Created LDAP docker instance. \n " + details) ip, port, details = create_instance("pushpin", "ansible/pushpin", log_file=log_file, config_path=config_path) instance_details["pushpin"] = [ip, port] output_ok("Created Pushpin docker instance. \n " + details) ip, port, details = create_instance("videoserver", "ansible/video-server:1.0", log_file=log_file, config_path=config_path) instance_details["videoserver"] = [ip, port] output_ok("Created Videoserver docker instance. \n " + details) cmd = "cp config/tomcat/RegisterAPI.war " + tomcat_storage + "/RegisterAPI.war" subprocess_popen( cmd, log_file, "Copying RegisterAPI.war file to {0} failed.".format(tomcat_storage)) output_ok("Copied RegisterAPI.war file to {0}. ".format(tomcat_storage)) konga = config.get('KONGA', 'HTTP') cmd = 'docker run -d -p {0}:1337 --net mynet --link kong:kong --name konga -e "NODE_ENV=production" pantsel/konga'.\ format(konga) subprocess_with_print( cmd, success_msg="Created KONGA docker instance. ", failure_msg="Creation of KONGA docker instance failed.", log_file=log_file, exit_on_fail=True) create_ansible_host_file(instance_details)
def limit_install(limit): if "kong" in limit: output_info("Starting Kong quick install") subprocess.call('tasks/kong/quick-kong.sh ' + str( subprocess.check_output("docker port kong | grep 22 | cut -d : -f 2", shell=True)).strip(), shell=True) output_ok("Installed Kong") if "rabbitmq" in limit: output_info("Starting RabbitMQ quick install") subprocess.call('tasks/rabbitmq/quick-rmq.sh ' + str( subprocess.check_output("docker port rabbitmq | grep 22 | cut -d : -f 2", shell=True)).strip(), shell=True) output_ok("Installed RabbitMQ") if "catalogue" in limit: output_info("Starting Catalogue quick install") subprocess.call('tasks/catalogue/quick-catalogue.sh ' + str( subprocess.check_output("docker port catalogue | grep 22 | cut -d : -f 2", shell=True)).strip(), shell=True) output_ok("Installed Catalogue") if "tomcat" in limit: output_info("Starting Tomcat quick install") subprocess.call('tasks/tomcat/quick-tomcat.sh ' + str( subprocess.check_output("docker port tomcat | grep 22 | cut -d : -f 2", shell=True)).strip(), shell=True) output_ok("Installed Tomcat") if "elasticsearch" in limit: output_info("Starting Elasticsearch quick install") subprocess.call('tasks/elasticsearch/quick-elk.sh ' + str( subprocess.check_output("docker port elasticsearch | grep 22 | cut -d : -f 2", shell=True)).strip(), shell=True) output_ok("Installed Elasticsearch") if "ldapd" in limit: output_info("Starting LDAPD quick install") subprocess.call('tasks/ldapd/quick-ldapd.sh ' + str( subprocess.check_output("docker port ldapd | grep 22 | cut -d : -f 2", shell=True)).strip(), shell=True) output_ok("Installed LDAPD") if "videoserver" in limit: output_info("Starting Videoserver quick install") subprocess.call('tasks/videoserver/quick-vs.sh ' + str( subprocess.check_output("docker port videoserver | grep 22 | cut -d : -f 2", shell=True)).strip(), shell=True) output_ok("Installed Videoserver")
def docker_setup(log_file, config_path="/etc/ideam/ideam.conf"): """ Creates docker instances for kong, ca, catalogue, rabbitmq, elastic search, apache storm, ldap, ntp and bind server from an ubuntu-ssh image. First, docker creates certificate authority (CA) instance and then have the CA certify Ansible user's public key. A new docker image with this CA's public key in TrustedUserCAKeys is created to avoid redundant sending of Ansible's public keys to all hosts. Important: This docker setup will remove all the current containers and there will be loss of data. This should be used only for fresh installation. """ instance_details = {} config = ConfigParser.ConfigParser() config.readfp(open(config_path)) subprocess_with_print("docker network create --driver bridge mynet", success_msg="Created a docker network named mynet. ", failure_msg="Already a docker network named mynet exists. ", log_file=log_file, exit_on_fail=False) kong_storage = config.get('KONG', 'DATA_STORAGE') kong_log_location = config.get('KONG', 'LOG_LOCATION') output_info("Using {0} as Kong's persistant storage. ".format(kong_storage)) kong_config_storage = config.get('KONG', 'CONFIG_STORAGE') output_info("Using {0} as Kong's config persistant storage. ".format(kong_config_storage)) rabbitmq_storage = config.get('RABBITMQ', 'DATA_STORAGE') output_info("Using {0} as RabbitMQ's persistant storage. ".format(rabbitmq_storage)) tomcat_storage = config.get('TOMCAT', 'DATA_STORAGE') output_info("Using {0} as Apache Tomcat's persistant storage. ".format(tomcat_storage)) catalogue_storage = config.get('CATALOGUE', 'DATA_STORAGE') output_info("Using {0} as Catalogue's persistant storage. ".format(catalogue_storage)) subprocess_with_print("docker volume create --name ldapd-data", success_msg="Created ldapd-data data container ", failure_msg="Creation of ldapd-data data container failed.", log_file=log_file, exit_on_fail=True) key = config.get('SYSTEM_CONFIG', 'SSH_PUBLIC_KEY') output_info("Using {0} as your ssh key for certification. ".format(key)) home = os.path.expanduser('~') with open(home + "/.ssh/configs", 'w+') as f: f.write("IdentityFile {0}\n".format(key)) key = key.replace("~", home) subprocess_popen("find "+key, log_file, "Missing ssh public key file in {}. Create one using command ssh-keygen.". format(key)) cmd = 'cp -r ' + key + ' ' + os.getcwd() + '/config/certificate_authority/keys/id_rsa.pub' subprocess_popen(cmd, log_file, "Copying to /config/certificate_authority/keys/ failed.") # subprocess_with_print("docker build -t ideam/alpine-ssh -f images/alpine/Dockerfile.alpine-ssh .". # format(unique_value()), # success_msg="Created ideam/alpine-ssh docker image. ", # failure_msg="Building alpine image from images/alpine/Dockerfile.alpine-ssh failed.", # log_file=log_file, # exit_on_fail=True) # # ca_ip, ca_port, details = create_instance("certificate_authority", "ideam/alpine-ssh", log_file, config_path=config_path) # output_ok("Created Certificate Authority docker instance. \n " + details) # # instance_details["certificate_authority"] = [ca_ip, ca_port] # create_ansible_host_file(instance_details) # output_ok("Created Ansible hosts file with CA instance. ") # # output_info("Starting Ansible Certificate Authority Setup. ") # subprocess.call('tasks/certificate_authority/ca.sh '+str(subprocess.check_output("docker port certificate_authority | grep 22 | cut -d : -f 2",shell=True)).strip(), # shell=True) # # cmd = "cp config/certificate_authority/keys/id_rsa-cert.pub " + "~/.ssh/".replace("~", home) # subprocess_popen(cmd, log_file, "Copying Certificate Authority's cert file to ansible's .ssh/ failed.") # output_ok("Copied Certificate Authority's cert file to Ansible's .ssh. ") #TODO change data folder of postgres ip, port, details = create_instance("kong", "ideam/kong", storage_host=kong_storage, storage_guest="/var/lib/postgresql", log_file=log_file, config_path=config_path, log_storage=kong_log_location) instance_details["kong"] = [ip, port] output_ok("Created Kong docker instance. \n " + details) ip, port, details = create_instance("catalogue", "ideam/catalogue", storage_host=catalogue_storage, storage_guest="/data/db", log_file=log_file, config_path=config_path) instance_details["catalogue"] = [ip, port] output_ok("Created Catalogue docker instance. \n " + details) ip, port, details = create_instance("rabbitmq", "ideam/rabbitmq", storage_host=rabbitmq_storage, storage_guest="/var/lib/rabbitmq", log_file=log_file, config_path=config_path) instance_details["rabbitmq"] = [ip, port] output_ok("Created RabbitMQ docker instance. \n " + details) ip, port, details = create_instance("elasticsearch", "ideam/elasticsearch-nokibana", log_file=log_file, config_path=config_path) instance_details["elasticsearch"] = [ip, port] output_ok("Created Elastic Search docker instance. \n " + details) ip, port, details = create_instance("tomcat", "ideam/tomcat", storage_host=tomcat_storage, storage_guest="/usr/local/tomcat/webapps", log_file=log_file, config_path=config_path) instance_details["tomcat"] = [ip, port] output_ok("Created Tomcat docker instance. \n " + details) ip, port, details = create_instance("ldapd", "ideam/ldapd", storage_host="ldapd-data", storage_guest="/var/db", log_file=log_file, config_path=config_path) instance_details["ldapd"] = [ip, port] output_ok("Created LDAP docker instance. \n " + details) ip, port, details = create_instance("videoserver", "ideam/videoserver", log_file=log_file, config_path=config_path) instance_details["videoserver"] = [ip, port] output_ok("Created Videoserver docker instance. \n " + details) konga = config.get('KONGA', 'HTTP') cmd = 'docker run -d -p {0}:1337 --net mynet --link kong:kong --name konga -e "NODE_ENV=production" pantsel/konga'.\ format(konga) subprocess_with_print(cmd, success_msg="Created KONGA docker instance. ", failure_msg="Creation of KONGA docker instance failed.", log_file=log_file, exit_on_fail=True) # create_ansible_host_file(instance_details) print("") #Just to separate out the individual installations output_info("Starting Kong quick install") subprocess.call('tasks/kong/quick-kong.sh', shell=True) output_ok("Installed Kong") print("") output_info("Starting RabbitMQ quick install") subprocess.call('tasks/rabbitmq/quick-rmq.sh ', shell=True) output_ok("Installed RabbitMQ") print("") output_info("Starting Catalogue quick install") subprocess.call('tasks/catalogue/quick-catalogue.sh ', shell=True) output_ok("Installed Catalogue") print("") output_info("Starting Tomcat quick install") subprocess.call('tasks/tomcat/quick-tomcat.sh ', shell=True) output_ok("Installed Tomcat") print("") output_info("Starting Elasticsearch quick install") subprocess.call('tasks/elasticsearch/quick-elk.sh ', shell=True) output_ok("Installed Elasticsearch") print("") output_info("Starting LDAPD quick install") subprocess.call('tasks/ldapd/quick-ldapd.sh ', shell=True) output_ok("Installed LDAPD") print("") output_info("Starting Videoserver quick install") subprocess.call('tasks/videoserver/quick-vs.sh ', shell=True) output_ok("Installed Videoserver")
def start_services(limit): #TODO commit docker images along with start scripts if "kong" in limit: print("") # Just to separate out the individual start scripts output_info("Starting Kong container") try: subprocess.call('docker cp tasks/kong/quick_start_kong.sh kong:/etc/', shell=True) subprocess.call('docker exec kong /etc/quick_start_kong.sh', shell=True) except Exception as e: print(e) output_ok("Started Kong container") if "rabbitmq" in limit: print("") output_info("Starting RabbitMQ container") try: subprocess.call('docker cp tasks/rabbitmq/quick_start_rmq.sh rabbitmq:/etc/', shell=True) subprocess.call('docker exec rabbitmq /etc/quick_start_rmq.sh', shell=True) except Exception as e: print(e) output_ok("Started RabbitMQ container") if "catalogue" in limit: print("") output_info("Starting Catalogue container") try: subprocess.call('docker cp tasks/catalogue/quick_start_catalogue.sh catalogue:/etc/', shell=True) subprocess.call('docker exec catalogue /etc/quick_start_catalogue.sh', shell=True) except Exception as e: print(e) output_ok("Started Catalogue container") if "tomcat" in limit: print("") output_info("Starting Tomcat container") try: subprocess.call('docker cp tasks/tomcat/quick_start_tomcat.sh tomcat:/etc/', shell=True) subprocess.call('docker exec tomcat /etc/quick_start_tomcat.sh', shell=True) except Exception as e: print(e) output_ok("Started Tomcat container") if "elasticsearch" in limit: print("") output_info("Starting Elasticsearch container") try: subprocess.call('docker cp tasks/elasticsearch/quick_start_elk.sh elasticsearch:/etc/', shell=True) subprocess.call('docker exec elasticsearch /etc/quick_start_elk.sh', shell=True) except Exception as e: print(e) output_ok("Started Elasticsearch container") if "ldapd" in limit: print("") output_info("Starting LDAPD container") try: subprocess.call('docker cp tasks/ldapd/quick_start_ldapd.sh ldapd:/etc/', shell=True) subprocess.call('docker exec ldapd /etc/quick_start_ldapd.sh', shell=True) except Exception as e: print(e) output_ok("Started LDAPD container") if "videoserver" in limit: print("") output_info("Starting Videoserver container") try: subprocess.call('docker exec videoserver /etc/quick-vs-setup.sh', shell=True) except Exception as e: print(e) output_ok("Started Videoserver container")