自动安装与配置gitlab

#!/usr/bin/python
#-*- coding: UTF-8 -*-
import commands
import urllib2
import os
import sys
import subprocess
import time
print "-----------安装gitlab程序--------------"
def exec_cmd(cmd,timeout=-1):
    _p=subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
    if timeout >0:
        timer=Timer(timeout,_p.kill)
        timer.start()
        _stdout,_stderr=p.communicate()
        if time.is_alive:
            timer.cancel()
            ret={‘return_code‘: _p.returncode,‘stdout‘: _stdout,‘stderr‘: _stderr}
        else:
            ret={‘return_code‘: _p.returncode,‘stdout‘: ‘‘,‘stderr‘: _stderr}
    else:
        _stdout, _stderr = _p.communicate()
        ret={‘return_code‘: _p.returncode,‘stdout‘: _stdout,‘stderr‘: _stderr}
    return ret
#安装gitalb安装前的依赖软件    
def install():
    pakages=[‘openssh-server‘,‘epel-release‘,‘postfix‘,‘cronie‘,‘vim‘]
    print "Installing pakages"
    for each in pakages:
        command="yum -y install %s" % each
        ret=exec_cmd(command)
        if ret[‘return_code‘]!=0:
            print ‘pakage({0}) install failed,reason:{1}‘.format(each,ret[‘stderr‘])
            sys.exit(3)
        else:
            print ‘pakage({0}) install success,‘.format(each)
#做防火墙的
def command():
    command=‘sudo lokkit -s http -s ssh‘
    ret=exec_cmd(command)
    if ret[‘return_code‘]!=0:
        print "the %s excute failed" % command
    return True
#下载gitlab软件包
def download():
    print "-----------------upload gitlab packages------------------!!!!"
    url=‘http://192.168.100.127/gitlab-7.9.2_omnibus-1.el6.x86_64.rpm‘
    f=urllib2.urlopen(url)
    data=f.read()
    with open("/root/gitlab-7.9.2_omnibus-1.el6.x86_64.rpm","wb") as code:
        code.write(data)
    print "编译gitlab,此过程需要一段时间,请耐心等待"
    command1=‘sudo rpm -i gitlab-7.9.2_omnibus-1.el6.x86_64.rpm‘
    ret1=exec_cmd(command1)
    if ret1[‘return_code‘]!=0:
        print "the %s excute failed" % command1
    else:
        print "the %s excute success" % command1
    command2=‘gitlab-ctl reconfigure‘
    ret2=exec_cmd(command2)
    if ret2[‘return_code‘]!=0:
        print "the %s excute failed" % command2
    else:
        print "the %s excute success" % command2
#停掉服务,为了修改域名
    command3=‘gitlab-ctl stop‘
    ret3=exec_cmd(command3)
    if ret3[‘return_code‘]!=0:
        print "the %s excute failed" % command3
#调用alter_host函数    
    alter_host()
    command4=‘gitlab-ctl start‘
    ret4=exec_cmd(command4)
    if ret3[‘return_code‘] !=0:
        print "the %s excute failed" % command4
    return True
#修改邮箱的域名
def alter_host():
    host=commands.getoutput("ifconfig eth0|grep Bcast|awk ‘{print $2}‘|cut -d ‘:‘ -f 2")
    config_file=‘/var/opt/gitlab/gitlab-rails/etc/gitlab.yml‘
    command1=‘sed -i "s/gitlab.example.com/{0}/g" {1} ‘.format(host,config_file)
    ret1=exec_cmd(command1)
    if ret1[‘return_code‘]!=0:
        print "the % excute failed" % command1
    else:
        print "the command excute success"
install()
command()
download()
print "--------------安装完成--------------"
时间: 2024-10-10 13:05:56

自动安装与配置gitlab的相关文章

Linux无人值守自动安装详细配置流程

以下配置流程均在CentOS 6.7实现 实验环境: PXE + httpd + dhcp + tftp-server + kickstart 实现环境: PXE+httpd + dhcp + tftp-server + kickstart 简单介绍相关概念: PXE:是一种安装方式,支持通过网络引导,访问服务器的文件来安装系统,需要网卡支持 http:文件服务器,存放系统ISO文件 dhcp:实现客户机地址分配 tftp:存放PXE相关的文件的服务器 kickstart:是安装程序anacon

oracle 11g自动安装与配置

自动删除日志脚本文件下载地址: 链接:http://pan.baidu.com/s/1mg0EnQo    密码:4uit 数据库安装前的准备工作 [[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0  #配置IP地址 DEVICE=eth0 HWADDR=00:0C:29:59:6E:BF TYPE=Ethernet ONBOOT=yes BOOTPROTO=no IPADDR=172.16.2.20 NETM

docker安装与配置gitlab详细过程

1.打开网易镜像中心 https://c.163yun.com/hub#/m/home/ 2.搜索gitlab,获取下载地址.例如:docker pull hub.c.163.com/gutenye/gitlab-ce:latest 3.把镜像下载到linux中 4.将 GitLab 的配置 (etc) . 日志 (log) .数据 (data) 放到容器之外, 便于日后升级. mkdir -p /mnt/gitlab/etc mkdir -p /mnt/gitlab/log mkdir -p

ansible自动安装并配置ssh免密环境shell脚本

#!/bin/bash clearUSER=rootPASSWD=amunlinuxPUBDIR=/root/.sshcat > ~/prompt-ans.txt << EOF 如果需要配置服务器数量过多,最好在外部保存到ip-list文件内,易于美观 如果.ssh/ 下存在文件,需要删除后再次执行脚本,不想删除注释关键字即可 服务器密码需要统一 EOFcat ~/prompt-ans.txtsleep 4syum -y install ansible expect* which exp

Cobbler 自动安装 配置

自动化安装适用于IDC机房批量安装服务器: 现在我们的自动化安装的方法有两种:今天我们来实现一下Cobbler的配置: 1.PXE,这种配置起来比较麻烦: 2.Cobbler,这种批量安装的方法,也是基于PEX结构执行的,但是Cobbler省去了我们配置文件的步骤,都交给了Cobbler来完成: 1)安装软件:查看服务是否启动 [[email protected] ~]# yum install tftp-server rsync xinetd httpd dhcp [[email protec

centos6.5安装和配置cobbler

Cobbler介绍 Cobbler 是一个系统启动服务(boot server),可以通过网络启动(PXE)的方式用来快速安装.重装物理服务器和虚拟机,支持安装不同的 Linux 发行版和 Windows.该工具使用python开发,小巧轻便(才15k行代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理 DHCP,DNS,以及yum包镜像. Cobbler 使用命令行方式管理,也提供了基于 Web 的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发

P6 EPPM 安装与配置指南 16 R1 2016.4

   关于安装和 配置P6 EPPM 本指南告诉你如何自动 安装和配置您的应用程序. 在您开始之前,阅读 先决条件 P6 EPPM配置 (7页). 安装P6 EPPM 您将使用 安装程序 (窗口) ./ runinstaller (对于Linux或UNIX)白桃花心木P6企业项目组合管理 物理介质或下载安装以下P6 EPPM应用程序: 请注意 :你不需要安装 应用程序,你可以选择你安装什么. 然而,您必须安装 P6运行其他P6 EPPM应用程序. 4 P6(和它的帮助和教程) 4 P6团队成员接

FastDFS 自动部署和配置脚本

写了一个自动安装和配置FastDFS的脚本,还没有写好关于nginx的配置.先贴上,如下: 自动安装FastDFS,(这部分是之前同事写好的) #!/bin/bash #instll gcc echo "================== install gcc ==================" cd ./gccRpm ./gccInstall.sh cd .. echo "================== gcc installed ==============

转载CI系统搭建二、Gitlab的安装和配置

博客转载于longgeek.com, 地址 http://longgeek.com/2013/12/26/ci-system-structures-ii-gitlab-installation/#i-4. 我在自己电脑上安装了这个gitLab,亲自测试过博客中描述的步骤很全.其中 域名如果没有替换为自己本地的地址,需要带上端口号.其中端口号为8081 上一篇文章 CI 系统搭建:一. 基础环境设置.规划 大概规划了下环境,本文主要用来记录安装 Gitlab 的过程,主要参考官方文档 并没有做太多