先奉上Gitlad 与AD域集成,后续将继续奉上Nexus、Jenkinsyu AD域的集成记录。
如果您觉得有用请点个攒。
查询容器信息
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6e64e00ea1c4 nginx:1.19 "/docker-entrypoint.…" 4 months ago Up 7 days 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp home_nginx_1
2963b288d9c1 jenkins/jenkins:lts "/sbin/tini -- /usr/…" 4 months ago Up 7 days 8080/tcp, 0.0.0.0:50000->50000/tcp home_jenkins_1
51fe3007b697 gitlab/gitlab-ce:latest "/assets/wrapper" 4 months ago Up 7 days (healthy) 80/tcp, 443/tcp, 0.0.0.0:2222->22/tcp home_gitlab_1
584b3e776dbd sonatype/nexus3 "sh -c ${SONATYPE_DI…" 4 months ago Up 7 days 0.0.0.0:8080->8080/tcp, 0.0.0.0:8082->8082/tcp, 8081/tcp home_nexus_1
进入Git容器
[root@localhost ~]# docker exec -it 51fe3007b697 /bin/bash
root@git:/#
编辑git配置文件
root@git:/# vim /etc/gitlab/gitlab.rb
我的配置文件关于LDAP的配置大约在430行,供大家参考。也可以直接搜索,shift+? 输入:ldap_enabled,进行搜索定位,如果你使用的微软AD域,添加如下配置:
gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
main: # 'main' is the GitLab 'provider ID' of this LDAP server
label: 'AD域'
host: '192.168.100.1'
port: 389
uid: 'cn'
bind_dn: 'cn=admin,cn=Users,dc=xxxx,dc=com'
password: 'zxhN*XXASASARFGGGx*!3Kxt'
encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
verify_certificates: true
smartcard_auth: false
active_directory: true
allow_username_or_email_login: true
lowercase_usernames: false
block_auto_created_users: false
base: 'ou=产品研发中心,dc=xxxx,dc=com'
user_filter: ''
## EE only
group_base: ''
admin_group: ''
sync_ssh_keys: false
其中的 label: 'AD域' 定义了登录页的标题,可以按需修改,效果如下图:
重载配置文件:
gitlab-ctl reconfigure
看到如下提示,标识顺利完成
Running handlers:
Running handlers complete
Chef Infra Client finished, 4/742 resources updated in 14 seconds
gitlab Reconfigured!
重启git服务
gitlab-ctl restart
测试ad配置
root@git:/# gitlab-rake gitlab:ldap:check
Checking LDAP ...
LDAP: ... Server: ldapmain
LDAP authentication... Success
LDAP users with access to your GitLab server (only showing the first 100 results)
DN: cn=test1,ou=产品研发中心,dc=xxxx,dc=com cn: test1
DN: cn=gittest,ou=产品研发中心,dc=xxxx,dc=com cn: gittest
DN: cn=test,ou=产品研发中心,dc=xxxx,dc=com cn: test
Checking LDAP ... Finished
回到git登录页面使用测试账户登录,成功。