ときどきAnsible日記

主にITインフラ基盤の自動化に関する事を書いているブログです

GitでPlaybookを管理したい~GitLabインストール失敗編→のち成功~

お疲れ様です。伊藤です。

注 今回は失敗編なので正解が見たい方は読み飛ばしてください。まだ正解は見つかってませんが。。。→その後リベンジしました。最下部に追記しております。

Ansibleによる自動化環境を検討していますが、Playbookを運用する際に困るのがバージョン管理です。修正を繰り返しているうちにどのPlaybookが最新かわかんなくなった!というのでは本末転倒。既存のCVSやSubvertionでは芸がないので調べてみるとAnsibleと相性が良いのはGitである、とさまざまなところで書いてますね。。GitHubなんかはよく聞くのですが実際は使ったことがない。。。というわけで今回の記事です。


GitHubはGitを使ってインターネット上にソースをアップロードして世界中で共有しようという仕組みかと思います。現実的にはそんな世界中に公開したくない、という方がほとんどかと思いますので、ローカルでできる仕組みを探してみます。で、出てきたのがGitLabとGitBucket。
企業で開発しているのがGitLab、個人でやっているのがGitBucket...なんとなくGitLabを選んでみます。


というわけで下記のURLに飛んでGitLabをインストールします。
about.gitlab.com

下記のような画面が出ますのでCentOS7を選択
f:id:pj_doaa:20170829124421p:plain


そうするとインストール手順が出ます。最初に出てくる
1. Install and configure the necessary dependencies
についてはsshのインストールと設定を行っているようなのでスルー

続いて
2. Add the GitLab package server and install the package
で実際のインストールを行います。まずはインストール用のスクリプトを実行。

[root@RHEL7 ~]# curl -sS https://packages.gitlab.com/install/repositories/gitlab /gitlab-ce/script.rpm.sh | sudo bash
Detected operating system as rhel/7.
Checking for curl...
Detected curl...
Downloading repository file: https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/config_file.repo?os=rhel&dist=7&source=script
done.
Installing pygpgme to verify GPG signatures...
読み込んだプラグイン:product-id, search-disabled-repos, subscription-manager
This system is registered to Red Hat Subscription Management, but is not receiving updates. You can use subscription-manager to assign subscriptions.

*** WARNING ***
The subscription for following product(s) has expired:
  - MRG Realtime
  - Oracle Java (for RHEL Client)
  - Oracle Java (for RHEL Server)
  - Oracle Java (for RHEL Server) - Extended Update Support
  - Oracle Java (for RHEL Workstation)
  - Red Hat Beta
  - Red Hat Container Development Kit
  - Red Hat Container Images
  - Red Hat Container Images Beta
  - Red Hat Developer Toolset (for RHEL Server EUS)
  - Red Hat Developer Toolset (for RHEL Server)
  - Red Hat Developer Toolset (for RHEL Workstation)
  - Red Hat Enterprise Linux Desktop
  - Red Hat Enterprise Linux High Availability (for RHEL Server)
  - Red Hat Enterprise Linux High Availability (for RHEL Server) - Extended Update Support
  - Red Hat Enterprise Linux High Performance Networking (for RHEL Server)
  - Red Hat Enterprise Linux High Performance Networking (for RHEL Server) - Extended Update Support
  - Red Hat Enterprise Linux Load Balancer (for RHEL Server)
  - Red Hat Enterprise Linux Load Balancer (for RHEL Server) - Extended Update Support
  - Red Hat Enterprise Linux Resilient Storage (for RHEL Server)
  - Red Hat Enterprise Linux Resilient Storage (for RHEL Server) - Extended Update Support
  - Red Hat Enterprise Linux Scalable File System (for RHEL Server)
  - Red Hat Enterprise Linux Scalable File System (for RHEL Server) - Extended Update Support
  - Red Hat Enterprise Linux Server
  - Red Hat Enterprise Linux Server - Extended Update Support
  - Red Hat Enterprise Linux Workstation
  - Red Hat Enterprise Linux for Real Time
  - Red Hat Software Collections (for RHEL Client)
  - Red Hat Software Collections (for RHEL Server)
  - Red Hat Software Collections (for RHEL Workstation)
  - Red Hat Software Collections Beta (for RHEL Client)
  - Red Hat Software Collections Beta (for RHEL Server)
  - Red Hat Software Collections Beta (for RHEL Workstation)
  - dotNET on RHEL (for RHEL Server)
  - dotNET on RHEL (for RHEL Workstation)
  - dotNET on RHEL Beta (for RHEL Server)
  - dotNET on RHEL Beta (for RHEL Workstation)
You no longer have access to the repositories that provide these products.  It is important that you apply an active subscription in order to resume access to security and other critical updates. If you don't have other active subscriptions, you can renew the expired subscription.  
gitlab_gitlab-ce-source/signature                        |  836 B     00:00     
https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey から鍵を取得中です。
Importing GPG key 0xE15E78F4:
 Userid     : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
 Fingerprint: 1a4c 919d b987 d435 9396 38b9 1421 9a96 e15e 78f4
 From       : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg から鍵を取得中です。
gitlab_gitlab-ce-source/signature                        |  951 B     00:00 !!! 
gitlab_gitlab-ce-source/primary                    0.0 B/s |    0 B   00:01     gitlab_gitlab-ce-source/primary                            |  175 B   00:01     
何もしません
Installing yum-utils...
読み込んだプラグイン:product-id, search-disabled-repos, subscription-manager
This system is registered to Red Hat Subscription Management, but is not receiving updates. You can use subscription-manager to assign subscriptions.

*** WARNING ***
The subscription for following product(s) has expired:
  - MRG Realtime
  - Oracle Java (for RHEL Client)
  - Oracle Java (for RHEL Server)
  - Oracle Java (for RHEL Server) - Extended Update Support
  - Oracle Java (for RHEL Workstation)
  - Red Hat Beta
  - Red Hat Container Development Kit
  - Red Hat Container Images
  - Red Hat Container Images Beta
  - Red Hat Developer Toolset (for RHEL Server EUS)
  - Red Hat Developer Toolset (for RHEL Server)
  - Red Hat Developer Toolset (for RHEL Workstation)
  - Red Hat Enterprise Linux Desktop
  - Red Hat Enterprise Linux High Availability (for RHEL Server)
  - Red Hat Enterprise Linux High Availability (for RHEL Server) - Extended Update Support
  - Red Hat Enterprise Linux High Performance Networking (for RHEL Server)
  - Red Hat Enterprise Linux High Performance Networking (for RHEL Server) - Extended Update Support
  - Red Hat Enterprise Linux Load Balancer (for RHEL Server)
  - Red Hat Enterprise Linux Load Balancer (for RHEL Server) - Extended Update Support
  - Red Hat Enterprise Linux Resilient Storage (for RHEL Server)
  - Red Hat Enterprise Linux Resilient Storage (for RHEL Server) - Extended Update Support
  - Red Hat Enterprise Linux Scalable File System (for RHEL Server)
  - Red Hat Enterprise Linux Scalable File System (for RHEL Server) - Extended Update Support
  - Red Hat Enterprise Linux Server
  - Red Hat Enterprise Linux Server - Extended Update Support
  - Red Hat Enterprise Linux Workstation
  - Red Hat Enterprise Linux for Real Time
  - Red Hat Software Collections (for RHEL Client)
  - Red Hat Software Collections (for RHEL Server)
  - Red Hat Software Collections (for RHEL Workstation)
  - Red Hat Software Collections Beta (for RHEL Client)
  - Red Hat Software Collections Beta (for RHEL Server)
  - Red Hat Software Collections Beta (for RHEL Workstation)
  - dotNET on RHEL (for RHEL Server)
  - dotNET on RHEL (for RHEL Workstation)
  - dotNET on RHEL Beta (for RHEL Server)
  - dotNET on RHEL Beta (for RHEL Workstation)
You no longer have access to the repositories that provide these products.  It is important that you apply an active subscription in order to resume access to security and other critical updates. If you don't have other active subscriptions, you can renew the expired subscription.  
パッケージ yum-utils は利用できません。
エラー: 何もしません

WARNING: 
The yum-utils package could not be installed. This means you may not be able to install source RPMs or use other yum features.

Generating yum cache for gitlab_gitlab-ce...
Importing GPG key 0xE15E78F4:
 Userid     : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
 Fingerprint: 1a4c 919d b987 d435 9396 38b9 1421 9a96 e15e 78f4
 From       : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey

The repository is setup! You can now install packages.

う~ん、色々出てるけど最後にインストールできるよ!って言ってるから進めます。

[root@RHEL7 ~]# sudo yum install -y gitlab-ce
読み込んだプラグイン:product-id, search-disabled-repos, subscription-manager
This system is registered to Red Hat Subscription Management, but is not receiving updates. You can use subscription-manager to assign subscriptions.
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ gitlab-ce.x86_64 0:9.5.1-ce.0.el7 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

================================================================================
 Package         アーキテクチャー
                              バージョン           リポジトリー            容量
================================================================================
インストール中:
 gitlab-ce       x86_64       9.5.1-ce.0.el7       gitlab_gitlab-ce       378 M

トランザクションの要約
================================================================================
インストール  1 パッケージ

総ダウンロード容量: 378 M
インストール容量: 1.1 G
Downloading packages:
/var/cache/yum/x86_64/7Server/gitlab_gitlab-ce/packages/gitlab-ce-9.5.1-ce.0.el7.x86_64.rpm: ヘッダー V4 RSA/SHA1 Signature、鍵 ID f27eab47: NOKEY
gitlab-ce-9.5.1-ce.0.el7.x86_64.rpm の公開鍵がインストールされていません
gitlab-ce-9.5.1-ce.0.el7.x86_64.rpm                        | 378 MB   00:41     
https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey から鍵を取得中です。
Importing GPG key 0xE15E78F4:
 Userid     : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
 Fingerprint: 1a4c 919d b987 d435 9396 38b9 1421 9a96 e15e 78f4
 From       : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg から鍵を取得中です。
Importing GPG key 0xF27EAB47:
 Userid     : "GitLab, Inc. <support@gitlab.com>"
 Fingerprint: dbef 8977 4ddb 9eb3 7d9f c3a0 3cfc f9ba f27e ab47
 From       : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction



       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.

     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/


gitlab: Thank you for installing GitLab!
gitlab: To configure and start GitLab, RUN THE FOLLOWING COMMAND:

sudo gitlab-ctl reconfigure

gitlab: GitLab should be reachable at http://RHEL7.3
gitlab: Otherwise configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
gitlab: And running reconfigure again.
gitlab: 
gitlab: For a comprehensive list of configuration options please see the Omnibus GitLab readme
gitlab: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
gitlab: 
It looks like GitLab has not been configured yet; skipping the upgrade script.
  検証中                  : gitlab-ce-9.5.1-ce.0.el7.x86_64                 1/1 

インストール:
  gitlab-ce.x86_64 0:9.5.1-ce.0.el7                                             

完了しました!

なんか主張の強そうなログが出てきました。とりあえず完了したようです。

最後に
3. Configure and start GitLab
に書かれている設定を実行。

[root@RHEL7 ~]# sudo gitlab-ctl reconfigure
Starting Chef Client, version 12.12.15
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
  - package (0.1.0)
  - consul (0.0.0)
  - runit (0.14.2)
  - gitlab (0.0.1)
  - registry (0.1.0)
Installing Cookbook Gems:
・
・

Running handlers:
Running handlers complete
Chef Client finished, 362/517 resources updated in 03 minutes 58 seconds
gitlab Reconfigured!

これめっちゃ長いです。この時も4分ぐらいかかってますね。しかもChefで設定て。。
ともあれ後はURLの設定をして再起動したらIEでアクセス出来るっぽいです。

URLの設定は下記でファイルを編集

vi /etc/gitlab/gitlab.rb
# external_urlを修正
external_url 'http://192.168.1.100:8080'

その後にまた、reconfigureを実行してサービス再起動でつながるはず。

gitlab-ctl reconfigure
gitlab-ctl stop
gitlab-ctl start

どりゃ
f:id:pj_doaa:20170829130442p:plain

あれえ・・・
どうやらログを見るとサービスがうまく上がっていない模様。。。
もうちょっと調べてみます。とりあえず今回は失敗ということで。

2017/8/31追記↓↓↓↓↓↓↓↓
新しく仮想マシンを用意して真っ新なところにインストールしたら成功しました。特に手順に変更はないので別ページは立ち上げませんが。。ログインに成功すると下記のような画面が出ます。
f:id:pj_doaa:20170831115540p:plain

まあ失敗した理由は分からず仕舞いですが。。。
2017/8/31追記↑↑↑↑↑↑↑↑

お疲れ様でした。