GitLab Cookbook with SSL

13226 단어 GitLabchefVagrantAWS
GitLab 설치가 쉬워졌습니다. GitLab Omnibus에서도 사용됩니다.
Cookbook SSL이 설정된 GitLab을 쉽게 설치할 수 있습니다.

Prepare



먼저 マシンドメイン証明書를 준비합니다.

기계



AWS 또는 사쿠라 VPS 등으로 공용으로 기계를 만듭니다.
(이번 OSUbuntu 12.04를 사용합니다.)

SSH



로컬 및 원격 SSH를 설정합니다. 원격 암호 인증을 금지하려면sshd_config에서 PasswordAuthenticationno로 편집합니다.
$ ssh [email protected] mkdir .ssh
$ scp ~/.ssh/id_rsa.pub [email protected]:.ssh/authorized_keys
$ cat << __EOS__ >> ~/.ssh/config
Host example.com
  User ubuntu
  IdentityFile ~/.ssh/id_rsa
__EOS__
$ ssh example.com
ubuntu@example:~$ sudo editor /etc/ssh/sshd_config
ubuntu@example:~$ sudo service ssh restart

도메인



이름.com, 도레지 등으로 도메인을 가져옵니다.
(DNS 설정에서 SPF 레코드을 등록합시다.)

Sender Policy Framework


nslookup 명령으로 TXT 레코드를 확인합니다.
$ nslookup -q=txt example.com
Server:   192.168.0.1
Address:  192.168.0.1#53

Non-authoritative answer:
example.com text = "v=spf1 ip4:93.184.216.119 -all"

Certificate



사이버 트러스트BIZCERT 등으로 서버 증명서를 취득합니다.
(이번에는 자기 서명 증명서를 이용합니다.)

Self-signed certificate


openssl 명령으로 자체 서명 인증서(올레올레 인증서)를 만듭니다.
$ openssl genrsa -out server.key 2048
$ openssl req -new -key server.key -out server.csr
$ openssl rsa -in server.key -out server.key
$ openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
秘密鍵証明書 파일은 나중에 사용할 수 있습니다.


Files
내용
보충


server.key
RSA PRIVATE KEY
비밀키

server.csr
CERTIFICATE REQUEST
인증서 서명 요청

server.crt
CERTIFICATE
증명서


Delivered



Chef Solo



다음은 Chef 도구로 GitLab을 설치합니다.

Download



설치에는 knife-soloBerkshelf을 사용합니다.
$ gem install berkshelf
$ gem install knife-solo
$ knife configure
$ knife solo init ./gitlab_chef
$ cd ./gitlab_chef/
$ curl -o Berksfile https://gitlab.com/gitlab-org/cookbook-gitlab/raw/master/Berksfile
$ sed -i.bak '/^metadata$/d' Berksfile
$ echo "cookbook 'gitlab', git: 'https://gitlab.com/gitlab-org/cookbook-gitlab.git'" >> Berksfile
$ berks vendor

Provision


ssl_certificatessl_certificate_key에서 証明書秘密鍵의 내용을 편집합니다. (개행은 \n입니다.)knife solo 명령이 GitLab을 설치합니다.
$ cat << __EOS__ > ./nodes/example.com.json
{
  "gitlab": {
    "host": "example.com",
    "port": "443",
    "email_from": "[email protected]",
    "url": "https://git.example.com/",
    "ssl_certificate": "-----BEGIN CERTIFICATE-----\nfoo\nbar\nbaz\n-----END CERTIFICATE-----",
    "ssl_certificate_key": "-----BEGIN RSA PRIVATE KEY-----\nqux\nquux\ncorge\n-----END RSA PRIVATE KEY-----"
  }
  "run_list": [
    "gitlab::default"
  ]
}
__EOS__
$ knife solo prepare example.com --bootstrap-version 11.4.4
$ knife solo cook example.com

Self-signed certificate



자체 서명 인증서는 config.ymlself_signed_certtrue로 편집합니다.
$ ssh example.com
ubuntu@example:~$ sudo editor /home/git/gitlab-shell/config.yml

메일(SMTP)



Postfix



메일을 보낼 때 Postfix를 사용합니다. main.cf를 편집하고 다시 시작합니다.
$ ssh example.com
ubuntu@example:~$ sudo apt-get install postfix
ubuntu@example:~$ sudo editor /etc/postfix/main.cf
ubuntu@example:~$ sudo service postfix restart

Gitlab


production.rbconfig.action_mailer.delivery_method = :sendmail다음 줄에 다음 config.action_mailer.sendmail_settings를 추가합니다.
config.action_mailer.sendmail_settings = {
  location: '/usr/sbin/sendmail',
  arguments: '-i -t'
}
production.rb를 편집하고 다시 시작합니다.
$ ssh example.com
ubuntu@example:~$ sudo editor /home/git/gitlab/config/environments/production.rb
ubuntu@example:~$ sudo service gitlab restart

Inspect



새 사용자를 만들고 프로젝트를 만듭니다.
추가 공개 키를 추가하면 세 개의 이메일이 수신됩니다.


Actions
메일 Subject


New User
Account was created for you

새로운 프로젝트
Access to project was granted

Add SSH Key
SSH key was added to your account


이것으로 올레올레 GitLab이 완성됩니다.

logo-black

Tips



Vagrant



VagrantAmazon EC2은 GitLab을 더 쉽게 설치할 수 있습니다.

Download


Vagrantfile, access_key_id, secret_access_key, private_key_pathkeypair_name를 편집합니다.
$ gem install berkshelf
$ vagrant plugin install vagrant-berkshelf
$ vagrant plugin install vagrant-omnibus
$ vagrant plugin install vagrant-aws
$ vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
$ git clone https://gitlab.com/gitlab-org/cookbook-gitlab.git ./gitlab
$ cd ./gitlab/
$ cp ./example/Vagrantfile_aws ./Vagrantfile
$ editor ./Vagrantfile

Provision


Vagrantfilechef.json 또는 chef.run_listChef Solo와 동일하게 편집합니다.vagrant provision 명령이 GitLab을 설치합니다.
$ vagrant up --provider=aws
$ eval $(vagrant ssh-config | awk '/HostName/ {print "HostName=" $2}')
$ sed -i.bak "s/example.com/$HostName/g" Vagrantfile
$ sed -i.bak 's/chef.run_list = \[\]/chef.run_list = \["gitlab::default"\]/g' Vagrantfile
$ vagrant provision

GitLab.org Production도 참조하십시오.

좋은 웹페이지 즐겨찾기