インフラCI実践ガイドの演習について引き続き試してみます。今回は4章となります。
前の記事でテスト環境の構築まで実施してます。この続きです。
4.1 演習環境の確認
4.1.1 GitLabの設定
Gitlabのプロジェクトを作成して、CIのための準備をします。
Gitlabにrootでログオンしてから新規プロジェクトを作成します。
![](https://syachiku.net/wp-content/uploads/2020/06/200622-1-01-1024x340.jpg)
github上にあるリポジトリ「https://github.com/infra-ci-book/ketchup-vagrant-ansible.git」からプロジェクトをインポートします。
![](https://syachiku.net/wp-content/uploads/2020/06/200622-1-02-1024x526.jpg)
![](https://syachiku.net/wp-content/uploads/2020/06/200622-1-03-1024x543.jpg)
プロジェクトにメンバを追加します。
![](https://syachiku.net/wp-content/uploads/2020/06/200622-1-04.jpg)
すでに作られているsshの秘密鍵を確認して、プロジェクトで利用できるように貼り付けます。
![](https://syachiku.net/wp-content/uploads/2020/06/200622-1-05.jpg)
![](https://syachiku.net/wp-content/uploads/2020/06/200622-1-06-1024x749.jpg)
4.1.2 パイプラインの実行
次にパイプラインを実行します。先ほど作成したプロジェクトをCentOSホスト側にCloneします。
[root@infraci ~]# cd ~/
[root@infraci ~]# git clone http://192.168.33.10/root/ketchup-vagrant-ansible.git
Gitの設定をしてから、新規ファイルを作成してリポジトリにpushします。
[root@infraci ~]# cd ketchup-vagrant-ansible/
[root@infraci ketchup-vagrant-ansible]# git config --local user.name "root"
[root@infraci ketchup-vagrant-ansible]# git config --local user.email "root@example.com"
[root@infraci ketchup-vagrant-ansible]# git config --local push.default simple
[root@infraci ketchup-vagrant-ansible]# echo "hello infra-ci" > chap04-test
[root@infraci ketchup-vagrant-ansible]# git add .
[root@infraci ketchup-vagrant-ansible]# git commit -m "add the test file"
こんな感じです。
![](https://syachiku.net/wp-content/uploads/2020/06/200622-1-07-1024x927.jpg)
GitlabにログオンしてプロジェクトのCI/CDのpilelineを確認すると動いている(runnningになっている)のが確認できます。完了するまで12分くらいかかりました。
![](https://syachiku.net/wp-content/uploads/2020/06/200622-1-08-1024x632.jpg)
次に先ほどのファイルを削除してみます。git rm コマンドを使ってファイルを削除してます。
[root@infraci ketchup-vagrant-ansible]# git rm chap04-test
[root@infraci ketchup-vagrant-ansible]# git commit -m "delete the test file"
[root@infraci ketchup-vagrant-ansible]# git push
![](https://syachiku.net/wp-content/uploads/2020/06/200622-1-09.jpg)
再度パイプラインが走っていることを確認します。
![](https://syachiku.net/wp-content/uploads/2020/06/200622-1-10-1024x474.jpg)
4.1.3 変更履歴の確認
Gitでの変更履歴の確認です。
![](https://syachiku.net/wp-content/uploads/2020/06/200622-1-11.jpg)
![](https://syachiku.net/wp-content/uploads/2020/06/200622-1-12-1024x519.jpg)
この後は今後の演習のシナリオの解説がされてます。本番環境とテスト環境のチームが分離していて、本番環境が責任分離点という感じです。
今回は以上となります。
コメント