当前位置:   article > 正文

Android下的配置管理之道之Centos7安装配置gitlab_qwerty461

qwerty461

#ubuntu 安装gitlab

使用清华大学gitlab的镜像https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/
  • 1
curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null
vi /etc/yum.repos.d/gitlab-ce.repo
  • 1
  • 2
[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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
sudo yum makecache
sudo yum install gitlab-ce
  • 1
  • 2
然后打开/etc/gitlab/gitlab.rb,将external_url = 'http://xxx.xxx.com'
修改为自己的IP地址或者自己的域名,然后编译,这里会用chef来进行,sudo gitlab-ctl reconfigure
这样如果没有报错就是安装完成了
  • 1
  • 2
  • 3

#配置ldap登录

### LDAP Settings
###! Docs: https://docs.gitlab.com/omnibus/settings/ldap.html
###! **Be careful not to break the indentation in the ldap_servers block. It is
###!   in yaml format and the spaces must be retained. Using tabs will not work.**
gitlab_rails['ldap_enabled'] = true
###! **remember to close this block with 'EOS' below**
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
    main: # 'main' is the GitLab 'provider ID' of this LDAP server
     label: 'LDAP'
     host: 'xx.xx.xx.xx'
     port: 389
     uid: 'sAMAccountName'
     bind_dn: 'cn=username,cn=Users,dc=xxx,dc=com'
     password: 'password'
     encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
     verify_certificates: true
     ca_file: ''
     ssl_version: ''
     active_directory: true
     allow_username_or_email_login: false
     block_auto_created_users: false
     base: 'dc=xxx,dc=com'
     user_filter: ''
     attributes:
       username: ['uid', 'userid', 'sAMAccountName']
       email:    ['mail', 'email', 'userPrincipalName']
       name:       'cn'
       first_name: 'givenName'
       last_name:  'sn'
#     ## EE only
#     group_base: ''
#     admin_group: ''
#     sync_ssh_keys: false
#
#   secondary: # 'secondary' is the GitLab 'provider ID' of second LDAP server
#     label: 'LDAP'
#     host: '_your_ldap_server'
#     port: 389
#     uid: 'sAMAccountName'
#     bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
#     password: '_the_password_of_the_bind_user'
#     encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
#     verify_certificates: true
#     ca_file: ''
#     ssl_version: ''
#     active_directory: true
#     allow_username_or_email_login: false
#     block_auto_created_users: false
#     base: ''
#     user_filter: ''
#     attributes:
#       username: ['uid', 'userid', 'sAMAccountName']
#       email:    ['mail', 'email', 'userPrincipalName']
#       name:       'cn'
#       first_name: 'givenName'
#       last_name:  'sn'
#     ## EE only
#     group_base: ''
#     admin_group: ''
#     sync_ssh_keys: false
EOS
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61

   @Test
   public void test() {
       String username = "mage";
       String password = "mage";
       Properties env = new Properties();
       String ldapURL = "LDAP://10.10.103.151:389";//ip:port
       env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
       env.put(Context.SECURITY_AUTHENTICATION, "simple");//"none","simple","strong"
       env.put(Context.SECURITY_PRINCIPAL, "公司域名\\"+ username);
       env.put(Context.SECURITY_CREDENTIALS, password);
       env.put(Context.PROVIDER_URL, ldapURL);
       try {
           LdapContext ctx = new InitialLdapContext(env, null);

           SearchControls searchCtls = new SearchControls();
           searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
           //String searchFilter = "(&(objectCategory=person)(objectClass=user)(name=*))";
           String searchFilter = "sAMAccountName=" + username;//这里过滤器,这样写 只会有这个账号的一些信息被搜到
           String searchBase = "OU=公司群组名称,OU=公司群组名称,DC=公司域名,DC=com";
           NamingEnumeration<SearchResult> answer = ctx.search(searchBase, searchFilter, searchCtls);
           while (answer.hasMoreElements()) {
               SearchResult sr = (SearchResult) answer.next();//这里就是搜到的用户的信息。
               System.out.println(sr.getName());
           }
           ctx.close();
       } catch (NamingException e) {
           e.printStackTrace();
       }
   }

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
ldapsearch -vvv -LLL -H ldap://ldapip -b "dc=test,dc=com"  -D 'cn=账号,OU=系统账号,OU=xxxx科技有限公司,dc=test,dc=com' -w密码

xxxx科技有限公司  这个是在ad域里面分的一个目录,这个目录和默认的Users那个目录同级的。
系统账号  这个是 公司 下面分的一个子目录。
dc 一般是公司域名。
  • 1
  • 2
  • 3
  • 4
  • 5
ldapsearch -vvv -LLL -H ldap://ldapip -b "dc=test,dc=com"  -D 'cn=账号,cn=Users,dc=test,dc=com' -w密码

这里的Users就是 在ad域里面的那个默认的组






  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

#centos 安装gitlab

  1. Install and configure the necessary dependencies
sudo yum install -y curl openssh-server openssh-clients cronie
sudo lokkit -s http -s ssh


  • 1
  • 2
  • 3
  • 4
  1. Add the GitLab package server and install the package
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo yum install -y gitlab-ce


  • 1
  • 2
  • 3
  • 4
  1. Configure and start GitLab
sudo gitlab-ctl reconfigure

  • 1
  • 2
ldapsearch -vvv -LLL -H ldap://10.0.13.251 -b "dc=example,dc=com"  -D 'CN=gitlab,OU=系统账号,DC=example,DC=com' -wxxxxpassword

/etc/gitlab/gitlab.rb 

## Url on which GitLab will be reachable.
## For more details on configuring external_url see:
## https://gitlab.com/gitlab-org/omnibus-gitlab/blob/629def0a7a26e7c2326566f0758d4a27857b52a3/README.md#configuring-the-external-url-for-gitlab
external_url 'http://10.0.63.31'



## Note: configuration settings below are optional.
## Uncomment and change the value.
############################
# gitlab.yml configuration #
############################

# gitlab_rails['gitlab_ssh_host'] = 'ssh.host_example.com'
# gitlab_rails['time_zone'] = 'UTC'
# gitlab_rails['gitlab_email_enabled'] = true
# gitlab_rails['gitlab_email_from'] = 'example@example.com'
# gitlab_rails['gitlab_email_display_name'] = 'Example'
# gitlab_rails['gitlab_email_reply_to'] 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/720926
推荐阅读
相关标签
  

闽ICP备14008679号