LoginSignup
84
84

More than 5 years have passed since last update.

GitLab Cookbook

Last updated at Posted at 2013-06-16

===============

GitLabはGitHubのクローンでSCM(Software Configuration Management)に利用できます。
Installationは丁寧に記載されているので、これをベースにChefCookbookを作りました。

GitLabは Ruby on Rails で開発されておりPumaSidekiqなどの素敵なミドルウェアが利用されています。
また、 Git flow などでブランチを運用するので Network が見やすいのもポイントです。

これで簡単にVirtualBox、Amazon EC2、さくらのVPSZ Cloud(Joyent Cloud)などにインストールできます。

環境

Vagrant: 1.3.1
Mac: OS X Lion

(Windowsはこちらを参考にして下さい。)

VirtualBox

localhostでアスセスするGitLabは何かと使い勝手があります。
(当たり前ですがネットワークに接続しなくてもGitLabが使えます。)

Gem & Plugin

まずberkshelfvagrant-berkshelf,vagrant-omnibusをインストールします。

$ gem install berkshelf
$ vagrant plugin install vagrant-berkshelf
$ vagrant plugin install vagrant-omnibus

Download & Edit

後はGitLabのCookbookをダウンロードして、vagrant upコマンドを実施するだけで
GitLabがインストールされます。(簡単ですね!)

$ git clone git://github.com/ogom/cookbook-gitlab ./gitlab
$ cd ./gitlab/
$ vagrant up

http://localhost:8080/にアクセスするとGitLabが表示されます。
UserがogomでProjectがtokyoのGitのURLはgit@localhost:ogom/tokyo.gitです。

Administrator

Amazon EC2

パブリックにGitLabが欲しいときはAWSが簡単です。

Gem & Plugin

berkshelfvagrant-berkshelf,vagrant-omnibusをインストールします。
vagrant-awsをインストールしてdummyboxを追加します。

$ 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

Download & Edit

GitLabのCookbookをダウンロードして、/example/Vagrantfile_awsVagrantfileにコピーして編集します。
アクセスキー(access_key_id,secret_access_key)や秘密鍵(private_key_path)、公開鍵(keypair_name)を変更して下さい。

SSHHTTPを許可するセキュリティグループはAWSで設定します。(/example/Vagrantfile_awsではvagrantで登録しています。)
aws_security_group

vagrant upコマンドに--provider=awsのオプションを追加して実施します。

$ git clone git://github.com/ogom/cookbook-gitlab ./gitlab
$ cd ./gitlab/
$ cp ./example/Vagrantfile_aws ./Vagrantfile
$ vagrant up --provider=aws

DNS

EC2はPublic DNSを設定するのでドメインでGitLabにアクセスできます。
Vagrantfileを編集してvagrant provisionコマンドでインストールを再開します。
('vagrant ssh-config'コマンドでドメインを参照できます。)

$ vagrant ssh-config | awk '/HostName/ {print $2}'
$ editor ./Vagrantfile
$ vagrant provision

長いですがgit@ec2-50-16-8-211.compute-1.amazonaws.com:ogom/girls.gitのURLでgit cloneできます。
aws_ec2_gitlab

インスタンスが不要になればvagrant destroyコマンドでTerminateしてくれます。

Knife Solo

さくらのVPSZ CloudKnife SoloでGitLabをインストールします。
もちろんEC2にもインストールできます。(この例は先ほどのインスタンス)

Gem

berkshelfknife-soloをインストールします。

$ gem install berkshelf
$ gem install knife-solo

Download

ChefのRepositoryを作りGitLabのCookbookなどをダウンロードします。

$ knife configure
$ knife solo init ./chef-repo
$ cd ./chef-repo/
$ echo 'cookbook "gitlab", github: "ogom/cookbook-gitlab"' >> ./Berksfile
$ berks install --path ./cookbooks

Edit

knife solo prepareコマンドでChefをインンストールします。
knife solo cookコマンドでGitLabをインンストールします。
(nodejsonこちらを参考にして下さい。)

$ knife solo prepare ubuntu@ec2-50-16-8-211.compute-1.amazonaws.com -i ~/.ssh/vagrant_aws.pem
$ editor ./nodes/ec2-50-16-8-211.compute-1.amazonaws.com.json
$ knife solo cook ubuntu@ec2-50-16-8-211.compute-1.amazonaws.com -i ~/.ssh/vagrant_aws.pem --no-chef-check

HTTPのhttp://ec2-50-16-8-211.compute-1.amazonaws.com/ogom/style.gitのURLでもgit cloneできます。
(さくらのVPSは1G、Z CloudはSmall 1GBでインストールを確認しました。)

Tips

VagrantのPluginはGemなのでvagrant-awsのようにJoyent(SDC)を操作する
vagrant-sdcプラグインを作るならsmartdcが利用できそうです。

84
84
12

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
84
84