Gitlab搭建社区版
参考地址:https://zhuanlan.zhihu.com/p/62042884
其中gitlab资源包地址显示不全,可使用浏览器下载到本地再拷到服务器
最后搭建完成会出现访问不了,需关闭防火墙
systemctl disable firewalld
#重启
reboot
配置ldap
Gitlab搭建完成后配置ldap
1.打开配置文件
vi /etc/gitlab/gitlab.rb
2.找到LDAP Setting
里面提供了例子,没有改里面的例子,直接在后面添加配置
gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
main: # 'main' is the GitLab 'provider ID' of this LDAP server
label: 'LDAP'
host: 'xxxxx'
port: 389
uid: 'uid'
bind_dn: 'cn=admin,c=cn'
password: 'xxxxx'
encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
verify_certificates: true
active_directory: false
allow_username_or_email_login: true
lowercase_usernames: false
block_auto_created_users: false
base: 'c=cn'
user_filter: ''
attributes:
username: ['uid', 'userid', 'sAMAccountName']
email: ['mail', 'email', 'userPrincipalName']
name: 'cn'
first_name: 'givenName'
last_name: 'sn'
EOS
当前搭建的LDAP服务如下
(1)host,是搭建的openldap的ip,根据实际情况修改;
(2)uid,根据实际情况填uid或者cn等,应该会根据这个属性来取到所有可用的用户;
(3)bind_dn,openldap的管理员账号,根据实际情况修改;
(4)password,openldap的管理员,根据实际情况修改;
(5)active_directory,似乎是针对连接是否是ad域控的标示,因为这部分是openldap的配置,故为false;
(6)allow_username_or_email_login,用户登录是否用户名和邮箱都可以,方便用户故配置true;
(7)base,用户列表所在的目录
编辑完成保存退出
3.重新加载配置
gitlab-ctl reconfigure
运行后最后一行为“gitlab Reconfigured!”才说明是加载新配置成功,否则就是根据报错信息找错误
4.查看是否能正常获取用户列表
gitlab-rake gitlab:ldap:check
正常连接的情况下执行之后能看到用户的列表
5.重启gitlab
gitlab-ctl restart
6.重启成功后浏览器登录显示LDAP登录选项,即可使用ldap账户登录,原有的管理员账户使用standard方式进行登录