Share
Embed
技術的負債を返済する(DevOps編)
【 ヒカ☆ラボ 】スタートアップの草創期/成長期に求められる技術とは!? ~年率600%の成長を続けるリクルーティングプラットフォームを開発する企業が実践するDevOpsとスクラム開発を語ります~
http://at-agent.jp/service/event/127/
Kenji Akiyama
October 09, 2014
Transcript
102 slides
-
ࣗݾհ ळࢁݦ࣏ ,FOKJ"LJZBNB ! גࣜձࣾϋςϨϏδϣϯ ΤϯδχΞ ݄ࢀը ! UXJUUFS!BSUJGBDUTBVDF
HJUIVC!BSUJGBDUTBVDF ( ,FOKJ"LJZBNB -
εΩϧηοτ ‣ 1FSM ‣ 1)1 ‣ 3VCZ ‣ )5.-$44 ‣
+BWBTDSJQU ‣ $P⒎FFTDSJQU ‣ -JOVY ‣ 4PMBSJT ‣ .Z42- ‣ 1PTUHSF42- ‣ ֤छ8"' ‣ FUDʜ -
ҎલͷΩϟϦΞ ཧֶ̋ݚڀॴʹ΄Ͳ ! w ੜσʔλͷղੳ w σʔλϕʔεߏங w 8FCΞϓϦ։ൃ !
ίϯϐϡʔλʔपΓͷ͜ͱͳ ΒΘΓͱԿͰ -
ྫʣίʔυ ‣ ཧղෆೳͳม໊ ‣ DPOEͱDPOEͬͯԿ͕ҧ͏ͷʁ ‣ ཧղෆೳͳϝιου໊ ‣ IBT3FDPSEͷฦΓ͕ྻʁ ‣
ॏෳͨ͠ϝιου ‣ ༵Λฦ͢ϝιου͕ͭ༗Γ·͚͢Ͳ -
ྫʣΦϖϨʔγϣϯ ‣ ϢʔβʔΞΧϯτ͕ڞ༗ ‣ ͝ʜ͝ஊͰ͢ΑͶʁ ‣ ຊ൪ڥͱ։ൃڥͰϑΝΠϧʹ͕ࠩ͋Δ ‣ ͑ʜʁ͝ஊͰ͢ΑͶʁ ‣
։ൃऀݸਓͷಠࣗσϓϩΠखॱ ‣ ͝ஊͰ͢ΑͶʁ͝ஊͰ͢ΑͶʁ ‣ υΩϡϝϯτෆ ‣ ͦΕͬͯυΩϡϝϯτɺ͋Γ·͔͢ʁ -
ͳͥ͜͏ͳͬͨʁ ‣ ͕࣌ؒແ͍ ‣ ίʔυͷ࣭ͳͲʹ࣌ؒΛ͔͚͍ͯΔ༨༟ ແ͍ɻ ‣ γεςϜͷޮԽͳͲʹ࣌ؒΛ͔͚͍ͯΔ༨ ༟ແ͍ɻ ‣
খنΏ͑ͷશೳײ ‣ ΄ͱΜͲ͕ࣗ࡞ͬͨͷͰ͍͍ͩͨΘ͔ͬͯ ͍Δɻ -
͔ͭͯͷσϓϩΠखॱ (JUͷ։ൃϒϥϯν͔ΒANBTUFSAϒϥϯνϚʔδ͢Δ ࡞ۀͷ։࢝Λ4MBDLͰશһʹ௨͢Δ લճͷσϓϩΠ͔Βมߋͷ͋ͬͨϑΝΠϧ͚ͩΛαʔόʔʹίϐʔ͢Δ ݱߦόʔδϣϯͷσΟϨΫτϦΛ৽ͨͳόʔδϣϯ໊Λ͚ͯίϐʔ͢ Δ
αʔόʔʹίϐʔͨ͠ϑΝΠϧͰ৽όʔδϣϯσΟϨΫτϦͷϑΝΠϧ Λ্ॻ͖͢Δ ݱߦόʔδϣϯͷσΟϨΫτϦΛࢦ͢4ZNMJOLΛɺ৽όʔδϣϯσΟϨ ΫτϦΛࢦ͢Α͏ʹ࡞͢͠ $BDIFϑΝΠϧΛআ͢Δ QIQGQNΛ࠶ىಈ͢Δ ࡞ۀͷऴྃΛ4MBDLͰશһʹ௨͢Δ -
͔ͭͯͷσϓϩΠखॱ # local ! $ git checkout master $ git
pull $ git merge DEV_BRANCH $ PAGER=cat git diff --name-status LAST_TAG CRRT_TAG \ > > file_diff.txt $ grep '^D' file_diff.txt > file_del.txt $ grep -v '^D' file_diff.txt > file_mod.txt $ grep '\w\s*wordpress' file_diff.txt > file_wdp.txt $ perl -i -ple '/\.scss$/ \ > && s/(sass|scss$)/css/g’ file_mod.txt $ bundle exec compass compile $ mkdir -p DEST_DIR $ perl -ple 's/^\w\s+//' file_mod.txt \ > | xargs -I% rsync -R % DEST_DIR $ cp file_del.txt DEST_DIR $ scp -r DEST_DIR REMOTE_HOST:~/DEST_DIR ! # remote ! $ cd DEPLOY_TO $ sudo -u DEPLOY_USER cp -apr LAST_TAG CRRT_TAG $ sudo -u DEPLOY_USER rsync -av DEST_DIR DEPLOY_TO/ \ > CRRT_TAG $ cd DEPLOY_TO/CRRT_TAG $ perl -ple 's/^D\s+//' file_del.txt | xargs rm $ sudo -u DEPLOY_USER ln -snf DEPLOY_TO/CRRT_TAG WEB_ROOT $ sudo find CAKE1_APP_CACHE -type f -exec rm {} \; $ sudo find CAKE2_APP_CACHE -type f -name 'empty' -prune \ > -o -type f -exec rm {} \; $ sudo service php5-fpm restart -
ࣗಈԽͷԸܙ # local ! $ git checkout master $ git
pull $ git merge DEV_BRANCH $ PAGER=cat git diff --name-status LAST_TAG CRRT_TAG \ > > file_diff.txt $ grep '^D' file_diff.txt > file_del.txt $ grep -v '^D' file_diff.txt > file_mod.txt $ grep '\w\s*wordpress' file_diff.txt > file_wdp.txt $ perl -i -ple '/\.scss$/ \ > && s/(sass|scss$)/css/g’ file_mod.txt $ bundle exec compass compile $ mkdir -p DEST_DIR $ perl -ple 's/^\w\s+//' file_mod.txt \ > | xargs -I% rsync -R % DEST_DIR $ cp file_del.txt DEST_DIR $ scp -r DEST_DIR REMOTE_HOST:~/DEST_DIR ! # remote ! $ cd DEPLOY_TO $ sudo -u DEPLOY_USER cp -apr LAST_TAG CRRT_TAG $ sudo -u DEPLOY_USER rsync -av DEST_DIR DEPLOY_TO/ \ > CRRT_TAG $ cd DEPLOY_TO/CRRT_TAG $ perl -ple 's/^D\s+//' file_del.txt | xargs rm $ sudo -u DEPLOY_USER ln -snf DEPLOY_TO/CRRT_TAG WEB_ROOT $ sudo find CAKE1_APP_CACHE -type f -exec rm {} \; $ sudo find CAKE2_APP_CACHE -type f -name 'empty' -prune \ > -o -type f -exec rm {} \; $ sudo service php5-fpm restart -
ࣗಈԽͷԸܙ # local ! $ git checkout master $ git
pull $ git merge DEV_BRANCH $ PAGER=cat git diff --name-status LAST_TAG CRRT_TAG \ > > file_diff.txt $ grep '^D' file_diff.txt > file_del.txt $ grep -v '^D' file_diff.txt > file_mod.txt $ grep '\w\s*wordpress' file_diff.txt > file_wdp.txt $ perl -i -ple '/\.scss$/ \ > && s/(sass|scss$)/css/g’ file_mod.txt $ bundle exec compass compile $ mkdir -p DEST_DIR $ perl -ple 's/^\w\s+//' file_mod.txt \ > | xargs -I% rsync -R % DEST_DIR $ cp file_del.txt DEST_DIR $ scp -r DEST_DIR REMOTE_HOST:~/DEST_DIR ! # remote ! $ cd DEPLOY_TO $ sudo -u DEPLOY_USER cp -apr LAST_TAG CRRT_TAG $ sudo -u DEPLOY_USER rsync -av DEST_DIR DEPLOY_TO/ \ > CRRT_TAG $ cd DEPLOY_TO/CRRT_TAG $ perl -ple 's/^D\s+//' file_del.txt | xargs rm $ sudo -u DEPLOY_USER ln -snf DEPLOY_TO/CRRT_TAG WEB_ROOT $ sudo find CAKE1_APP_CACHE -type f -exec rm {} \; $ sudo find CAKE2_APP_CACHE -type f -name 'empty' -prune \ > -o -type f -exec rm {} \; $ sudo service php5-fpm restart # local ! $ cap production deploy -
ࣗಈԽͷԸܙ # local ! $ git checkout master $ git
pull $ git merge DEV_BRANCH $ PAGER=cat git diff --name-status LAST_TAG CRRT_TAG \ > > file_diff.txt $ grep '^D' file_diff.txt > file_del.txt $ grep -v '^D' file_diff.txt > file_mod.txt $ grep '\w\s*wordpress' file_diff.txt > file_wdp.txt $ perl -i -ple '/\.scss$/ \ > && s/(sass|scss$)/css/g’ file_mod.txt $ bundle exec compass compile $ mkdir -p DEST_DIR $ perl -ple 's/^\w\s+//' file_mod.txt \ > | xargs -I% rsync -R % DEST_DIR $ cp file_del.txt DEST_DIR $ scp -r DEST_DIR REMOTE_HOST:~/DEST_DIR ! # remote ! $ cd DEPLOY_TO $ sudo -u DEPLOY_USER cp -apr LAST_TAG CRRT_TAG $ sudo -u DEPLOY_USER rsync -av DEST_DIR DEPLOY_TO/ \ > CRRT_TAG $ cd DEPLOY_TO/CRRT_TAG $ perl -ple 's/^D\s+//' file_del.txt | xargs rm $ sudo -u DEPLOY_USER ln -snf DEPLOY_TO/CRRT_TAG WEB_ROOT $ sudo find CAKE1_APP_CACHE -type f -exec rm {} \; $ sudo find CAKE2_APP_CACHE -type f -name 'empty' -prune \ > -o -type f -exec rm {} \; $ sudo service php5-fpm restart # local ! $ cap production deploy UBLFOCZXJFENBJFS -
EFQMPZUBTL ‣ EFQMPZTUBSUJOH ‣ EFQMPZDIFDL ‣ HJUDIFDL ‣ EFQMPZDIFDLEJSFDUPSJFT ‣
EFQMPZDIFDLMJOLFE@EJST ‣ EFQMPZDIFDLNBLF@MJOLFE@EJST ‣ EFQMPZDIFDLMJOLFE@pMFT ‣ EFQMPZTUBSUFE ‣ EFQMPZVQEBUJOH ‣ HJUDSFBUF@SFMFBTF ‣ EFQMPZTZNMJOLTIBSFE ‣ EFQMPZTZNMJOLMJOLFE@pMFT ‣ EFQMPZTZNMJOLMJOLFE@EJST ‣ EFQMPZVQEBUFE ‣ EFQMPZQVCMJTIJOH ‣ EFQMPZTZNMJOLSFMFBTF ‣ EFQMPZQVCMJTIFE ‣ EFQMPZpOJTIJOH ‣ EFQMPZDMFBOVQ ‣ EFQMPZpOJTIFE $BQJTUSBOPͷσϓϩΠϑϨʔϜϫʔΫͷ͍ํ աڈܗͰه͞Ε͍ͯΔλεΫۭͷλεΫ ͳͷͰ͜ΕΒΛඞཁʹԠ্ͯ͡ॻ͖͢Δ -
ͲΜͳίʔυʁ task :updated do on roles(:app) do ["cakephp1","cakephp2"].each do |cake_dir|
["cake", "lib", "index.php", "plugins", "vendors"].each do |part_dir| part_path = fetch(:deploy_to) + '/' + cake_dir + '/' + part_dir if test "[ -e #{part_path} ]" then execute :ln, '-snf', part_path, "#{fetch(:release_path)}/#{cake_dir}/#{part_dir}" end end end ! within "#{fetch(:release_path)}/cakephp2/app" do composer_path = "#{fetch(:release_path)}/cakephp2/app/composer.phar" if test "[ -f #{composer_path} ]" then execute "./composer.phar", 'install' end ! if fetch(:run_migration) then execute '../lib/Cake/Console/cake', 'Migrations.migration', 'run', 'all' end end ! if fetch(:sass_compile_path) then within "#{fetch(:release_path)}/#{fetch(:sass_compile_path)}" do execute :compass, 'compile', '--boring' end end ! end end -
ͲΜͳίʔυʁ task :updated do on roles(:app) do ["cakephp1","cakephp2"].each do |cake_dir|
["cake", "lib", "index.php", "plugins", "vendors"].each do |part_dir| part_path = fetch(:deploy_to) + '/' + cake_dir + '/' + part_dir if test "[ -e #{part_path} ]" then execute :ln, '-snf', part_path, "#{fetch(:release_path)}/#{cake_dir}/#{part_dir}" end end end ! within "#{fetch(:release_path)}/cakephp2/app" do composer_path = "#{fetch(:release_path)}/cakephp2/app/composer.phar" if test "[ -f #{composer_path} ]" then execute "./composer.phar", 'install' end ! if fetch(:run_migration) then execute '../lib/Cake/Console/cake', 'Migrations.migration', 'run', 'all' end end ! if fetch(:sass_compile_path) then within "#{fetch(:release_path)}/#{fetch(:sass_compile_path)}" do execute :compass, 'compile', '--boring' end end ! end end $BLF1)1ϥΠϒϥϦ ϦϯΫΛுΔ -
ͲΜͳίʔυʁ task :updated do on roles(:app) do ["cakephp1","cakephp2"].each do |cake_dir|
["cake", "lib", "index.php", "plugins", "vendors"].each do |part_dir| part_path = fetch(:deploy_to) + '/' + cake_dir + '/' + part_dir if test "[ -e #{part_path} ]" then execute :ln, '-snf', part_path, "#{fetch(:release_path)}/#{cake_dir}/#{part_dir}" end end end ! within "#{fetch(:release_path)}/cakephp2/app" do composer_path = "#{fetch(:release_path)}/cakephp2/app/composer.phar" if test "[ -f #{composer_path} ]" then execute "./composer.phar", 'install' end ! if fetch(:run_migration) then execute '../lib/Cake/Console/cake', 'Migrations.migration', 'run', 'all' end end ! if fetch(:sass_compile_path) then within "#{fetch(:release_path)}/#{fetch(:sass_compile_path)}" do execute :compass, 'compile', '--boring' end end ! end end $BLF1)1ϥΠϒϥϦ ϦϯΫΛுΔ DPNQPTFSͰϓϥάΠϯ ΛΠϯετʔϧ͢Δ -
ͲΜͳίʔυʁ task :updated do on roles(:app) do ["cakephp1","cakephp2"].each do |cake_dir|
["cake", "lib", "index.php", "plugins", "vendors"].each do |part_dir| part_path = fetch(:deploy_to) + '/' + cake_dir + '/' + part_dir if test "[ -e #{part_path} ]" then execute :ln, '-snf', part_path, "#{fetch(:release_path)}/#{cake_dir}/#{part_dir}" end end end ! within "#{fetch(:release_path)}/cakephp2/app" do composer_path = "#{fetch(:release_path)}/cakephp2/app/composer.phar" if test "[ -f #{composer_path} ]" then execute "./composer.phar", 'install' end ! if fetch(:run_migration) then execute '../lib/Cake/Console/cake', 'Migrations.migration', 'run', 'all' end end ! if fetch(:sass_compile_path) then within "#{fetch(:release_path)}/#{fetch(:sass_compile_path)}" do execute :compass, 'compile', '--boring' end end ! end end $BLF1)1ϥΠϒϥϦ ϦϯΫΛுΔ DPNQPTFSͰϓϥάΠϯ ΛΠϯετʔϧ͢Δ σʔλϕʔεϚΠάϨʔ γϣϯΛ࣮ߦ͢Δ -
ͲΜͳίʔυʁ task :updated do on roles(:app) do ["cakephp1","cakephp2"].each do |cake_dir|
["cake", "lib", "index.php", "plugins", "vendors"].each do |part_dir| part_path = fetch(:deploy_to) + '/' + cake_dir + '/' + part_dir if test "[ -e #{part_path} ]" then execute :ln, '-snf', part_path, "#{fetch(:release_path)}/#{cake_dir}/#{part_dir}" end end end ! within "#{fetch(:release_path)}/cakephp2/app" do composer_path = "#{fetch(:release_path)}/cakephp2/app/composer.phar" if test "[ -f #{composer_path} ]" then execute "./composer.phar", 'install' end ! if fetch(:run_migration) then execute '../lib/Cake/Console/cake', 'Migrations.migration', 'run', 'all' end end ! if fetch(:sass_compile_path) then within "#{fetch(:release_path)}/#{fetch(:sass_compile_path)}" do execute :compass, 'compile', '--boring' end end ! end end $BLF1)1ϥΠϒϥϦ ϦϯΫΛுΔ DPNQPTFSͰϓϥάΠϯ ΛΠϯετʔϧ͢Δ DPNQBTTͰTBTTϑΝΠϧ ΛίϯύΠϧ͢Δ σʔλϕʔεϚΠάϨʔ γϣϯΛ࣮ߦ͢Δ -
ͲΜͳίʔυʁ task :updated do on roles(:app) do ["cakephp1","cakephp2"].each do |cake_dir|
["cake", "lib", "index.php", "plugins", "vendors"].each do |part_dir| part_path = fetch(:deploy_to) + '/' + cake_dir + '/' + part_dir if test "[ -e #{part_path} ]" then execute :ln, '-snf', part_path, "#{fetch(:release_path)}/#{cake_dir}/#{part_dir}" end end end ! within "#{fetch(:release_path)}/cakephp2/app" do composer_path = "#{fetch(:release_path)}/cakephp2/app/composer.phar" if test "[ -f #{composer_path} ]" then execute "./composer.phar", 'install' end ! if fetch(:run_migration) then execute '../lib/Cake/Console/cake', 'Migrations.migration', 'run', 'all' end end ! if fetch(:sass_compile_path) then within "#{fetch(:release_path)}/#{fetch(:sass_compile_path)}" do execute :compass, 'compile', '--boring' end end ! end end $BLF1)1ϥΠϒϥϦ ϦϯΫΛுΔ DPNQPTFSͰϓϥάΠϯ ΛΠϯετʔϧ͢Δ DPNQBTTͰTBTTϑΝΠϧ ΛίϯύΠϧ͢Δ σʔλϕʔεϚΠάϨʔ γϣϯΛ࣮ߦ͢Δ ΞϓϦέʔγϣϯಛҟతͳλεΫΛ ه͍ͯ͘͠ -
ͲΜͳίʔυʁ task :restart do on roles(:app, :wp) do execute :sudo,
:service, 'php5-fpm', 'restart' end end ! after :publishing, :restart ! before :restart, :clear_cache do on roles(:app) do if fetch(:app_cache1_path) then execute :sudo, :find, fetch(:app_cache1_path), '-type f -exec rm {} \;' end if fetch(:app_cache2_path) then execute :sudo, :find, fetch(:app_cache2_path), '-type f -name "empty" -prune -o -type f -exec rm {} \;' end end end -
ͲΜͳίʔυʁ task :restart do on roles(:app, :wp) do execute :sudo,
:service, 'php5-fpm', 'restart' end end ! after :publishing, :restart ! before :restart, :clear_cache do on roles(:app) do if fetch(:app_cache1_path) then execute :sudo, :find, fetch(:app_cache1_path), '-type f -exec rm {} \;' end if fetch(:app_cache2_path) then execute :sudo, :find, fetch(:app_cache2_path), '-type f -name "empty" -prune -o -type f -exec rm {} \;' end end end QIQGQNΛϦελʔτ͢Δ -
ͲΜͳίʔυʁ task :restart do on roles(:app, :wp) do execute :sudo,
:service, 'php5-fpm', 'restart' end end ! after :publishing, :restart ! before :restart, :clear_cache do on roles(:app) do if fetch(:app_cache1_path) then execute :sudo, :find, fetch(:app_cache1_path), '-type f -exec rm {} \;' end if fetch(:app_cache2_path) then execute :sudo, :find, fetch(:app_cache2_path), '-type f -name "empty" -prune -o -type f -exec rm {} \;' end end end QIQGQNΛϦελʔτ͢Δ QVCMJTIJOHλεΫͷޙ ʹ࣮ߦͯ͠Ͷὑ -
ͲΜͳίʔυʁ task :restart do on roles(:app, :wp) do execute :sudo,
:service, 'php5-fpm', 'restart' end end ! after :publishing, :restart ! before :restart, :clear_cache do on roles(:app) do if fetch(:app_cache1_path) then execute :sudo, :find, fetch(:app_cache1_path), '-type f -exec rm {} \;' end if fetch(:app_cache2_path) then execute :sudo, :find, fetch(:app_cache2_path), '-type f -name "empty" -prune -o -type f -exec rm {} \;' end end end QIQGQNΛϦελʔτ͢Δ QVCMJTIJOHλεΫͷޙ ʹ࣮ߦͯ͠Ͷὑ Ϧελʔτ͢ΔલʹΩϟο γϡΛফ͠ͱ͍ͯͶὑ -
ͲΜͳίʔυʁ task :restart do on roles(:app, :wp) do execute :sudo,
:service, 'php5-fpm', 'restart' end end ! after :publishing, :restart ! before :restart, :clear_cache do on roles(:app) do if fetch(:app_cache1_path) then execute :sudo, :find, fetch(:app_cache1_path), '-type f -exec rm {} \;' end if fetch(:app_cache2_path) then execute :sudo, :find, fetch(:app_cache2_path), '-type f -name "empty" -prune -o -type f -exec rm {} \;' end end end QIQGQNΛϦελʔτ͢Δ QVCMJTIJOHλεΫͷޙ ʹ࣮ߦͯ͠Ͷὑ Ϧελʔτ͢ΔલʹΩϟο γϡΛফ͠ͱ͍ͯͶὑ طଘͷλεΫͷલޙʹҙͷλεΫΛ )PPL͢Δ -
ͲΜͳίʔυʁ namespace :notify do namespace :update do task :start do
_send_message("[\`#{fetch(:application)}\`] Deployment has started.") end ! task :finish do _send_message("[\`#{fetch(:application)}\`] Deployment has finished. :ok_woman:\n> #{fetch(:commit_message)}") end end ! namespace :rollback do task :start do _send_message("[\`#{fetch(:application)}\`] Rollback has started.\nCurrent Revision is \`#{fetch(:latest_revision)}\`") end ! task :finish do _send_message("[\`#{fetch(:application)}\`] Rollback has finished. :ok_woman:\nCurrent revision is \`#{fetch(:current_revision)}\`") end end end ! before 'deploy:starting', 'notify:update:start' after 'deploy:finishing', 'notify:update:finish' before 'deploy:reverting', 'notify:rollback:start' after 'deploy:finishing_rollback', 'notify:rollback:finish' $BQJTUSBOPʹΑΔσϓϩΠͷ࣮ߦ࣌ʹ4MBDL௨͢Δํ๏ -
ͲΜͳίʔυʁ namespace :notify do namespace :update do task :start do
_send_message("[\`#{fetch(:application)}\`] Deployment has started.") end ! task :finish do _send_message("[\`#{fetch(:application)}\`] Deployment has finished. :ok_woman:\n> #{fetch(:commit_message)}") end end ! namespace :rollback do task :start do _send_message("[\`#{fetch(:application)}\`] Rollback has started.\nCurrent Revision is \`#{fetch(:latest_revision)}\`") end ! task :finish do _send_message("[\`#{fetch(:application)}\`] Rollback has finished. :ok_woman:\nCurrent revision is \`#{fetch(:current_revision)}\`") end end end ! before 'deploy:starting', 'notify:update:start' after 'deploy:finishing', 'notify:update:finish' before 'deploy:reverting', 'notify:rollback:start' after 'deploy:finishing_rollback', 'notify:rollback:finish' σϓϩΠϩʔϧόοΫͷ։࢝ऴྃ ͷલޙʹ௨ΛૹΔ $BQJTUSBOPʹΑΔσϓϩΠͷ࣮ߦ࣌ʹ4MBDL௨͢Δํ๏ -
ͲΜͳίʔυʁ namespace :notify do namespace :update do task :start do
_send_message("[\`#{fetch(:application)}\`] Deployment has started.") end ! task :finish do _send_message("[\`#{fetch(:application)}\`] Deployment has finished. :ok_woman:\n> #{fetch(:commit_message)}") end end ! namespace :rollback do task :start do _send_message("[\`#{fetch(:application)}\`] Rollback has started.\nCurrent Revision is \`#{fetch(:latest_revision)}\`") end ! task :finish do _send_message("[\`#{fetch(:application)}\`] Rollback has finished. :ok_woman:\nCurrent revision is \`#{fetch(:current_revision)}\`") end end end ! before 'deploy:starting', 'notify:update:start' after 'deploy:finishing', 'notify:update:finish' before 'deploy:reverting', 'notify:rollback:start' after 'deploy:finishing_rollback', 'notify:rollback:finish' σϓϩΠϩʔϧόοΫͷ։࢝ऴྃ ͷલޙʹ௨ΛૹΔ $BQJTUSBOPʹΑΔσϓϩΠͷ࣮ߦ࣌ʹ4MBDL௨͢Δํ๏ ఆٛͨ͠3VCZͷؔ Λݺͼग़͢ -
ͲΜͳίʔυʁ namespace :notify do namespace :update do task :start do
_send_message("[\`#{fetch(:application)}\`] Deployment has started.") end ! task :finish do _send_message("[\`#{fetch(:application)}\`] Deployment has finished. :ok_woman:\n> #{fetch(:commit_message)}") end end ! namespace :rollback do task :start do _send_message("[\`#{fetch(:application)}\`] Rollback has started.\nCurrent Revision is \`#{fetch(:latest_revision)}\`") end ! task :finish do _send_message("[\`#{fetch(:application)}\`] Rollback has finished. :ok_woman:\nCurrent revision is \`#{fetch(:current_revision)}\`") end end end ! before 'deploy:starting', 'notify:update:start' after 'deploy:finishing', 'notify:update:finish' before 'deploy:reverting', 'notify:rollback:start' after 'deploy:finishing_rollback', 'notify:rollback:finish' σϓϩΠϩʔϧόοΫͷ։࢝ऴྃ ͷલޙʹ௨ΛૹΔ $BQJTUSBOPʹΑΔσϓϩΠͷ࣮ߦ࣌ʹ4MBDL௨͢Δํ๏ ఆٛͨ͠3VCZͷؔ Λݺͼग़͢ 3VCZͰ֦ு͢Δ -
ࣗಈԽͰ͖ͳ͔ͬͨ͜ͱ ‣ 8PSE1SFTTͷσϓϩΠ ‣ ϓϥάΠϯͷͳͲ ‣ 8FCΞϓϦ֎ͷ͜ͱ ‣ DSPOUBC ‣
ϦόʔεϓϩΩγͷઃఆ ‣ 8"'ʢ$BLF1)1ʣͷΞοϓάϨʔυ -
ࣗಈԽͷԸܙ # remote ! $ aptitude install nginx php5 php5-fpm
php5-mysql php5-json php5-curl postfix build-essential tmux vim zsh $ sudo ufw enable $ sudo ufw allow 22 $ sudo ufw allow 80 $ sudo vi /etc/ssh/sshd_config $ sudo vi /etc/php5/fpm/pool.d/www.conf $ git clone https://github.com/sstephenson/rbenv.git \ > /opt/rbenv $ git clone https://github.com/sstephenson/ruby-build.git \ > ~/opt/rbenv/plugins/ruby-build $ export PATH=“/opt/rbenv/bin:$PATH" $ eval "$(rbenv init -)” $ rbenv install 2.1.3 $ gem install bundler … $ export PERLBREW_ROOT=“/opt/perlbrew” $ curl -L http://install.perlbrew.pl | bash $ perlbrew install perl-5.18.2 $ perlbrew switch perl-5.18.2 $ curl -L http://cpanmin.us | perl - —sudo \ > App::cpanminus $ cpanm Carton … $ sudo rm /etc/nginx/site-enabled/default $ sudo vi /etc/nginx/site-available/my-site $ sudo ln -s /etc/nginx/site-available/my-site \ > /etc/nginx/site-enabled/my-site … $ sudo adduser hoge $ sudo adduser fuga … -
ࣗಈԽͷԸܙ # remote ! $ aptitude install nginx php5 php5-fpm
php5-mysql php5-json php5-curl postfix build-essential tmux vim zsh $ sudo ufw enable $ sudo ufw allow 22 $ sudo ufw allow 80 $ sudo vi /etc/ssh/sshd_config $ sudo vi /etc/php5/fpm/pool.d/www.conf $ git clone https://github.com/sstephenson/rbenv.git \ > /opt/rbenv $ git clone https://github.com/sstephenson/ruby-build.git \ > ~/opt/rbenv/plugins/ruby-build $ export PATH=“/opt/rbenv/bin:$PATH" $ eval "$(rbenv init -)” $ rbenv install 2.1.3 $ gem install bundler … $ export PERLBREW_ROOT=“/opt/perlbrew” $ curl -L http://install.perlbrew.pl | bash $ perlbrew install perl-5.18.2 $ perlbrew switch perl-5.18.2 $ curl -L http://cpanmin.us | perl - —sudo \ > App::cpanminus $ cpanm Carton … $ sudo rm /etc/nginx/site-enabled/default $ sudo vi /etc/nginx/site-available/my-site $ sudo ln -s /etc/nginx/site-available/my-site \ > /etc/nginx/site-enabled/my-site … $ sudo adduser hoge $ sudo adduser fuga … # local ! $ knife solo cookbook 192.168.0.1 -
ࣗಈԽͷԸܙ # remote ! $ aptitude install nginx php5 php5-fpm
php5-mysql php5-json php5-curl postfix build-essential tmux vim zsh $ sudo ufw enable $ sudo ufw allow 22 $ sudo ufw allow 80 $ sudo vi /etc/ssh/sshd_config $ sudo vi /etc/php5/fpm/pool.d/www.conf $ git clone https://github.com/sstephenson/rbenv.git \ > /opt/rbenv $ git clone https://github.com/sstephenson/ruby-build.git \ > ~/opt/rbenv/plugins/ruby-build $ export PATH=“/opt/rbenv/bin:$PATH" $ eval "$(rbenv init -)” $ rbenv install 2.1.3 $ gem install bundler … $ export PERLBREW_ROOT=“/opt/perlbrew” $ curl -L http://install.perlbrew.pl | bash $ perlbrew install perl-5.18.2 $ perlbrew switch perl-5.18.2 $ curl -L http://cpanmin.us | perl - —sudo \ > App::cpanminus $ cpanm Carton … $ sudo rm /etc/nginx/site-enabled/default $ sudo vi /etc/nginx/site-available/my-site $ sudo ln -s /etc/nginx/site-available/my-site \ > /etc/nginx/site-enabled/my-site … $ sudo adduser hoge $ sudo adduser fuga … # local ! $ knife solo cookbook 192.168.0.1 UBLFOCZXJFENBJFS -
$IFG ‣ #FSLTpMF ‣ DPPLCPPLT ‣ EBUB@CBHT ‣ FOWJSPONFOUT ‣
OPEFT ‣ SPMFT ‣ TJUFDPPLCPPLT -
ͲΜͳίʔυʁ directory service_dir do owner application_owner group application_owner mode '0755'
action :create recursive true not_if { ::File.exists?(service_dir) } end ! remote_file "#{source_dir}/cakephp-#{cake_full_version_number}.tar.gz" do source "https://github.com/cakephp/cakephp/archive/#{cake_full_version_number}.tar.gz" mode "0644" action :create_if_missing end ! execute "untar-cakephp" do cwd source_dir command "tar -xzf cakephp-#{cake_full_version_number}.tar.gz" creates "#{source_cake_dir}/index.php" end -
ͲΜͳίʔυʁ directory service_dir do owner application_owner group application_owner mode '0755'
action :create recursive true not_if { ::File.exists?(service_dir) } end ! remote_file "#{source_dir}/cakephp-#{cake_full_version_number}.tar.gz" do source "https://github.com/cakephp/cakephp/archive/#{cake_full_version_number}.tar.gz" mode "0644" action :create_if_missing end ! execute "untar-cakephp" do cwd source_dir command "tar -xzf cakephp-#{cake_full_version_number}.tar.gz" creates "#{source_cake_dir}/index.php" end σΟϨΫτϦΛ࡞͢Δ -
ͲΜͳίʔυʁ directory service_dir do owner application_owner group application_owner mode '0755'
action :create recursive true not_if { ::File.exists?(service_dir) } end ! remote_file "#{source_dir}/cakephp-#{cake_full_version_number}.tar.gz" do source "https://github.com/cakephp/cakephp/archive/#{cake_full_version_number}.tar.gz" mode "0644" action :create_if_missing end ! execute "untar-cakephp" do cwd source_dir command "tar -xzf cakephp-#{cake_full_version_number}.tar.gz" creates "#{source_cake_dir}/index.php" end σΟϨΫτϦΛ࡞͢Δ ϦϞʔτ͔ΒϑΝΠϧΛ औͬͯ͘Δ -
ͲΜͳίʔυʁ directory service_dir do owner application_owner group application_owner mode '0755'
action :create recursive true not_if { ::File.exists?(service_dir) } end ! remote_file "#{source_dir}/cakephp-#{cake_full_version_number}.tar.gz" do source "https://github.com/cakephp/cakephp/archive/#{cake_full_version_number}.tar.gz" mode "0644" action :create_if_missing end ! execute "untar-cakephp" do cwd source_dir command "tar -xzf cakephp-#{cake_full_version_number}.tar.gz" creates "#{source_cake_dir}/index.php" end σΟϨΫτϦΛ࡞͢Δ ϦϞʔτ͔ΒϑΝΠϧΛ औͬͯ͘Δ ରσΟϨΫτϦʹղౚ͢Δ -
ͲΜͳίʔυʁ directory service_dir do owner application_owner group application_owner mode '0755'
action :create recursive true not_if { ::File.exists?(service_dir) } end ! remote_file "#{source_dir}/cakephp-#{cake_full_version_number}.tar.gz" do source "https://github.com/cakephp/cakephp/archive/#{cake_full_version_number}.tar.gz" mode "0644" action :create_if_missing end ! execute "untar-cakephp" do cwd source_dir command "tar -xzf cakephp-#{cake_full_version_number}.tar.gz" creates "#{source_cake_dir}/index.php" end σΟϨΫτϦΛ࡞͢Δ ϦϞʔτ͔ΒϑΝΠϧΛ औͬͯ͘Δ ରσΟϨΫτϦʹղౚ͢Δ 3VCZͷ%4-ʹͳ͍ͬͯΔ -
ͲΜͳίʔυʁ default['gsskt-cakephp']['app_name'] = 'hogehoge' ! default['gsskt-cakephp']['http_server_owner'] = 'hoge' default['gsskt-cakephp']['application_owner'] =
'fuga' default['gsskt-cakephp']['deploy_parent'] = '/home/hoge' ! default['gsskt-cakephp']['cake1']['version'] = "1.3.0" default['gsskt-cakephp']['cake1']['debug_level'] = 0 default['gsskt-cakephp']['cake1']['use_analytics'] = true ! default['gsskt-cakephp']['cake2']['version'] = “2.1.0" default['gsskt-cakephp']['cake2']['debug_level'] = 0 default['gsskt-cakephp']['cake2']['use_analytics'] = true -
ͲΜͳίʔυʁ default['gsskt-cakephp']['app_name'] = 'hogehoge' ! default['gsskt-cakephp']['http_server_owner'] = 'hoge' default['gsskt-cakephp']['application_owner'] =
'fuga' default['gsskt-cakephp']['deploy_parent'] = '/home/hoge' ! default['gsskt-cakephp']['cake1']['version'] = "1.3.0" default['gsskt-cakephp']['cake1']['debug_level'] = 0 default['gsskt-cakephp']['cake1']['use_analytics'] = true ! default['gsskt-cakephp']['cake2']['version'] = “2.1.0" default['gsskt-cakephp']['cake2']['debug_level'] = 0 default['gsskt-cakephp']['cake2']['use_analytics'] = true ઃఆΛ্ॻ͖͢Δ͜ͱͰ ࠶ར༻Ͱ͖Δ -
ಋೖίετ ‣ ֻ͚िؒҐʢਓ݄ʣ ‣ ίετʹӨڹΛ༩͑Δཁૉ ‣ ߏͷෳࡶ͞ ‣ ։ൃऀͷࣝྔ ‣
ʢϗετͷنʹΑΒͳ͍ʣ