ゆるふわエンジニアのブログ

行ったこと、調べたこと等をつらつらと書いていくかもしれません。

GitLabのインストール(CentOS)

GitLabのインストール方法について紹介していきます。
今回紹介する内容は、下記URLの内容和訳したものに、
私がハマった部分についてを加えたものとなっています。
about.gitlab.com

内容のお品書きは下記の通りです。

  1. インストール環境(OS)
  2. インストール方法
  3. GitLabのreconfigureに失敗したら

それでは、見ていきましょう。


1. インストール環境(OS)
CentOS6.7 64bit(仮想環境)です。
以降紹介する方法はすべて、git_testユーザでログインした後に
スーパユーザモードへ切り替えて操作していますので、ご了承ください。

2. インストール方法
SSHのクライアント、サーバとメール送信用のpostfix、cronをインストールします。

[root@localhost git_test]# yum -y install curl openssh-server openssh-clients postfix cronie


postfixのサービスを起動させ、その後自動起動するように設定を変更します。

[root@localhost git_test]# service postfix start
[root@localhost git_test]# chkconfig postfix on


iptables(firewall)へルールを追加します。

[root@localhost git_test]# lokkit -s http -s ssh


GitLabのパッケージを取得し、インストールします。

[root@localhost git_test]# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
[root@localhost git_test]# yum -y install gitlab-ce


設定を適用します。

[root@localhost git_test]# gitlab-ctl reconfigure

これで、インストールについては終了です。
http://ホスト名またはIPアドレス/
または
http://ホスト名またはIPアドレス:ポート番号/
へアクセスできるか確認しましょう。

3. GitLabのreconfigureに失敗したら
gitlab-ctl reconfigureコマンドを実行した時に下記の様なメッセージが出力され、
失敗することがあります。

Running handlers:
[2016-01-24T17:19:24+09:00] ERROR: Running exception handlers
Running handlers complete
[2016-01-24T17:19:24+09:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 05 seconds
[2016-01-24T17:19:24+09:00] FATAL: Stacktrace dumped to /opt/gitlab/embedded/cookbooks/cache/chef-stacktrace.out
[2016-01-24T17:19:24+09:00] ERROR: user[git] (gitlab::users line 38) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '8'
---- Begin output of ["usermod", "-s", "/bin/sh", "-d", "/var/opt/gitlab", "git"] ----
STDOUT: 
STDERR: usermod: user git is currently used by process 1804
---- End output of ["usermod", "-s", "/bin/sh", "-d", "/var/opt/gitlab", "git"] ----
Ran ["usermod", "-s", "/bin/sh", "-d", "/var/opt/gitlab", "git"] returned 8
[2016-01-24T17:19:25+09:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)


出力されたメッセージを遡ってみて、下記の様なメッセージが出力されていたら
多分、先にgitユーザを作成してしまっている事が原因で失敗しています。
gitユーザを削除した後にgitlab-ctl reconfigureコマンドを実行してください。
(私の環境の場合、gitユーザの削除で上手くいきました。)

Recipe: gitlab::users
  * directory[/var/opt/gitlab] action create (up to date)
  * group[git] action create
    - alter group git
    - replace group members with new list of members
  * user[git] action create
    
    ================================================================================
    Error executing action `create` on resource 'user[git]'
    ================================================================================