Esempio n. 1
0
    def install(self, from_source=True):
        """
        Install openresty.

        :param from_source:
            When true install openresty from source code.
            When false install openresty from yum repository.
        :return:
        """

        # Full path of python file locates in
        var_full_path = os.path.dirname(os.path.realpath(__file__))

        if from_source:
            var_compile = raw_input("Compile Openresty? [y/n]: ")
            var_install = raw_input("Install Openresty? [y/n]: ")
            if var_compile.lower() == "y":
                # Compile openresty on compile machine
                logging.info("########################### Compile openresty ##############################")
                var_command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook " + var_full_path + "/role_openresty_compile.yml"
                var_command = var_command + " --user root"
                var_command = var_command + " --ask-pass"
                cli_common.execute_command(var_command)

            if var_install.lower() == "y":
                # Deploy openresty to target machine
                logging.info("########################### Deploy openresty ##############################")
                var_command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook " + var_full_path + "/role_openresty_install.yml"
                var_command = var_command + " --user root"
                var_command = var_command + " --ask-pass"
                cli_common.execute_command(var_command)
        else:
            # TODO: Install openresty from yum repository
            raise Exception, "Install openresty from yum repository not implement yet."
Esempio n. 2
0
    def install(self):
        """
        Install grafana.

        :return:
        """

        # Full path of python file locates in
        var_full_path = os.path.dirname(os.path.realpath(__file__))

        var_install = raw_input("Install grafana? [y/n]: ")
        if var_install.lower() == "y":
            var_host_prometheus = raw_input("Enter target machine of deploying grafana (example: 192.168.1.20:8080): ")
            var_host_prometheus_user = raw_input("Enter target machine user (default root): ") or "root"
            # var_grafana_admin = raw_input("Enter grafana admin user or left it empty without changing: ")
            # var_grafana_admin_password = raw_input("Enter grafana admin user password or left it empty without changing: ")

        # Install grafana
        if var_install.lower() == "y":
            var_command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook " + var_full_path + "/role_grafana_install.yml"
            var_command = cli_common.concat_command(var_command, var_host_prometheus, var_host_prometheus_user)
            # if var_grafana_admin:
            #     var_command = var_command + " -e var_grafana_admin=" + var_grafana_admin
            # if var_grafana_admin_password:
            #     var_command = var_command + " -e var_grafana_admin_password=" + var_grafana_admin_password
            cli_common.execute_command(var_command)
Esempio n. 3
0
    def install(self):
        """
        Call ansible role_kamailio_install role to install kamailio.

        :return:
        """

        # Full path of python file locates in
        var_full_path = os.path.dirname(os.path.realpath(__file__))

        var_install_kamailio = raw_input("Install Kamailio? [y/n]: ")
        if var_install_kamailio.lower() == "y":
            var_host_target_kamailio = raw_input(
                "Enter deploying target machine (example: 192.168.1.20:8080): "
            )
            var_host_target_user_kamailio = raw_input(
                "Enter target machine user (default root): ") or "root"
        var_install_rtpengine = raw_input("Install Rtpengine? [y/n]: ")
        if var_install_rtpengine.lower() == "y":
            var_host_target_rtpengine = raw_input(
                "Enter deploying target machine (example: 192.168.1.20:8080): "
            )
            var_host_target_user_rtpengine = raw_input(
                "Enter target machine user (default root): ") or "root"

        if var_install_kamailio.lower() == "y" or var_install_rtpengine.lower(
        ) == "y":
            var_external_kamailio_ip = raw_input(
                "Enter kamailio external ip: ")
            var_internal_kamailio_ip = raw_input(
                "Enter kamailio internal ip: ")

        if var_install_kamailio.lower() == "y":
            var_command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook " + var_full_path + "/role_kamailio_install.yml -e 'ansible_python_interpreter=/usr/bin/python3'"
            var_command = cli_common.concat_command(
                var_command, var_host_target_kamailio,
                var_host_target_user_kamailio)
            if var_external_kamailio_ip:
                var_command = var_command + " -e var_external_kamailio_ip=" + var_external_kamailio_ip
            if var_internal_kamailio_ip:
                var_command = var_command + " -e var_internal_kamailio_ip=" + var_internal_kamailio_ip
            cli_common.execute_command(var_command)

        if var_install_rtpengine.lower() == "y":
            var_command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook " + var_full_path + "/role_rtpengine_install.yml -e 'ansible_python_interpreter=/usr/bin/python3'"
            var_command = cli_common.concat_command(
                var_command, var_host_target_rtpengine,
                var_host_target_user_rtpengine)
            if var_external_kamailio_ip:
                var_command = var_command + " -e var_external_kamailio_ip=" + var_external_kamailio_ip
            if var_internal_kamailio_ip:
                var_command = var_command + " -e var_internal_kamailio_ip=" + var_internal_kamailio_ip
            cli_common.execute_command(var_command)
Esempio n. 4
0
    def install(self,
                remote_hosts="127.0.0.1,",
                remote_user="******",
                include_jdk=False,
                include_git=False,
                include_maven=False,
                include_mariadb=False,
                include_redis=False,
                include_intellij=False,
                include_smartgit=False,
                include_xrdp=False,
                include_jmeter=False):
        """
        Install develop environment.

        :param remote_hosts
        :param remote_user
        :return:
        """

        # Full path of python file locates in
        var_full_path = os.path.dirname(os.path.realpath(__file__))
        var_command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook " + var_full_path + "/role_develop_env_install.yml"
        var_command = cli_common.concat_command(var_command, remote_hosts,
                                                remote_user)

        if include_jdk:
            var_command = var_command + " -e var_include_jdk=true"
        if include_git:
            var_command = var_command + " -e var_include_git=true"
        if include_maven:
            var_command = var_command + " -e var_include_maven=true"
        if include_mariadb:
            var_command = var_command + " -e var_include_mariadb=true"
        if include_redis:
            var_command = var_command + " -e var_include_redis=true"
        if include_intellij:
            var_command = var_command + " -e var_include_intellij=true"
        if include_smartgit:
            var_command = var_command + " -e var_include_smartgit=true"
        if include_xrdp:
            var_command = var_command + " -e var_include_xrdp=true"
        if include_jmeter:
            var_command = var_command + " -e var_include_jmeter=true"
            if not include_jdk:
                var_command = var_command + " -e var_include_jdk=true"

        cli_common.execute_command(var_command)
Esempio n. 5
0
    def install(self):
        """
        Install prometheus.

        :return:
        """

        # Full path of python file locates in
        var_full_path = os.path.dirname(os.path.realpath(__file__))

        var_install_prometheus = raw_input("Install prometheus? [y/n]: ")
        if var_install_prometheus.lower() == "y":
            var_host_prometheus = raw_input(
                "Enter target machine of deploying prometheus (example: 192.168.1.20:8080): "
            )
            var_host_prometheus_user = raw_input(
                "Enter target machine user (default root): ") or "root"
            var_host_pushgateway_1 = raw_input(
                "* Enter pushgateway (example: 192.168.1.20): ")
            if not var_host_pushgateway_1:
                raise Exception, "Parameter pushgateway cann't be empty"

        var_install_pushgateway = raw_input("Install pushgateway? [y/n]: ")
        if var_install_pushgateway.lower() == "y":
            var_host_pushgateway = raw_input(
                "Enter target machine of deploying pushgateway (example: 192.168.1.20:8080): "
            )
            var_host_pushgateway_user = raw_input(
                "Enter target machine user (default root): ") or "root"

        # Install prometheus
        if var_install_prometheus.lower() == "y":
            var_command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook " + var_full_path + "/role_prometheus_install.yml"
            var_command = cli_common.concat_command(var_command,
                                                    var_host_prometheus,
                                                    var_host_prometheus_user)
            var_command = var_command + " -e var_host_pushgateway=" + var_host_pushgateway_1
            cli_common.execute_command(var_command)

        # Install pushgateway
        if var_install_pushgateway.lower() == "y":
            var_command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook " + var_full_path + "/role_prometheus_pushgateway_install.yml"
            var_command = cli_common.concat_command(var_command,
                                                    var_host_pushgateway,
                                                    var_host_pushgateway_user)
            cli_common.execute_command(var_command)
Esempio n. 6
0
    def install(self):
        """
        Install mongodb

        :return:
        """

        # Full path of python file locates in
        var_full_path = os.path.dirname(os.path.realpath(__file__))

        var_install = raw_input("Install Mongodb? [y/n]: ")
        if var_install.lower() == "y":
            var_host_target = raw_input("Enter deploying target machine (example: 192.168.1.20:8080): ")
            var_host_target_user = raw_input("Enter target machine user (default root): ") or "root"

        if var_install.lower() == "y":
            var_command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook " + var_full_path + "/role_mongodb_install.yml"
            var_command = cli_common.concat_command(var_command, var_host_target, var_host_target_user)
            cli_common.execute_command(var_command)
Esempio n. 7
0
    def install(self):
        """
        Call ansible role_rabbitmq_install role to install rabbitmq.

        Access url http://192.168.1.180:15672/ with login user and password guest/guest
        :return:
        """

        # Full path of python file locates in
        var_full_path = os.path.dirname(os.path.realpath(__file__))

        var_install = raw_input("Install RabbitMQ? [y/n]: ")
        if var_install.lower() == "y":
            var_host_target_rabbitmq = raw_input("Enter deploying target machine (example: 192.168.1.20:8080): ")
            var_host_target_user_rabbitmq = raw_input("Enter target machine user (default root): ") or "root"

        if var_install.lower() == "y":
            var_command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook " + var_full_path + "/role_rabbitmq_install.yml"
            var_command = cli_common.concat_command(var_command, var_host_target_rabbitmq, var_host_target_user_rabbitmq)
            cli_common.execute_command(var_command)
Esempio n. 8
0
    def install(self, socks5=None, remote_hosts="127.0.0.1,", remote_user="******"):
        """
        Call ansible role_freeswitch_install role to install freeswitch.

        :param socks5:
            Socks5 proxy server to accelerate yum install freeswitch.
            Value should be in format 192.168.1.12:10080
        :param remote_hosts
        :param remote_user
        :return:
        """

        # Full path of python file locates in
        var_full_path = os.path.dirname(os.path.realpath(__file__))

        # Call ansible-playbook command with role_freeswitch_install.yml file
        var_command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook " + var_full_path + "/role_freeswitch_install.yml"

        if socks5:
            var_command = var_command + " -e socks5=socks5h://" + socks5
        var_command = cli_common.concat_command(var_command, remote_hosts, remote_user)
        cli_common.execute_command(var_command)
Esempio n. 9
0
    def install(self):
        """
        Install shadowsocks.
        :return:
        """

        # Full path of python file locates in
        var_full_path = os.path.dirname(os.path.realpath(__file__))

        var_install = raw_input("Install Shadowsocks? [y/n]: ")
        if var_install.lower() == "y":
            var_host_target = raw_input("Enter target deploying machine (example: 192.168.1.20:8080): ")
            var_host_target_user = raw_input("Enter target machine user (default root): ") or "root"
            var_server_port = raw_input("Enter server port (default 11080): ") or "11080"
            var_password = raw_input("Enter password (default 123456): ") or "123456"
            var_command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook " + var_full_path + "/role_shadowsocks_install.yml"
            var_command = cli_common.concat_command(var_command, var_host_target, var_host_target_user)
            if var_server_port:
                var_command = var_command + " -e var_server_port=" + var_server_port
            if var_password:
                var_command = var_command + " -e var_password=" + var_password
            cli_common.execute_command(var_command)
Esempio n. 10
0
    def install(self):
        """
        Install elasticsearch, logstash, kibana.
        Access http://localhost:9200 for determining if getting elasticsearch installed successfully.
        Access http://localhost:5601 for determining if getting kibana installed successfully.

        :return:
        """

        # Full path of python file locates in
        var_full_path = os.path.dirname(os.path.realpath(__file__))

        var_install = raw_input("Install Elasticsearch? [y/n]: ")
        if var_install.lower() == "y":
            var_host_target_elasticsearch = raw_input(
                "Enter deploying target machine (example: 192.168.1.20:8080): "
            )
            var_host_target_user_elasticsearch = raw_input(
                "Enter target machine user (default root): ") or "root"
        var_install_logstash = raw_input("Install Logstash? [y/n]: ")
        if var_install_logstash.lower() == "y":
            var_host_target_logstash = raw_input(
                "Enter deploying target machine (example: 192.168.1.20:8080): "
            )
            var_host_target_user_logstash = raw_input(
                "Enter target machine user (default root): ") or "root"
        var_install_kibana = raw_input("Install kibana? [y/n]: ")
        if var_install_kibana.lower() == "y":
            var_host_target_kibana = raw_input(
                "Enter deploying target machine (example: 192.168.1.20:8080): "
            )
            var_host_target_user_kibana = raw_input(
                "Enter target machine user (default root): ") or "root"

        if var_install.lower() == "y":
            var_command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook " + var_full_path + "/role_elasticsearch_install.yml"
            var_command = cli_common.concat_command(
                var_command, var_host_target_elasticsearch,
                var_host_target_user_elasticsearch)
            cli_common.execute_command(var_command)

        if var_install_logstash.lower() == "y":
            var_command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook " + var_full_path + "/role_logstash_install.yml"
            var_command = cli_common.concat_command(
                var_command, var_host_target_logstash,
                var_host_target_user_logstash)
            cli_common.execute_command(var_command)

        if var_install_kibana.lower() == "y":
            var_command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook " + var_full_path + "/role_kibana_install.yml"
            var_command = cli_common.concat_command(
                var_command, var_host_target_kibana,
                var_host_target_user_kibana)
            cli_common.execute_command(var_command)