gitlabの導入方法のメモ
...こんにちは。小宮です。先輩から要望されていそうな気がしたのでgitlab導入時のメモです。。
やたらめったら長いし手順が複雑でこのとおりやって再現できるかはお使いの環境に依存する可能性があり保障できかねます。 この手順で再現した環境はOSはCentOS6.5でした。 postgresを許容できるのであれば自動的に入れられるオムニバス版があるのでそちらをお使いいただくのがよろしいかと。 個人的にpostgresの運用の知見が心もとなかったのと、RDSに逃げられなくなるのがアレだったのでmysqlで頑張りました。
自分で自動化する時は、passengerとgitlab:setup時の対話処理をなんとか自動化するオプションを付けるとこがキモかと思いました。 この手順自体は部分的にchefがでてきますがほぼ手動です。自動化オプションは最後のほうにちょろっと書いときます。
1.このへんからmysqlをなんとかして入れとく
$ wget http://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.6/MySQL-5.6.17-1.linux_glibc2.5.x86_64.rpm-bundle.tar -P site-cookbooks/mysqld/files/default/usr/local/src/2.rbenv等でrubyをなんとかして入れておく
(chefでなにもせずにやるとchefgemに寄るので注意がひつよう) rubyのバージョンが低いとGemfileのシンタックスチェックでエラー出てmysql2とかが入らないことも。
3.Gitのインストール
# yum -y install libcurl-devel libxslt-devel libxml2-devel expat-devel gettext openssl-devel zlib-devel Installed: libcurl-devel.x86_64 0:7.19.7-37.el6_4 libxml2-devel.x86_64 0:2.7.6-14.el6 libxslt-devel.x86_64 0:1.1.26-2.el6_3.1 Dependency Installed: libgcrypt-devel.x86_64 0:1.4.5-11.el6_4 libgpg-error-devel.x86_64 0:1.7-4.el6 # su - chef;cd infra-chef-repo/ $ knife cookbook create git -o site-cookbooks $ knife cookbook create redis -o site-cookbooks $ vi site-cookbooks/git/recipes/default.rb # # Cookbook Name:: git # Recipe:: default # # Copyright 2014, YOUR_COMPANY_NAME # # All rights reserved - Do Not Redistribute # %W{libcurl-devel libxslt-devel libxml2-devel expat-devel gettext openssl-devel zlib-devel libgcrypt-devel libgpg-error-devel}.each do |pkg| package pkg do not_if "rpm -qa|grep #{pkg}" action :install end end bash "bash-install-git" do not_if "ls -d /usr/local/src/git-1.9.0" code <<-EOC wget https://git-core.googlecode.com/files/git-1.9.0.tar.gz -P /usr/local/src cd /usr/local/src/ tar zxf git-1.9.0.tar.gz cd /usr/local/src/git-1.9.0 ./configure --prefix=/usr/local/git make all make install ln -sf /usr/local/git/bin/git* /usr/local/bin/ EOC end $ knife solo cook localhost -o git # wget https://git-core.googlecode.com/files/git-1.9.0.tar.gz -P /usr/local/src # cd /usr/local/src/ # tar zxf git-1.9.0.tar.gz # cd /usr/local/src/git-1.9.0 # ./configure --prefix=/usr/local/git # make all # make install # ln -s /usr/local/git/bin/git* /usr/local/bin/ # which git /usr/local/bin/git # git --version git version 1.9.04.redisのインストール
# yum install -y --enablerepo=remi redis Installed: redis.x86_64 0:2.8.9-1.el6.remi Dependency Installed: gperftools-libs.x86_64 0:2.0-11.el6.3 libunwind.x86_64 0:1.1-2.el6 # /etc/init.d/redis start # chkconfig redis on # redis-cli ping PONG $ vi site-cookbooks/redis/recipes/default.rb bash "yum-install-redis-from-remi" do not_if "which redis-cli" code <<-EOC yum install -y --enablerepo=remi redis EOC end service "redis" do supports :status => true, :restart => true action [ :enable, :start ] end $ knife cookbook test redis $ knife solo cook localhost -o redis5.ユーザ作成
# useradd -c 'GitLab' git # chmod 755 /home/git # su - git -s /bin/bash $ mkdir .ssh $ touch .ssh/authorized_keys $ chmod 600 .ssh/authorized_keys $ chmod 700 .ssh $ git config --global user.name "GitLab" $ git config --global user.email "gitlab@localhost" ##### 6.gitlab-shellのインストール $ git clone https://github.com/gitlabhq/gitlab-shell.git -b v1.9.4 $ cp -a /home/git/gitlab-shell/config.yml{.example,} $ /home/git/gitlab-shell/bin/install install失敗する場合は、gitユーザの.bashrcか/etc/profile.d/の下あたりに環境変数を追加し読み込みしてから再実行 export PATH=/path-to-ruby:$PATH8.gitlabインストール
$ git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-8-stable gitlab $ cp -a /home/git/gitlab/config/gitlab.yml{.example,} 不要っぽい -------------------------- $ chmod -R u+rwX /home/git/gitlab/log/ $ chmod -R u+rwX /home/git/gitlab/tmp/ $ mkdir /home/git/gitlab/tmp/pids/ $ mkdir /home/git/gitlab/tmp/sockets/ $ chmod -R u+rwX /home/git/gitlab/tmp/pids/ $ chmod -R u+rwX /home/git/gitlab/tmp/sockets/ $ mkdir /home/git/gitlab/public/uploads $ chmod -R u+rwX /home/git/gitlab/public/uploads -------------------------- $ mkdir /home/git/gitlab-satellites $ ll -d /home/git/gitlab-satellites drwxrwxr-x 2 git git 4096 5月 19 12:20 2014 /home/git/gitlab-satellites $ $ ll -d /home/git/gitlab-satellites drwxr-x--- 2 git git 4096 5月 19 12:20 2014 /home/git/gitlab-satellites $ cp -a /home/git/gitlab/config/unicorn.rb{.example,} $ cp -a /home/git/gitlab/config/initializers/rack_attack.rb{.example,} $ cd /home/git/gitlab $ git config --global user.name "GitLab" $ git config --global user.email "gitlab@localhost" $ git config --global core.autocrlf input9.DB設定
$ cp -a /home/git/gitlab/config/database.yml{.mysql,} $ vi /home/git/gitlab/config/database.yml $ diff /home/git/gitlab/config/database.yml{.mysql,} 10,12c10,12 < username: git < password: "secure password" < # host: localhost --- > username: gitxxxxx > password: "xxxxxxxx" > host: localhost $ ls -al /home/git/gitlab/config/database.yml -rw-rw-r-- 1 git git 777 5月 19 12:32 2014 /home/git/gitlab/config/database.yml $ chmod o-rwx /home/git/gitlab/config/database.yml $ ls -al /home/git/gitlab/config/database.yml -rw-rw---- 1 git git 777 5月 19 12:32 2014 /home/git/gitlab/config/database.yml $ vi /home/git/gitlab/config/gitlab.yml $ diff /home/git/gitlab/config/gitlab.yml{,.example} 227c227 < bin_path: /usr/local/bin/git --- > bin_path: /usr/bin/gitローカル等てきとうなところ(database.ymlに指定したところ)にDBをなんとかしていれる
solarisのKSSLをつかう
...おはようございます。インフラ宮下です。
最近はopensslの脆弱性が頻繁に取りざたされています。 そこで今回はKSSLを使ってSSLをterminateする設定を紹介します。
1.環境
サーバ:oracle spark enterprise T2000 OS:solaris10
とても古い環境です。
構成:コンテナ構成でWEBサーバはlocal ZONEに構築されています。 KSSLで終端するのはglobal ZONEです。 local ZONEのWEBサーバでは、8888ポートでListenするように設定しています。
2.証明書の準備
KSSLで渡せる証明書情報は1ファイルだけなので、「証明書+中間証明書+秘密鍵」の順番で情報を貼り付けたファイルをGlobal ZONEから見れる場所に設置する。
[shell]# vi /etc/httpd/keys/abc.net.key [/shell]
3.SMFにKSSLサービスを登録する
[shell]ksslcfg create -f pem -i /etc/httpd/keys/abc.net.key -x 8888 zone-web01 443 [/shell]
「zone-web01」はforward先のサーバを差します。(今回はlocal ZONEのWEBサーバ) この名前は、DNSで引けるかhostsに登録してある必要があります。 「-i」…設置した証明書を指定する。経験的にファイルの権限とかに制約はない 「-x」…配下のサーバと通信ポート番号。webサーバがListenしているポートです 「zone-web01」…terminate後の接続先サーバ名 「443」…KSSL自体が待ち受けるポート
[shell]# svcs -a|grep ssl online 10:15:01 svc:/network/ssl/proxy:kssl-zone-web01-443 [/shell] Global Zoneでこのように「online」となれば起動成功です。
facebookのIPがmod_geoipで拒否される対応
...こんにちは。プラットフォームの小宮です。
apacheのmod_geoipモジュールで海外を拒否してみたところ、
Facebookの画像が表示されないということで対応しました。・whoisが必要だが入ってなかったので他の入ってるサーバでパッケージ名を調べて導入
[shell]$ which whois /usr/bin/whois # rpm -qf /usr/bin/whois jwhois-3.2.2-1
# yum install jwhois Installed: jwhois.x86_64 0:4.0-19.el6 # which whois /usr/bin/whois[/shell]
・fb公式で許可リスト取得方法を確認
以下のコマンドで定期的に更新リストを取得せよと公式に書いてある。
App Security - Facebook開発者[shell]# whois -h whois.radb.net – ‘-i origin AS32934’ | grep ^route:|awk ‘{print $2}’ 204.15.20.0/22 69.63.176.0/20 ~略~ 69.63.184.0/21 66.220.144.0/20 69.63.176.0/20[/shell] ※65ブロックくらいだった。手作業はあり得ないので何とか自動化を試みる。
・設定追加方法の検討
この辺に追記できるか考えてみる。
[shell]# cat /etc/cron.monthly/geoip #!/bin/bash wget -q http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz gunzip GeoIP.dat.gz mv -f GeoIP.dat /usr/share/GeoIP/GeoIP.dat[/shell]
datはバイナリなので自分で追記は困難。軽くググってもそんなことしてる人いない。
[shell]# file /usr/share/GeoIP/GeoIP.dat /usr/share/GeoIP/GeoIP.dat: data[/shell]