はじめに

GitLabCEをAmazonLinux2023 上に構築したのでその時の記録をしておく。  

環境

1
MacOS Ventura 13.3.1 (a) (操作PC)

準備

EC2インスタンスの作成

項目設定値
名前gitlab
OSAmazonLinux2023 AMI
アーキテクチャ64ビット(Arm)
インスタンスタイプt4g.medium
キーペアgitlab(新規で作成)
セキュリティグループssh,http,https (自分のIPのみ)
ストレージ8GB (gp3)

GitLabの要件を確認すると、4GBが最小のメモリとなっているので、t4g.mediumとする。

SSHログイン

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
~/workspace/ansible-gitlab-for-al2023$ssh -i ~/.ssh/gitlab.pem [email protected]
   ,     #_
   ~\_  ####_        Amazon Linux 2023
  ~~  \_#####\
  ~~     \###|
  ~~       \#/ ___   https://aws.amazon.com/linux/amazon-linux-2023
   ~~       V~' '->
    ~~~         /
      ~~._.   _/
         _/ _/
       _/m/'
[ec2-user@ip-172-31-29-225 ~]$ 

Ansibleの構築&実行

※構築したプレイブックについてはGitHubの下記に公開しておく。

構築

GitHubのリポジトリは下記
https://github.com/katsuobushiFPGA/ansible-gitlab-al2023

実行

README.md の手順通りに構築する。

  1. hostsの準備
1
2
3
cp hosts.example hosts

vim hosts

※IPアドレスと鍵ファイルの場所を指定しておく。

  1. group_vars の認証情報を編集する。
1
vim group_vars/all
  1. テスト
1
ansible-playbook -i hosts test.yml 
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
~/workspace/ansible-gitlab-for-al2023$ansible-playbook -i hosts test.yml 

PLAY [Test] ******************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************
[WARNING]: Platform linux on host 52.195.189.27 is using the discovered Python interpreter at /usr/bin/python3.9, but future installation of another Python
interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-core/2.15/reference_appendices/interpreter_discovery.html for more
information.
ok: [52.195.189.27]

TASK [Ping pong check] *******************************************************************************************************************************************
ok: [52.195.189.27]

PLAY RECAP *******************************************************************************************************************************************************
52.195.189.27              : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0  
  1. プレイブックの実行
1
ansible-playbook -i hosts site.yml
 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
~/workspace/ansible-gitlab-for-al2023$ansible-playbook -i hosts test.yml      

PLAY [Test] ******************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************
[WARNING]: Platform linux on host 3.112.240.174 is using the discovered Python interpreter at /usr/bin/python3.9, but future installation of another
Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-
core/2.15/reference_appendices/interpreter_discovery.html for more information.
ok: [3.112.240.174]

TASK [Ping pong check] *******************************************************************************************************************************
ok: [3.112.240.174]

PLAY RECAP *******************************************************************************************************************************************
3.112.240.174              : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

~/workspace/ansible-gitlab-for-al2023$ansible-playbook -i hosts site.yml     

PLAY [Provision] *************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************
[WARNING]: Platform linux on host 3.112.240.174 is using the discovered Python interpreter at /usr/bin/python3.9, but future installation of another
Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-
core/2.15/reference_appendices/interpreter_discovery.html for more information.
ok: [3.112.240.174]

TASK [swap : Setting swap file path] *****************************************************************************************************************
ok: [3.112.240.174]

TASK [swap : Zero padding] ***************************************************************************************************************************
changed: [3.112.240.174]

TASK [swap : Set up a Linux swap area] ***************************************************************************************************************
ok: [3.112.240.174]

TASK [swap : Chmod swap file] ************************************************************************************************************************
changed: [3.112.240.174]

TASK [swap : Mount swap] *****************************************************************************************************************************
changed: [3.112.240.174]

TASK [swap : Just force systemd to re-execute itself (2.8 and above)] ********************************************************************************
ok: [3.112.240.174]

TASK [swap : Enable file for swapping] ***************************************************************************************************************
ok: [3.112.240.174]

TASK [gitlab-ce : Add repository for GitLabCE] *******************************************************************************************************
changed: [3.112.240.174]

TASK [gitlab-ce : Install GitLabCE] ******************************************************************************************************************
changed: [3.112.240.174]

TASK [gitlab-runner : Add repository for GitLab runner] **********************************************************************************************
changed: [3.112.240.174]

TASK [gitlab-runner : Install GitLab runner] *********************************************************************************************************
changed: [3.112.240.174]

PLAY RECAP *******************************************************************************************************************************************
3.112.240.174              : ok=12   changed=7    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

できた!

確認

signin

rootのパスワードは以下でわかる。

1
cat /etc/gitlab/initial_root_password
dashboard

参考

おわりに

AmazonLinux2023にGitLabCEを入れるということを実践した。
でも公式のAMIで既に入っているものがあるらしいではないか・・・。   例えば下記など、公式でAMIの提供をしているのであればこれで良いのではないか!
https://aws.amazon.com/marketplace/pp/prodview-w6ykryurkesjq
と思ったが、まあ勉強という意味でね。