• 自动化部署三剑客 gitlab + ansible + jenkins


    http://www.showerlee.com/archives/1880
    
    https://edu.51cto.com/center/course/lesson/index?id=280700
    

    GitLab 搭建

    配置国内 yum 源
    
    网易(163)yum源是国内最好的yum源之一 ,无论是速度还是软件版本,都非常的不错,将yum源设置为163yum,可以提升软件包安装和更新的速度,同时避免一些常见软件版本无法找到。具体设置方法如下:
    1,进入yum源配置目录
    cd /etc/yum.repos.d
    2,备份系统自带的yum源
    mv CentOS-Base.repo CentOS-Base.repo.bk
    下载163网易的yum源:
    wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
    3,更新玩yum源后,执行下边命令更新yum配置,使操作立即生效
    yum makecache
    4,除了网易之外,国内还有其他不错的yum源,比如中科大和搜狐的,大家可以根据自己需求下载
    中科大的yum源:
    wget http://centos.ustc.edu.cn/CentOS-Base.repo
    sohu的yum源
    wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
    
    仍然不够 , 修改 gitlab-ce 的 仓库地址为国内源
    
    vim /etc/yum.repos.d/gitlab-ce.repo   并添加 如下
    
    [gitlab-ce]
    name=gitlab-ce
    baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
    repo_gpgcheck=0
    gpgcheck=0
    enabled=1
    gpgkey=https://packages.gitlab.com/gpg.key
    
    --------------------- 
    
    
    sudo su as root, 
    
    yum install curl policycoreutils openssh-server openssh-clients postfixs
    
    curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
    
    开启 邮件服务
    systemctl start postfix
    systemctl enable postfix
    
    安装  gitlab 社区版本 yum 一键安装包
    
    yum -y install  gitlab-ce   (这一步 如果下载速度很慢,建议回到上面讲解地方 依照方法修改 repo地址)
    
    mkdir -p /etc/gitlab/ssl
    创建 本地 私有密钥
    openssl genrsa -out "/etc/gitlab/ssl/gitlab.example.com.key" 2048
    
    使用 私有密钥 创建 ssl 证书
     
    openssl req -new -key "/etc/gitlab/ssl/gitlab.example.com.key" -out "/etc/gitlab/ssl/gitlab.example.com.csr"
    
    country: cn
    city: cs
    org name:  空格
    Common Name: 输入 gitlab.example.com
    email addr:  admin@example.com
    
    password: 123456
    optional company name: 回车
    
    去下面 目录 ll /etc/gitlab/ssl/  查看 私有密钥以及证书是否创建好
    
    接下来 指定证书格式 , 有效期限 365 天
    本地 签署证书 
    
    openssl x509 -req -days 365 -in "/etc/gitlab/ssl/gitlab.example.com.csr" -signkey "/etc/gitlab/ssl/gitlab.example.com.key" -out "/etc/gitlab/ssl/gitlab.example.com.crt"
    
    创建 pem 证书
    
    openssl dhparam -out /etc/gitlab/ssl/dhparams.pem 2048
    
    再次查看 pem 证书是否创建成功 ll
    
    开始配置 gitlab 服务端 ,引入 上面的 配置 
    
    vi /etc/gitlab/gitlab.rb
    
    修改 external_url 把  https 改为 http
    修改 redirect_http_to_https   将 注释 删除 改为 true
    修改 ssl_certificate 改为 /etc/gitlab/ssl/gitlab.example.com.crt
    修改 ssl_certificate_key 改为 /etc/gitlab/ssl/gitlab.example.com.key
    修改 ssl_dhparam 为 /etc/gitlab/ssl/dhparams.pem
    
    :x! 
    
    gitlab-ctl reconfigure
    
    
    vi /var/opt/gitlab/nginx/conf/gitlab-http.conf
    
    找到 /server_name
    在 它下面 
    rewrite ^(.*)$ https://$host$1 permanent
    gitlab-ctl restart
    
    
    修改 本机 hosts 文件 不是 gitlab 服务器哦
    将 192.168.0.17 gitlab.example.com
    
    在 win 平台 打开浏览器输入
    http://gitlab.example.com
    
    第一次 登陆 修改密码
    第二次 用 修改完的 密码 进行登陆
    并在页面上 创建 project  test-repo (这步实在天简单就不写了)
    
    git -c httpp.sslVerify=false clone https://gitlab.example.com/root/test-repo.git
    
    账号 密码 
    
    touch  test.py
    git add .
    git commit
    git -c http.sslVerify=false push origin master
    
    
    
    
    

    ansible 采用源码安装

    http://www.ansible.com.cn/
    
    git clone https://github.com/ansible/ansible.git
    
    

    如果有来生,一个人去远行,看不同的风景,感受生命的活力。。。
  • 相关阅读:
    程序员要善于在工作中找到偷懒的办法
    关于count(1) 和 count(*)
    前端设计+程序开发那点事
    关于MySQL Connector/C++那点事儿
    windows下编译php5.2.17这是闹哪样?
    easyui使用时出现这个Uncaught TypeError: Cannot read property 'combo' of undefined
    视频文件自动转rtsp流
    Jenkins Pipeline如何动态的并行任务
    Jenkins的Dockerfile中如何批量迁移原Jenkins安装的插件
    Groovy中json的一些操作
  • 原文地址:https://www.cnblogs.com/Frank99/p/10864211.html
Copyright © 2020-2023  润新知