예제 #1
0
    def install(self, env):
        import params

        env.set_params(params)
        self.install_packages(env)

        kc.copy_cache_or_repo(self.package,
                              cache_dir=self.installer_cache_path,
                              arch='noarch')
        self.clean_up_failed_install()
        Execute('unzip -o -q %s ' % (self.package))
        Execute('mv %s %s' %
                (self.package.replace('.zip', ''), params.installation_dir))
        # Execute('rm -rf %s/jb*.Final' % params.installation_dir)
        try:
            grp.getgrnam(params.service_user)
        except KeyError:
            Execute('groupadd ' + params.service_user)
        try:
            pwd.getpwnam(params.service_user)
        except KeyError:
            Execute('useradd -s /bin/bash -g %s %s' %
                    (params.service_user, params.service_user))

        Execute('chown -Rf %s:%s %s' %
                (params.service_user, params.service_user,
                 params.installation_dir))

        import glob
        if not len(glob.glob(params.JAVA_HOME)):
            raise ValueError("Could not find JAVA_HOME in location : " +
                             params.JAVA_HOME)

        self.configure(env)
예제 #2
0
    def install_storm(self, env):
        # install ZeroMQ which is prerequisite for storm
        user_exist = os.system('grep storm /etc/passwd > /dev/null')
        if user_exist != 0:
            # zeromq no longer needed?
            # kc.copy_cache_or_repo('zeromq-2.1.7-1.el6.x86_64.rpm')
            # Execute('yum install -y zeromq-2.1.7-1.el6.x86_64.rpm')
            Execute('groupadd -g 53001 storm')
            Execute('mkdir -p /app/home')
            Execute('useradd -u 53001 -g 53001 -d /app/home/storm -s /bin/bash storm -c "Storm service account"')
            Execute('chmod 700 /app/home/storm')

        storm_dir_present = os.path.isdir('/usr/local/storm')
        if not storm_dir_present:
            # download storm
            kc.copy_cache_or_repo('storm-10.0.zip', arch='noarch')
            # http://ftp.riken.jp/net/apache/storm/apache-storm-0.10.0/apache-storm-0.10.0.zip
            Execute('unzip -o -q storm-10.0.zip -d /usr/local')
            Execute('mv /usr/local/apache-storm-0.10.0* /usr/local/storm-0.10.0')
            Execute('chown -R storm:storm /usr/local/storm-0.10.0')
            Execute('ln -s /usr/local/storm-0.10.0 /usr/local/storm')
            Execute('ln -s /usr/local/storm/bin/storm /usr/local/bin/storm')

        storm_home_dir = os.path.isdir('/app/storm')
        if not storm_home_dir:
            # Creating local directory for storm
            Execute('mkdir -p /app/storm')
            Execute('chown -R storm:storm /app/storm')
            Execute('chmod 750 /app/storm')
        storm_log_dir = os.path.isdir('/var/log/storm')
        if not storm_log_dir:
            # Creating local directory for storm
            Execute('mkdir -p /var/log/storm')
            Execute('chown -R storm:storm /var/log/storm')
            Execute('chmod 750 /var/log/storm')
예제 #3
0
    def install(self, env):
        import params
        import time
        import json

        env.set_params(params)
        self.install_packages(env)

        Execute('mkdir -p %s ' % params.install_topdir)
        kc.copy_cache_or_repo(self.package, arch='noarch')
        Execute('unzip -q %s' % (self.package))
        if os.path.exists(params.install_topdir + params.install_subdir):
            Execute('rm -rf %s' %
                    (params.install_topdir + params.install_subdir))
        Execute('mv apache-archiva-2.2.0 %s' %
                (params.install_topdir + params.install_subdir))
        if os.path.exists(self.package):
            Execute('rm -f ' + self.package)

        archiva_dict = json.dumps(params.archiva_admin_dict)
        curl_command = (
            'curl -H Content-type:application/json -d' + " '" + archiva_dict +
            "' " + 'http://' + 'localhost' + ':' +
            str(params.archiva_jetty_port) +
            '/restServices/redbackServices/userService/createAdminUser')
        self.start(env)
        for retry in range(3):
            try:
                time.sleep(60)
                Execute(curl_command, logoutput=True)
                break
            except Fail as ex:
                print "the curl command met with failure this time,,,trying in another 60 secs"
                print ex
예제 #4
0
    def install(self, env):
        import params

        env.set_params(params)
        self.install_packages(env)

        kc.copy_cache_or_repo(self.package, cache_dir=self.installer_cache_path, arch='noarch')
        self.clean_up_failed_install()
        Execute('unzip -o -q %s ' % (self.package))
        Execute('mv %s %s' % (self.package.replace('.zip', ''), params.installation_dir))
        # Execute('rm -rf %s/jb*.Final' % params.installation_dir)
        try:
            grp.getgrnam(params.service_user)
        except KeyError:
            Execute('groupadd ' + params.service_user)
        try:
            pwd.getpwnam(params.service_user)
        except KeyError:
            Execute('useradd -s /bin/bash -g %s %s' % (params.service_user, params.service_user))

        Execute('chown -Rf %s:%s %s' % (params.service_user, params.service_user, params.installation_dir))

        import glob
        if not len(glob.glob(params.JAVA_HOME)):
            raise ValueError("Could not find JAVA_HOME in location : " + params.JAVA_HOME)

        self.configure(env)
예제 #5
0
    def install(self, env):
        import params
        import time
        import json

        env.set_params(params)
        self.install_packages(env)

        Execute('mkdir -p %s ' % params.install_topdir)
        kc.copy_cache_or_repo(self.package, arch='noarch')
        Execute('unzip -q %s' % (self.package))
        if os.path.exists(params.install_topdir + params.install_subdir):
            Execute('rm -rf %s' % (params.install_topdir + params.install_subdir))
        Execute('mv apache-archiva-2.2.0 %s' % (params.install_topdir + params.install_subdir))
        if os.path.exists(self.package):
            Execute('rm -f ' + self.package)

        archiva_dict = json.dumps(params.archiva_admin_dict)
        curl_command = ('curl -H Content-type:application/json -d'
                        + " '" + archiva_dict + "' "
                        + 'http://' + 'localhost' + ':' + str(params.archiva_jetty_port)
                        + '/restServices/redbackServices/userService/createAdminUser')
        self.start(env)
        for retry in range(3):
            try:
                time.sleep(60)
                Execute(curl_command, logoutput=True)
                break
            except Fail as ex:
                print "the curl command met with failure this time,,,trying in another 60 secs"
                print ex
예제 #6
0
    def install(self, env):
        import params

        env.set_params(params)
        self.install_packages(env)

        kc.copy_cache_or_repo(self.package, cache_dir=self.installer_cache_path, arch='noarch')
        self.clean_up_failed_install()
        Execute('unzip -o -q %s -d %s' % (self.package, params.installation_dir))
        Execute('mv %s/jb*/* %s' % (params.installation_dir, params.installation_dir))
        Execute('rm -rf %s/jb*.Final' % params.installation_dir)
        try:
            grp.getgrnam('jboss')
        except KeyError:
            Execute('groupadd jboss')
        try:
            pwd.getpwnam('jboss')
        except KeyError:
            Execute('useradd -s /bin/bash -g jboss jboss')

        Execute('chown -Rf jboss:jboss %s' % params.installation_dir)

        File('/etc/init.d/jboss',
             content=Template("jboss.j2"),
             mode=0755
             )

        Execute('chkconfig --add jboss')
        Execute('chkconfig jboss on')

        self.configure(env)
예제 #7
0
    def install_storm(self, env):
        # install ZeroMQ which is prerequisite for storm
        user_exist = os.system('grep storm /etc/passwd > /dev/null')
        if user_exist != 0:
            # zeromq no longer needed?
            # kc.copy_cache_or_repo('zeromq-2.1.7-1.el6.x86_64.rpm')
            # Execute('yum install -y zeromq-2.1.7-1.el6.x86_64.rpm')
            Execute('groupadd -g 53001 storm')
            Execute('mkdir -p /app/home')
            Execute(
                'useradd -u 53001 -g 53001 -d /app/home/storm -s /bin/bash storm -c "Storm service account"'
            )
            Execute('chmod 700 /app/home/storm')

        storm_dir_present = os.path.isdir('/usr/local/storm')
        if not storm_dir_present:
            # download storm
            kc.copy_cache_or_repo('apache-storm-1.0.2.tar.gz', arch='noarch')
            # Execute('wget http://www.us.apache.org/dist/storm/apache-storm-1.0.2/apache-storm-1.0.2.tar.gz')
            Execute('tar -xvf apache-storm-1.0.2.tar.gz -C /usr/local')
            Execute('mv /usr/local/apache-storm-1.0.2* /usr/local/storm-1.0.2')
            Execute('chown -R storm:storm /usr/local/storm-1.0.2')
            Execute('ln -s /usr/local/storm-1.0.2 /usr/local/storm')
            Execute('ln -s /usr/local/storm/bin/storm /usr/local/bin/storm')
        storm_log_dir = os.path.isdir('/var/log/storm')
        if not storm_log_dir:
            # Creating local directory for storm
            Execute('mkdir -p /var/log/storm')
            Execute('chown -R storm:storm /var/log/storm')
            Execute('chmod 750 /var/log/storm')
예제 #8
0
 def install_jce(self):
     import params
     # cache this download so that this can be redistributed on restart of the service
     kc.copy_cache_or_repo("jce_policy-7.zip",
                           cache_dir='/etc/kave/cache',
                           arch="noarch")
     kc.copy_cache_or_repo("jce_policy-8.zip",
                           cache_dir='/etc/kave/cache',
                           arch="noarch")
     # need to think of some protection against recursive softlinks
     for javapath in params.searchpath.split(':'):
         # print "this is javaPath"+javapath
         if not len(javapath):
             continue
         # Does the top directory exist and is it a directory?
         if os.path.isdir(
                 os.path.realpath(os.sep.join(javapath.split(
                     os.sep)[:-1]))):
             for dir in glob.glob(javapath):
                 dir = os.path.realpath(dir)
                 if os.path.isdir(dir):
                     # print os.listdir(dir)
                     for folderpath in params.folderpath.split(':'):
                         if not os.path.isdir(dir + '/' + folderpath):
                             Execute('mkdir -p ' + dir + '/' + folderpath)
                         if '1.7' == self.java_version_installed(dir):
                             Execute('unzip -o -j -q jce_policy-7.zip -d ' +
                                     dir + '/' + folderpath)
                         else:
                             Execute('unzip -o -j -q jce_policy-8.zip -d ' +
                                     dir + '/' + folderpath)
예제 #9
0
    def install_storm(self, env):
        # install ZeroMQ which is prerequisite for storm
        user_exist = os.system('grep storm /etc/passwd > /dev/null')
        if user_exist != 0:
            # zeromq no longer needed?
            # kc.copy_cache_or_repo('zeromq-2.1.7-1.el6.x86_64.rpm')
            # Execute('yum install -y zeromq-2.1.7-1.el6.x86_64.rpm')
            Execute('groupadd -g 53001 storm')
            Execute('mkdir -p /app/home')
            Execute('useradd -u 53001 -g 53001 -d /app/home/storm -s /bin/bash storm -c "Storm service account"')
            Execute('chmod 700 /app/home/storm')

        storm_dir_present = os.path.isdir('/usr/local/storm')
        if not storm_dir_present:
            # download storm
            kc.copy_cache_or_repo('apache-storm-1.0.2.tar.gz', arch='noarch')
            # Execute('wget http://www.us.apache.org/dist/storm/apache-storm-1.0.2/apache-storm-1.0.2.tar.gz')
            Execute('tar -xvf apache-storm-1.0.2.tar.gz -C /usr/local')
            Execute('mv /usr/local/apache-storm-1.0.2* /usr/local/storm-1.0.2')
            Execute('chown -R storm:storm /usr/local/storm-1.0.2')
            Execute('ln -s /usr/local/storm-1.0.2 /usr/local/storm')
            Execute('ln -s /usr/local/storm/bin/storm /usr/local/bin/storm')
        storm_log_dir = os.path.isdir('/var/log/storm')
        if not storm_log_dir:
            # Creating local directory for storm
            Execute('mkdir -p /var/log/storm')
            Execute('chown -R storm:storm /var/log/storm')
            Execute('chmod 750 /var/log/storm')
예제 #10
0
    def install(self, env):
        import params
        # intelligently choose architecture
        import kavecommon as kc
        el = {"centos7": "el7"}
        self.package = self.package % el[kc.detect_linux_version().lower()]
        self.install_packages(env)
        env.set_params(params)

        kc.copy_cache_or_repo(self.package,
                              cache_dir=self.installer_cache_path)

        if params.use_external_postgres:
            Execute('sudo -u postgres psql -d template1 -c "CREATE USER ' +
                    str(params.postgres_database_user) +
                    ' WITH PASSWORD \'%s\';"' % params.gitlab_admin_password)
            Execute(
                'sudo -u postgres psql -d template1 -c "ALTER USER %s CREATEDB;"'
                % params.postgres_database_user)
            Execute('sudo -u postgres psql -d template1 -c ' +
                    '"CREATE DATABASE {} OWNER {};"'.format(
                        params.postgres_database_name,
                        params.postgres_database_user))
            Execute(
                'sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"'
            )

        # reset the password with set_password method
        # cretae SSL certificate
        Execute('rpm --replacepkgs -i %s' % self.package)

        if params.use_external_postgres:
            Execute('gitlab-ctl reconfigure')
            Execute('gitlab-rake gitlab:setup force=yes')
        Execute('mkdir -p /etc/gitlab/ssl/')
        country = "NA"
        state = "NA"
        locality = "NA"
        organization = "NA"
        organizationalun = "NA"
        if len(params.hostname) <= 64:
            commonname = params.hostname
        else:
            commonname = params.hostname.split(".", 1)[0]
        email = "*****@*****.**"
        Execute(
            str.format(
                'openssl req -x509 -nodes -days 3650 -newkey rsa:2048' +
                ' -keyout /etc/gitlab/ssl/' + str(params.hostname) +
                '.key -out ' + '/etc/gitlab/ssl/' + str(params.hostname) +
                '.crt ' +
                '-subj "/C={}/ST={}/L={}/O={}/OU={}/CN={}/emailAddress={}' +
                '"', country, state, locality, organization, organizationalun,
                commonname, email))
        self.configure(env)
        self.set_password(env)
        Execute("rm -rf " + self.installer_cache_path + self.package)
예제 #11
0
    def install(self, env):
        import params
        import kavecommon as kc
        Execute('yum clean all')
        self.install_packages(env)
        env.set_params(params)
        # no need to install if already installed ... does not work behind firewall after restart
        if self.kind == "node" and (os.path.exists('/etc/kave/toolbox_ok')
                                    and os.path.exists(params.top_dir +
                                                       '/KaveToolbox')):
            return True
        # configure first before installing, create custom install file and mirror file if necessary
        self.configure(env)
        if len(self.sttmpdir) < 4:
            raise IOError("where are you using for temp??")
        # Set up temporary directory for download/install
        Execute("mkdir -p " + self.sttmpdir)
        Execute("rm -rf " + self.sttmpdir + "/*")
        topdir = os.path.realpath(os.path.curdir)
        extraopts = ""
        if params.ignore_missing_groups:
            extraopts = " --ignore-missing-groups"
        kavetoolbox_path = '/KaveToolbox/' + params.releaseversion + 'scripts/KaveInstall'
        instscript = params.top_dir + kavetoolbox_path
        # no need to download if install script already exists
        if not os.path.exists(instscript):
            os.chdir(self.sttmpdir)
            kc.copy_cache_or_repo('kavetoolbox-' + params.releaseversion +
                                  '.tar.gz',
                                  arch="noarch",
                                  ver=params.releaseversion,
                                  dir="KaveToolbox")
            Execute('tar -xzf kavetoolbox-' + params.releaseversion +
                    '.tar.gz')
            # try to cope with the annoying way the tarball contains something with .git at the end!
            import glob

            for gits in glob.glob(self.sttmpdir + "/*.git"):
                if os.path.isdir(gits) and not gits.endswith("/.git"):
                    Execute('mv ' + gits + ' ' + gits[:-len(".git")])
            instscript = './KaveToolbox/scripts/KaveInstall'

        commandlineargs = ""
        if params.command_line_args:
            commandlineargs = " " + params.command_line_args
        Execute(instscript + ' --' + self.kind + extraopts + commandlineargs,
                logoutput=True)
        os.chdir(topdir)
        Execute("rm -rf " + self.sttmpdir + "/*")
        Execute("mkdir -p /etc/kave")
        Execute('touch /etc/kave/toolbox_ok')
        Execute('chmod -R a+r /etc/kave')
예제 #12
0
    def install(self, env):
        import params
        import kavecommon as kc

        super(Twiki, self).install(env)
        env.set_params(params)
        kc.copy_cache_or_repo('TWiki-6.0.0.zip', arch='noarch')
        Execute("mkdir -p " + params.install_dir)
        Execute("unzip -o -q TWiki-6.0.0.zip -d " + params.install_dir)
        Execute("mkdir -p " + params.install_dir + 'authtest')
        kc.chown_r(params.install_dir, "apache")
        Execute("cp " + params.install_dir + "/bin/LocalLib.cfg.txt " + params.install_dir + "/bin/LocalLib.cfg")
        Execute("chown apache:apache " + params.install_dir + "/bin/LocalLib.cfg")
        self.configure(env)
예제 #13
0
    def install(self, env):
        import params

        self.install_packages(env)

        # protect against client downloading behind firewall
        if not os.path.exists(params.sonarqube_runner_install_directory + '/current'):
            kc.copy_cache_or_repo(self.package, arch='noarch')
            Execute('mkdir -p %s ' % params.sonarqube_runner_install_directory)
            Execute('unzip -o -q %s -d %s' % (self.package, params.sonarqube_runner_install_directory))
            Execute('ln -sfn %s/sonar-runner-2.4 %s/current' % (
                params.sonarqube_runner_install_directory,
                params.sonarqube_runner_install_directory))

        self.configure(env)
예제 #14
0
    def install(self, env):
        import params

        self.install_packages(env)

        # protect against client downloading behind firewall
        if not os.path.exists(params.sonarqube_runner_install_directory + '/current'):
            kc.copy_cache_or_repo(self.package, arch="noarch")
            Execute('mkdir -p %s ' % params.sonarqube_runner_install_directory)
            Execute('unzip -o -q %s -d %s' % (self.package, params.sonarqube_runner_install_directory))
            Execute('ln -sfn %s/sonar-runner-2.4 %s/current' % (
                params.sonarqube_runner_install_directory,
                params.sonarqube_runner_install_directory))

        self.configure(env)
예제 #15
0
    def install(self, env):
        import params
        import kavecommon as kc
        Execute('yum clean all')
        self.install_packages(env)
        env.set_params(params)
        # no need to install if already installed ... does not work behind firewall after restart
        if self.kind == "node" and (os.path.exists('/etc/kave/toolbox_ok')
                                    and os.path.exists(params.top_dir + '/KaveToolbox')):
            return True
        # configure first before installing, create custom install file and mirror file if necessary
        self.configure(env)
        if len(self.sttmpdir) < 4:
            raise IOError("where are you using for temp??")
        # Set up temporary directory for download/install
        Execute("mkdir -p " + self.sttmpdir)
        Execute("rm -rf " + self.sttmpdir + "/*")
        topdir = os.path.realpath(os.path.curdir)
        extraopts = ""
        if params.ignore_missing_groups:
            extraopts = " --ignore-missing-groups"
        kavetoolbox_path = '/KaveToolbox/' + params.releaseversion + 'scripts/KaveInstall'
        instscript = params.top_dir + kavetoolbox_path
        # no need to download if install script already exists
        if not os.path.exists(instscript):
            os.chdir(self.sttmpdir)
            kc.copy_cache_or_repo('kavetoolbox-' + params.releaseversion + '.tar.gz', arch="noarch",
                                  ver=params.releaseversion,
                                  dir="KaveToolbox")
            Execute('tar -xzf kavetoolbox-' + params.releaseversion + '.tar.gz')
            # try to cope with the annoying way the tarball contains something with .git at the end!
            import glob

            for gits in glob.glob(self.sttmpdir + "/*.git"):
                if os.path.isdir(gits) and not gits.endswith("/.git"):
                    Execute('mv ' + gits + ' ' + gits[:-len(".git")])
            instscript = './KaveToolbox/scripts/KaveInstall'

        commandlineargs = ""
        if params.command_line_args:
            commandlineargs = " " + params.command_line_args
        Execute(instscript + ' --' + self.kind + extraopts + commandlineargs,
                logoutput=True)
        os.chdir(topdir)
        Execute("rm -rf " + self.sttmpdir + "/*")
        Execute("mkdir -p /etc/kave")
        Execute('touch /etc/kave/toolbox_ok')
        Execute('chmod -R a+r /etc/kave')
예제 #16
0
 def install(self, env):
     import params
     import kavecommon as kc
     kc.extra_redhat_repos()
     super(Twiki, self).install(env)
     env.set_params(params)
     kc.copy_cache_or_repo('TWiki-6.0.0.zip', arch='noarch')
     Execute("mkdir -p " + params.install_dir)
     Execute("unzip -o -q TWiki-6.0.0.zip -d " + params.install_dir)
     Execute("mkdir -p " + params.install_dir + 'authtest')
     kc.chown_r(params.install_dir, "apache")
     Execute("cp " + params.install_dir + "/bin/LocalLib.cfg.txt " +
             params.install_dir + "/bin/LocalLib.cfg")
     Execute("chown apache:apache " + params.install_dir +
             "/bin/LocalLib.cfg")
     self.configure(env)
예제 #17
0
    def install(self, env):
        import params

        env.set_params(params)
        self.install_packages(env)
        dlname = 'jenkins-' + str(params.download_version) + '-1.1.noarch.rpm'
        kc.copy_cache_or_repo(dlname, arch='noarch', alternates='http://pkg.jenkins-ci.org/redhat/' + dlname)
        Execute('rpm -qa | grep -qw jenkins || yum -y install ' + dlname)

        self.configure(env)
        # wget all requested plugins
        for plugin in params.plugins.split(','):
            plugin = plugin.strip()
            if not len(plugin):
                continue
            extsources = ["http://updates.jenkins-ci.org/latest/" + plugin + h for h in [".hpi", ".jpi"]]
            mirrorsources = []
            for mirror in kc.mirrors():
                mirrorsources = mirrorsources + \
                    [kc.repo_url('jenkins_plugins/' + plugin + h, arch='noarch', repo=mirror) for h in [".hpi", ".jpi"]]
            intsources = [kc.repo_url('jenkins_plugins/' + plugin + h, arch='noarch') for h in [".hpi", ".jpi"]]
            source = kc.failover_source(mirrorsources + intsources + extsources)
            dest = params.JENKINS_HOME + "/plugins/" + source.split('/')[-1]
            Execute(kc.copymethods(source, dest))

        File(params.JENKINS_HOME + '/config.xml',
             content=Template("config.xml.j2"),
             mode=0644
             )
        kc.chown_r(params.JENKINS_HOME + '/config.xml', params.JENKINS_USER)
        Execute('chkconfig jenkins on')
        self.start(env)
        # using curl to create username password for jenkinsl
        curl_command = ('curl -d "username='******'&password1=' + params.JENKINS_ADMIN_PASSWORD
                        + '&email=' + params.JENKINS_ADMIN_EMAIL + '&password2='
                        + params.JENKINS_ADMIN_PASSWORD + '&fullname='
                        + params.JENKINS_ADMIN + '&Submit=Sign%20up" "http://'
                        + params.hostname + ':' + str(params.JENKINS_PORT) + '/securityRealm/createAccount"')
        try:
            Execute(curl_command)
        except Fail as ex:
            print "the curl command met with failure the first time,,,trying in another 60 secs"
            print ex
            import time
            time.sleep(60)
            Execute(curl_command)
예제 #18
0
    def install(self, env):
        import params

        env.set_params(params)
        self.install_packages(env)
        dlname = 'jenkins-' + str(params.download_version) + '-1.1.noarch.rpm'
        kc.copy_cache_or_repo(dlname, arch='noarch', alternates='http://pkg.jenkins-ci.org/redhat/' + dlname)
        Execute('rpm -qa | grep -qw jenkins || yum -y install ' + dlname)

        self.configure(env)
        # wget all requested plugins
        for plugin in params.plugins.split(','):
            plugin = plugin.strip()
            if not len(plugin):
                continue
            extsources = ["http://updates.jenkins-ci.org/latest/" + plugin + h for h in [".hpi", ".jpi"]]
            mirrorsources = []
            for mirror in kc.mirrors():
                mirrorsources = mirrorsources + \
                    [kc.repo_url('jenkins_plugins/' + plugin + h, arch='noarch', repo=mirror) for h in [".hpi", ".jpi"]]
            intsources = [kc.repo_url('jenkins_plugins/' + plugin + h, arch='noarch') for h in [".hpi", ".jpi"]]
            source = kc.failover_source(mirrorsources + intsources + extsources)
            dest = params.JENKINS_HOME + "/plugins/" + source.split('/')[-1]
            Execute(kc.copymethods(source, dest))

        File(params.JENKINS_HOME + '/config.xml',
             content=Template("config.xml.j2"),
             mode=0644
             )
        kc.chown_r(params.JENKINS_HOME + '/config.xml', params.JENKINS_USER)
        Execute('chkconfig jenkins on')
        self.start(env)
        # using curl to create username password for jenkinsl
        curlCommand = ('curl -d "username='******'&password1=' + params.JENKINS_ADMIN_PASSWORD
                       + '&email=' + params.JENKINS_ADMIN_EMAIL + '&password2='
                       + params.JENKINS_ADMIN_PASSWORD + '&fullname='
                       + params.JENKINS_ADMIN + '&Submit=Sign%20up" "http://'
                       + params.hostname + ':' + str(params.JENKINS_PORT) + '/securityRealm/createAccount"')
        try:
            Execute(curlCommand)
        except Fail as ex:
            print "the curl command met with failure the first time,,,trying in another 60 secs"
            print ex
            import time
            time.sleep(60)
            Execute(curlCommand)
예제 #19
0
파일: gitlab.py 프로젝트: KaveIO/AmbariKave
    def install(self, env):
        import params
        # intelligently choose architecture
        import kavecommon as kc
        el = {"centos7": "el7"}
        self.package = self.package % el[kc.detect_linux_version().lower()]
        self.install_packages(env)
        env.set_params(params)

        kc.copy_cache_or_repo(self.package, cache_dir=self.installer_cache_path)

        if params.use_external_postgres:
            Execute('sudo -u postgres psql -d template1 -c "CREATE USER ' + str(params.postgres_database_user) +
                    ' WITH PASSWORD \'%s\';"' % params.gitlab_admin_password)
            Execute('sudo -u postgres psql -d template1 -c "ALTER USER %s CREATEDB;"' % params.postgres_database_user)
            Execute('sudo -u postgres psql -d template1 -c ' +
                    '"CREATE DATABASE {} OWNER {};"'.format(params.postgres_database_name,
                                                            params.postgres_database_user))
            Execute('sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"')

        # reset the password with set_password method
        # cretae SSL certificate
        Execute('rpm --replacepkgs -i %s' % self.package)

        if params.use_external_postgres:
            Execute('gitlab-ctl reconfigure')
            Execute('gitlab-rake gitlab:setup force=yes')
        Execute('mkdir -p /etc/gitlab/ssl/')
        country = "NA"
        state = "NA"
        locality = "NA"
        organization = "NA"
        organizationalun = "NA"
        if len(params.hostname) <= 64:
            commonname = params.hostname
        else:
            commonname = params.hostname.split(".", 1)[0]
        email = "*****@*****.**"
        Execute(str.format('openssl req -x509 -nodes -days 3650 -newkey rsa:2048' +
                           ' -keyout /etc/gitlab/ssl/' + str(params.hostname) + '.key -out ' +
                           '/etc/gitlab/ssl/' + str(params.hostname) + '.crt ' +
                           '-subj "/C={}/ST={}/L={}/O={}/OU={}/CN={}/emailAddress={}' +
                           '"', country, state, locality, organization, organizationalun, commonname, email))
        self.configure(env)
        self.set_password(env)
        Execute("rm -rf " + self.installer_cache_path + self.package)
예제 #20
0
    def install(self, env):
        import params

        env.set_params(params)
        self.install_packages(env)

        Execute('mkdir -p %s ' % params.install_topdir)
        kc.copy_cache_or_repo(self.package, arch="noarch")
        Execute('unzip -q %s' % (self.package))
        if os.path.exists(params.install_topdir + params.install_subdir):
            Execute('rm -rf %s' % (params.install_topdir + params.install_subdir))
        Execute('mv apache-archiva-2.2.0 %s' % (params.install_topdir + params.install_subdir))
        if os.path.exists(self.package):
            Execute('rm -f ' + self.package)
        if os.path.exists('/etc/init.d/archiva'):
            Execute('rm -f /etc/init.d/archiva')
        Execute('ln -s %s/bin/archiva /etc/init.d/archiva' % (params.install_topdir + params.install_subdir))

        self.configure(env)
예제 #21
0
    def install(self, env):
        # TODO: instead of throwing an exception here, I should enter gitlabs into the existing postgre database
        # correctly
        if os.path.exists('/var/lib/pgsql/data/pg_hba.conf'):
            raise SystemError(
                "You appear to already have a default postgre database installed (probably you're trying to put "
                "Gitlabs on the same machine as Ambari). This type of operation is not implemented yet.")
        import params
        # intelligently choose architecture
        import kavecommon as kc
        el = {"centos6": "el6", "centos7": "el7"}
        self.package = self.package % el[kc.detect_linux_version().lower()]
        self.install_packages(env)
        env.set_params(params)

        kc.copy_cache_or_repo(self.package, cache_dir=self.installer_cache_path)
        # reset the password with set_password method
        Execute('rpm --replacepkgs -i %s' % self.package)
        self.configure(env)
        self.set_password(env)
예제 #22
0
    def install(self, env):
        import params

        env.set_params(params)
        self.install_packages(env)

        kc.copy_cache_or_repo(self.package,
                              cache_dir=self.installer_cache_path,
                              arch='noarch')
        self.clean_up_failed_install()
        Execute('unzip -o -q %s -d %s' %
                (self.package, params.installation_dir))
        Execute('mv %s/jb*/* %s' %
                (params.installation_dir, params.installation_dir))
        Execute('rm -rf %s/jb*.Final' % params.installation_dir)
        try:
            grp.getgrnam(params.service_user)
        except KeyError:
            Execute('groupadd ' + params.service_user)
        try:
            pwd.getpwnam(params.service_user)
        except KeyError:
            Execute('useradd -s /bin/bash -g %s %s' %
                    (params.service_user, params.service_user))

        Execute('chown -Rf %s:%s %s' %
                (params.service_user, params.service_user,
                 params.installation_dir))

        import glob
        if not len(glob.glob(params.JAVA_HOME)):
            raise ValueError("Could not find JAVA_HOME in location : " +
                             params.JAVA_HOME)

        File('/etc/init.d/jboss', content=Template("jboss.j2"), mode=0755)

        Execute('chkconfig --add jboss')
        Execute('chkconfig jboss on')

        self.configure(env)
예제 #23
0
 def install_jce(self):
     import params
     # cache this download so that this can be redistributed on restart of the service
     kc.copy_cache_or_repo("jce_policy-7.zip", cache_dir='/etc/kave/cache', arch="noarch")
     kc.copy_cache_or_repo("jce_policy-8.zip", cache_dir='/etc/kave/cache', arch="noarch")
     # need to think of some protection against recursive softlinks
     for javapath in params.searchpath.split(':'):
         # print "this is javaPath"+javapath
         if not len(javapath):
             continue
         # Does the top directory exist and is it a directory?
         if os.path.isdir(os.path.realpath(os.sep.join(javapath.split(os.sep)[:-1]))):
             for dir in glob.glob(javapath):
                 dir = os.path.realpath(dir)
                 if os.path.isdir(dir):
                     # print os.listdir(dir)
                     for folderpath in params.folderpath.split(':'):
                         if not os.path.isdir(dir + '/' + folderpath):
                             Execute('mkdir -p ' + dir + '/' + folderpath)
                         if '1.7' == self.java_version_installed(dir):
                             Execute('unzip -o -j -q jce_policy-7.zip -d ' + dir + '/' + folderpath)
                         else:
                             Execute('unzip -o -j -q jce_policy-8.zip -d ' + dir + '/' + folderpath)
예제 #24
0
    def install(self, env):
        import params

        env.set_params(params)
        self.install_packages(env)
        dlname = 'jenkins-' + str(params.download_version) + '-1.1.noarch.rpm'
        kc.copy_cache_or_repo(dlname,
                              arch='noarch',
                              alternates='http://pkg.jenkins-ci.org/redhat/' +
                              dlname)
        Execute('rpm -qa | grep -qw jenkins || yum -y install ' + dlname)

        self.configure(env)
        # wget all requested plugins
        for plugin in params.plugins.split(','):
            plugin = plugin.strip()
            if not len(plugin):
                continue
            extsources = [
                "http://updates.jenkins-ci.org/latest/" + plugin + h
                for h in [".hpi", ".jpi"]
            ]
            mirrorsources = []
            for mirror in kc.mirrors():
                mirrorsources = mirrorsources + \
                    [kc.repo_url('jenkins_plugins/' + plugin + h, arch='noarch', repo=mirror) for h in [".hpi", ".jpi"]]
            intsources = [
                kc.repo_url('jenkins_plugins/' + plugin + h, arch='noarch')
                for h in [".hpi", ".jpi"]
            ]
            source = kc.failover_source(mirrorsources + intsources +
                                        extsources)
            dest = params.JENKINS_HOME + "/plugins/" + source.split('/')[-1]
            Execute(kc.copymethods(source, dest))

        Execute('mkdir -p /var/lib/jenkins/.ssl')
        cpath = "/var/lib/jenkins/.ssl"
        print str(cpath)
        #         #Change to your company details
        country = "NA"
        state = "NA"
        locality = "NA"
        organization = "NA"
        organizationalun = "NA"
        if len(params.hostname) <= 64:
            commonname = params.hostname
        else:
            commonname = params.hostname.split(".", 1)[0]
        email = "*****@*****.**"
        #         Optional
        password = "******"
        print "Generating key request"
        #         #Generate a key
        Execute(
            str.format(
                'openssl req -x509 -newkey rsa:4096' +
                ' -passout pass:{} -keyout /var/lib/jenkins/.ssl/key.pem -out'
                + ' /var/lib/jenkins/.ssl/cert.pem' +
                ' -days 365 -subj "/C={}/ST={}/L={}/O={}/OU={}/CN={}/emailAddress={} '
                + '"', password, country, state, locality, organization,
                organizationalun, commonname, email))
        #         #Import the key to pckc12
        Execute(
            str.format(
                'openssl pkcs12 -inkey /var/lib/jenkins/.ssl/key.pem' +
                ' -in /var/lib/jenkins/.ssl/cert.pem -export -out /var/lib/jenkins/.ssl/cert.p12'
                + ' -passin pass:{} -passout pass:{}', password, password))
        #         #Import keystore
        Execute(
            str.format(
                'keytool -importkeystore -srckeystore /var/lib/jenkins/.ssl/cert.p12'
                +
                ' -destkeystore /var/lib/jenkins/.ssl/jenkins.jks -srcstoretype pkcs12'
                + ' -deststoretype JKS -srcstorepass {} -deststorepass {}',
                password, password))

        File(params.JENKINS_HOME + '/config.xml',
             content=Template("config.xml.j2"),
             mode=0644)
        kc.chown_r(params.JENKINS_HOME + '/config.xml', params.JENKINS_USER)
        Execute('chkconfig jenkins on')

        self.start(env)
        # using curl to create username password for jenkinsl
        curl_command = ('curl -k -d "username='******'&password1=' + params.JENKINS_ADMIN_PASSWORD +
                        '&email=' + params.JENKINS_ADMIN_EMAIL +
                        '&password2=' + params.JENKINS_ADMIN_PASSWORD +
                        '&fullname=' + params.JENKINS_ADMIN +
                        '&Submit=Sign%20up" "https://' + params.hostname +
                        ':' + str(params.JENKINS_HTTPS_PORT) +
                        '/securityRealm/createAccount"')
        try:
            Execute(curl_command)
        except Fail as ex:
            print "the curl command met with failure the first time,,,trying in another 60 secs"
            print ex
            import time
            time.sleep(60)
            Execute(curl_command)
예제 #25
0
    def install(self, env):
        import params

        env.set_params(params)
        self.install_packages(env)
        # protect against client downloading behind firewall
        if not os.path.exists(params.sonarqube_install_directory + '/current'):
            kc.copy_cache_or_repo(
                self.package, arch='noarch'
            )  # http://dist.sonar.codehaus.org/sonarqube-5.0.1.zip
            Execute('mkdir -p %s ' % params.sonarqube_install_directory)
            Execute('unzip -o -q %s -d %s' %
                    (self.package, params.sonarqube_install_directory))
            Execute('ln -sfn %s/sonarqube-5.4 %s/current' %
                    (params.sonarqube_install_directory,
                     params.sonarqube_install_directory))

        if not os.path.exists(
                params.sonarqube_install_directory +
                '/current/extensions/plugins/sonar-pam-plugin-0.2.jar'):
            import tempfile
            import glob
            tdir = tempfile.mkdtemp()
            topd = os.path.realpath('.')
            os.chdir(tdir)
            # http://downloads.sourceforge.net/project/jpam/jpam/jpam-1.1/JPam-Linux_amd64-1.1.tgz
            # -O JPam-Linux_amd64-1.1.tgz')
            kc.copy_cache_or_repo("JPam-Linux_amd64-1.1.tgz", arch='noarch')
            Execute('tar -xvzf JPam-Linux_amd64-1.1.tgz')
            Execute('cp JPam-1.1/JPam-1.1.jar ' +
                    params.sonarqube_install_directory +
                    '/current/lib/common/')
            for javapath in params.jvmpath.split(':'):
                if not len(javapath):
                    continue
                # Does the top directory exist and is it a directory?
                if os.path.isdir(
                        os.path.realpath(
                            os.sep.join(javapath.split(os.sep)[:-1]))):
                    for dir in glob.glob(javapath):
                        if os.path.isdir(dir):
                            Execute('mkdir -p ' + dir + '/lib/amd64')
                            Execute('chmod -R a+r ' + dir)
                            Execute('cp JPam-1.1/libjpam.so ' + dir +
                                    '/lib/amd64/')
                            Execute('chmod a+x ' + dir +
                                    '/lib/amd64/libjpam.so')

            Execute('cp JPam-1.1/net-sf-jpam /etc/pam.d/')
            # http://downloads.sonarsource.com/plugins/org/codehaus/sonar-plugins/sonar-pam-plugin
            # /0.2/sonar-pam-plugin-0.2.jar
            kc.copy_cache_or_repo("sonar-pam-plugin-0.2.jar", arch='noarch')
            Execute('cp sonar-pam-plugin-0.2.jar ' +
                    params.sonarqube_install_directory +
                    '/current/extensions/plugins/')
            os.chdir(topd)
            Execute('rm -rf ' + tdir)

        # Getting the processor architecture type(64 bit or 32 bit)
        p = subprocess.Popen(["uname", "-p"], stdout=subprocess.PIPE)
        arch_type = p.communicate()[0]
        if os.path.exists('/etc/init.d/sonar'):
            Execute('rm -rf /etc/init.d/sonar')
        if 'x86_64' in arch_type:
            print("64 bit processor")
            Execute(
                'ln -s %s/current/bin/linux-x86-64/sonar.sh /etc/init.d/sonar'
                % params.sonarqube_install_directory)
        else:
            print("32 bit processor")
            Execute(
                'ln -s %s/current/bin/linux-x86-32/sonar.sh /etc/init.d/sonar'
                % params.sonarqube_install_directory)

        for plugin in params.sonarqube_plugins:
            kc.copy_cache_or_repo(plugin, arch="noarch")
            Execute('mv %s %s/current/extensions/plugins/' %
                    (plugin, params.sonarqube_install_directory))

        self.configure(env)
예제 #26
0
    def install(self, env):
        import params

        env.set_params(params)
        self.install_packages(env)
        # protect against client downloading behind firewall
        if not os.path.exists(params.sonarqube_install_directory + '/current'):
            kc.copy_cache_or_repo(self.package, arch='noarch')  # http://dist.sonar.codehaus.org/sonarqube-5.0.1.zip
            Execute('mkdir -p %s ' % params.sonarqube_install_directory)
            Execute('unzip -o -q %s -d %s' % (self.package, params.sonarqube_install_directory))
            Execute('ln -sfn %s/sonarqube-5.4 %s/current' % (
                params.sonarqube_install_directory,
                params.sonarqube_install_directory))

        if not os.path.exists(params.sonarqube_install_directory
                              + '/current/extensions/plugins/sonar-pam-plugin-0.2.jar'):
            import tempfile
            import glob
            tdir = tempfile.mkdtemp()
            topd = os.path.realpath('.')
            os.chdir(tdir)
            # http://downloads.sourceforge.net/project/jpam/jpam/jpam-1.1/JPam-Linux_amd64-1.1.tgz
            # -O JPam-Linux_amd64-1.1.tgz')
            kc.copy_cache_or_repo("JPam-Linux_amd64-1.1.tgz", arch='noarch')
            Execute('tar -xvzf JPam-Linux_amd64-1.1.tgz')
            Execute('cp JPam-1.1/JPam-1.1.jar ' + params.sonarqube_install_directory + '/current/lib/common/')
            for javapath in params.jvmpath.split(':'):
                if not len(javapath):
                    continue
                # Does the top directory exist and is it a directory?
                if os.path.isdir(os.path.realpath(os.sep.join(javapath.split(os.sep)[:-1]))):
                    for dir in glob.glob(javapath):
                        if os.path.isdir(dir):
                            Execute('mkdir -p ' + dir + '/lib/amd64')
                            Execute('chmod -R a+r ' + dir)
                            Execute('cp JPam-1.1/libjpam.so ' + dir + '/lib/amd64/')
                            Execute('chmod a+x ' + dir + '/lib/amd64/libjpam.so')

            Execute('cp JPam-1.1/net-sf-jpam /etc/pam.d/')
            # http://downloads.sonarsource.com/plugins/org/codehaus/sonar-plugins/sonar-pam-plugin
            # /0.2/sonar-pam-plugin-0.2.jar
            kc.copy_cache_or_repo("sonar-pam-plugin-0.2.jar", arch='noarch')
            Execute('cp sonar-pam-plugin-0.2.jar ' + params.sonarqube_install_directory
                    + '/current/extensions/plugins/')
            os.chdir(topd)
            Execute('rm -rf ' + tdir)

        # Getting the processor architecture type(64 bit or 32 bit)
        p = subprocess.Popen(["uname", "-p"], stdout=subprocess.PIPE)
        arch_type = p.communicate()[0]
        if os.path.exists('/etc/init.d/sonar'):
            Execute('rm -rf /etc/init.d/sonar')
        if 'x86_64' in arch_type:
            print("64 bit processor")
            Execute('ln -s %s/current/bin/linux-x86-64/sonar.sh /etc/init.d/sonar' % params.sonarqube_install_directory)
        else:
            print("32 bit processor")
            Execute('ln -s %s/current/bin/linux-x86-32/sonar.sh /etc/init.d/sonar' % params.sonarqube_install_directory)

        for plugin in params.sonarqube_plugins:
            kc.copy_cache_or_repo(plugin, arch="noarch")
            Execute('mv %s %s/current/extensions/plugins/' % (plugin, params.sonarqube_install_directory))

        self.configure(env)
예제 #27
0
    def install(self, env):
        import params
        import kavecommon as kc

        package = 'kavetoolbox-' + params.releaseversion + '.tar.gz'
        Execute('yum clean all')
        self.install_packages(env)
        env.set_params(params)
        # no need to install if already installed ... does not work behind firewall after restart
        if self.kind == "node" and (os.path.exists('/etc/kave/toolbox_ok')
                                    and os.path.exists(params.top_dir +
                                                       '/KaveToolbox')):
            return True
        # configure first before installing, create custom install file and mirror file if necessary
        self.configure(env)
        if len(self.sttmpdir) < 4:
            raise IOError("where are you using for temp??")
        # Set up temporary directory for download/install
        Execute("mkdir -p " + self.sttmpdir)
        Execute("rm -rf " + self.sttmpdir + "/*")
        topdir = os.path.realpath(os.path.curdir)
        extraopts = ""
        if params.ignore_missing_groups:
            extraopts = " --ignore-missing-groups"
        kavetoolbox_path = '/KaveToolbox/' + params.releaseversion + 'scripts/KaveInstall'
        instscript = params.top_dir + kavetoolbox_path
        # no need to download if install script already exists
        if not os.path.exists(instscript):
            os.chdir(self.sttmpdir)
            kc.copy_cache_or_repo(package,
                                  arch='noarch',
                                  ver=params.releaseversion,
                                  dir="KaveToolbox")
            Execute('tar -xzf ' + package)
            # try to cope with the annoying way the tarball contains something with .git at the end!
            import glob

            for gits in glob.glob(self.sttmpdir + "/*.git"):
                if os.path.isdir(gits) and not gits.endswith("/.git"):
                    Execute('mv ' + gits + ' ' + gits[:-len(".git")])
            instscript = './KaveToolbox/scripts/KaveInstall'
        Execute("mkdir -p /etc/kave")
        Execute('chmod -R a+r /etc/kave')
        File("/etc/kave/CustomInstall.py",
             content=InlineTemplate(params.custom_install_template),
             mode=0644)

        commandlineargs = ""
        if params.command_line_args:
            commandlineargs = " " + params.command_line_args

        noexec_detected = 0
        if 'noexec' in subprocess.check_output(
                'if mountpoint -q /tmp; then mount | grep "/tmp "; fi',
                shell=True):
            noexec_detected = 1
            Execute("mount -o remount,exec /tmp")

        Execute(instscript + ' --' + self.kind + extraopts + commandlineargs,
                logoutput=True)
        os.chdir(topdir)
        Execute("rm -rf " + self.sttmpdir + "/*")
        Execute('touch /etc/kave/toolbox_ok')
        Execute(
            'yum -y install --setopt=retries=20 --setopt=timeout=60 python-pip'
        )
        Execute(
            'bash -c "source /opt/KaveToolbox/pro/scripts/KaveEnv.sh ;pip install --upgrade pip"'
        )
        Execute(
            'bash -c "source /opt/KaveToolbox/pro/scripts/KaveEnv.sh ; pip install lightning-python"'
        )
        File("/opt/KaveToolbox/pro/config/kave-env-exclude-users.conf",
             content=InlineTemplate(params.kave_env_excluded_users),
             mode=0644)
        File("/etc/profile.d/ktb_custom_env.sh",
             content=InlineTemplate(params.kave_custom_environment),
             mode=0644)
        # Restart salt minion service. Otherwise it fails because of some python package installs/upgrades required
        # by KaveToolbox
        salt_check = subprocess.Popen(
            'systemctl is-active --quiet salt-minion.service', shell=True)
        salt_check.wait()
        if int(salt_check.returncode) == 0:
            Execute('systemctl restart salt-minion.service')
        if noexec_detected:
            Execute("mount -o remount,noexec /tmp")
예제 #28
0
    def install(self, env):
        import params
        import kavecommon as kc

        package = 'kavetoolbox-' + params.releaseversion + '.tar.gz'
        Execute('yum clean all')
        self.install_packages(env)
        env.set_params(params)
        # no need to install if already installed ... does not work behind firewall after restart
        if self.kind == "node" and (os.path.exists('/etc/kave/toolbox_ok')
                                    and os.path.exists(params.top_dir + '/KaveToolbox')):
            return True
        # configure first before installing, create custom install file and mirror file if necessary
        self.configure(env)
        if len(self.sttmpdir) < 4:
            raise IOError("where are you using for temp??")
        # Set up temporary directory for download/install
        Execute("mkdir -p " + self.sttmpdir)
        Execute("rm -rf " + self.sttmpdir + "/*")
        topdir = os.path.realpath(os.path.curdir)
        extraopts = ""
        if params.ignore_missing_groups:
            extraopts = " --ignore-missing-groups"
        kavetoolbox_path = '/KaveToolbox/' + params.releaseversion + 'scripts/KaveInstall'
        instscript = params.top_dir + kavetoolbox_path
        # no need to download if install script already exists
        if not os.path.exists(instscript):
            os.chdir(self.sttmpdir)
            kc.copy_cache_or_repo(package, arch='noarch',
                                  ver=params.releaseversion,
                                  dir="KaveToolbox")
            Execute('tar -xzf ' + package)
            # try to cope with the annoying way the tarball contains something with .git at the end!
            import glob

            for gits in glob.glob(self.sttmpdir + "/*.git"):
                if os.path.isdir(gits) and not gits.endswith("/.git"):
                    Execute('mv ' + gits + ' ' + gits[:-len(".git")])
            instscript = './KaveToolbox/scripts/KaveInstall'
        Execute("mkdir -p /etc/kave")
        Execute('chmod -R a+r /etc/kave')
        File("/etc/kave/CustomInstall.py",
             content=InlineTemplate(params.custom_install_template),
             mode=0644
             )

        commandlineargs = ""
        if params.command_line_args:
            commandlineargs = " " + params.command_line_args

        noexec_detected = 0
        if 'noexec' in subprocess.check_output('if mountpoint -q /tmp; then mount | grep "/tmp "; fi', shell=True):
            noexec_detected = 1
            Execute("mount -o remount,exec /tmp")

        Execute(instscript + ' --' + self.kind + extraopts + commandlineargs,
                logoutput=True)
        os.chdir(topdir)
        Execute("rm -rf " + self.sttmpdir + "/*")
        Execute('touch /etc/kave/toolbox_ok')
        Execute('yum -y install --setopt=retries=20 --setopt=timeout=60 python-pip')
        Execute('bash -c "source /opt/KaveToolbox/pro/scripts/KaveEnv.sh ;pip install --upgrade pip"')
        Execute('bash -c "source /opt/KaveToolbox/pro/scripts/KaveEnv.sh ; pip install lightning-python"')
        File("/opt/KaveToolbox/pro/config/kave-env-exclude-users.conf",
             content=InlineTemplate(params.kave_env_excluded_users),
             mode=0644
             )
        File("/etc/profile.d/ktb_custom_env.sh",
             content=InlineTemplate(params.kave_custom_environment),
             mode=0644
             )
        # Restart salt minion service. Otherwise it fails because of some python package installs/upgrades required
        # by KaveToolbox
        salt_check = subprocess.Popen('systemctl is-active --quiet salt-minion.service', shell=True)
        salt_check.wait()
        if int(salt_check.returncode) == 0:
            Execute('systemctl restart salt-minion.service')
        if noexec_detected:
            Execute("mount -o remount,noexec /tmp")
예제 #29
0
    def install(self, env):
        import params

        env.set_params(params)
        self.install_packages(env)
        dlname = 'jenkins-' + str(params.download_version) + '-1.1.noarch.rpm'
        kc.copy_cache_or_repo(dlname, arch='noarch', alternates='http://pkg.jenkins-ci.org/redhat/' + dlname)
        Execute('rpm -qa | grep -qw jenkins || yum -y install ' + dlname)

        self.configure(env)
        # wget all requested plugins
        for plugin in params.plugins.split(','):
            plugin = plugin.strip()
            if not len(plugin):
                continue
            extsources = ["http://updates.jenkins-ci.org/latest/" + plugin + h for h in [".hpi", ".jpi"]]
            mirrorsources = []
            for mirror in kc.mirrors():
                mirrorsources = mirrorsources + \
                    [kc.repo_url('jenkins_plugins/' + plugin + h, arch='noarch', repo=mirror) for h in [".hpi", ".jpi"]]
            intsources = [kc.repo_url('jenkins_plugins/' + plugin + h, arch='noarch') for h in [".hpi", ".jpi"]]
            source = kc.failover_source(mirrorsources + intsources + extsources)
            dest = params.JENKINS_HOME + "/plugins/" + source.split('/')[-1]
            Execute(kc.copymethods(source, dest))

        Execute('mkdir -p /var/lib/jenkins/.ssl')
        cpath = "/var/lib/jenkins/.ssl"
        print str(cpath)
#         #Change to your company details
        country = "NA"
        state = "NA"
        locality = "NA"
        organization = "NA"
        organizationalun = "NA"
        if len(params.hostname) <= 64:
            commonname = params.hostname
        else:
            commonname = params.hostname.split(".", 1)[0]
        email = "*****@*****.**"
#         Optional
        password = "******"
        print "Generating key request"
#         #Generate a key
        Execute(str.format('openssl req -x509 -newkey rsa:4096' +
                           ' -passout pass:{} -keyout /var/lib/jenkins/.ssl/key.pem -out' +
                           ' /var/lib/jenkins/.ssl/cert.pem' +
                           ' -days 365 -subj "/C={}/ST={}/L={}/O={}/OU={}/CN={}/emailAddress={} ' +
                           '"', password, country, state, locality, organization, organizationalun, commonname, email))
#         #Import the key to pckc12
        Execute(str.format('openssl pkcs12 -inkey /var/lib/jenkins/.ssl/key.pem' +
                           ' -in /var/lib/jenkins/.ssl/cert.pem -export -out /var/lib/jenkins/.ssl/cert.p12' +
                           ' -passin pass:{} -passout pass:{}', password, password))
#         #Import keystore
        Execute(str.format('keytool -importkeystore -srckeystore /var/lib/jenkins/.ssl/cert.p12' +
                           ' -destkeystore /var/lib/jenkins/.ssl/jenkins.jks -srcstoretype pkcs12' +
                           ' -deststoretype JKS -srcstorepass {} -deststorepass {}', password, password))

        File(params.JENKINS_HOME + '/config.xml',
             content=Template("config.xml.j2"),
             mode=0644
             )
        kc.chown_r(params.JENKINS_HOME + '/config.xml', params.JENKINS_USER)
        Execute('chkconfig jenkins on')

        self.start(env)
        # using curl to create username password for jenkinsl
        curl_command = ('curl -k -d "username='******'&password1=' + params.JENKINS_ADMIN_PASSWORD
                        + '&email=' + params.JENKINS_ADMIN_EMAIL + '&password2='
                        + params.JENKINS_ADMIN_PASSWORD + '&fullname='
                        + params.JENKINS_ADMIN + '&Submit=Sign%20up" "https://'
                        + params.hostname + ':' + str(params.JENKINS_HTTPS_PORT) + '/securityRealm/createAccount"')
        try:
            Execute(curl_command)
        except Fail as ex:
            print "the curl command met with failure the first time,,,trying in another 60 secs"
            print ex
            import time
            time.sleep(60)
            Execute(curl_command)