Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AWSを使っているならOpsWorksでDevOpsしよう!

 AWSを使っているならOpsWorksでDevOpsしよう!

2016/8/24に行った以下のイベントで使ったスライドです。
http://isao.connpass.com/event/37731/

0e7a809ed12558c5b148331d1a703ccb?s=128

Daiki Hirakata

August 29, 2016
Tweet

Transcript

  1. Twitter: #ISAOcorp AWSΛ࢖ͬͯΔͳΒOPSWORKSͰ DEVOPS͠Α͏ʂ @BIGPLANTS

  2. Twitter: #ISAOcorp ࣗݾ঺հ ฏܗ େथ @BIGPLANTS ▸ ࢁܗݝग़਎ 34ࡀ ABܕ

    ▸ גࣜձࣾISAOྺ 4೥ ▸ ιϑτ΢ΣΞΤϯδχΞྺ 6೥ ▸ OpsWorksྺ 3೥ ▸ ಘҙݴޠ͸PHP, Ruby͸গʑ ▸ ؔ৺ࣄ͸ΞδϟΠϧɺϦʔϯελʔτΞο ϓɺDevOpsɺTDDɺDDD ▸ ࠓ೥5݄ʹୈҰࢠ͕஀ੜ͠ΠΫϝϯΤϯδ χΞͱͯ͠ҭࣇฃಆதɻ
  3. Twitter: #ISAOcorp ࣗݾ঺հ OpsWorksͱԶ ▸ AWSͷOpsWorks։ൃνʔϜ͔ΒҙݟΛٻΊΒΕͨ࣌ɺૉ ௚ʹʮOpsWorks͸ؒҧ͍ͳ͘কདྷͷAWSͷओྗαʔϏε ʹͳΔͱ֬৴͍ͯ͠ΔͷͰվળΨϯΨϯ͓ئ͍͠·͢ʯͱ఻ ͑ͨ͘Β͍OpsWorksΛѪ͍ͯ͠·͢w ▸

    ৭ʑؾ೉͍͠΍ͭͰ͕͢ɻɻw
  4. Twitter: #ISAOcorp ࣗݾ঺հ ԶͷϓϩδΣΫτ “Goalous” Goalous: www.goalous.com

  5. Twitter: #ISAOcorp GOALOUSͷ։ൃʹ͍ͭͯ GoalousͷAWS؀ڥ

  6. Twitter: #ISAOcorp GOALOUSͷ։ൃʹ͍ͭͯ Goalousͷٕज़ελοΫ

  7. Twitter: #ISAOcorp GOALOUSͷ։ൃʹ͍ͭͯ GoalousͷDeploy Routine ཁ݅Λ(JU)VCJTTVFʹॻ͘ ͔Μ͹ΜϘʔυͰશମͷਐḿΛ؅ཧ (JU)VCJTTVFʹਐḿΛ࢒͢ σΟεΧογϣϯ (JU)VCͰίʔυϨϏϡʔ

    Ϛʔδ͓Αͼ σϓϩΠ
  8. Twitter: #ISAOcorp ΞδΣϯμ ࠓճ࿩͢͜ͱ ▸ ৽͍͠ϓϩδΣΫτΛ։࢝͢Δࡍʹ཈͓͑ͯ͘΂͖DevOpsͷ৺ಘ ʹ͍ͭͯ ▸ DevOpsΛࢧ͑Δपลπʔϧʹ͍ͭͯ ▸

    OpsWorksͷ֓ཁʹ͍ͭͯ ▸ OpsWorksΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTips ▸ ࠓ·Ͱىͬͨ͜໰୊ͱղܾํ๏ ▸ ·ͱΊ
  9. Twitter: #ISAOcorp ΞδΣϯμ ࠓճ࿩͞ͳ͍ࣄ ▸ Chefͷৄࡉʹ͍ͭͯ ▸ OpsWorksͷৄࡉͳ࢓༷ʹ͍ͭͯ ▸ पลπʔϧͷৄࡉʹ͍ͭͯ

  10. Twitter: #ISAOcorp ΞδΣϯμ ▸ ৽͍͠ϓϩδΣΫτΛ։࢝͢Δࡍʹ཈͓͑ͯ͘΂͖DevOpsͷ৺ಘ ʹ͍ͭͯ ▸ DevOpsΛࢧ͑Δपลπʔϧʹ͍ͭͯ ▸ OpsWorksͷ֓ཁʹ͍ͭͯ

    ▸ OpsWorksΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTips ▸ ࠓ·Ͱىͬͨ͜໰୊ͱղܾํ๏ ▸ ·ͱΊ
  11. Twitter: #ISAOcorp ৽͍͠ϓϩδΣΫτΛ։࢝͢Δࡍʹ཈͓͑ͯ͘΂͖DEVOPSͷ৺ಘʹ͍ͭͯ What’s DevOps? ▸ ։ൃ୲౰ऀ(Dev)ͱӡ༻୲౰ऀ(Ops)͕࿈ܞͯ͠ڠྗ͢Δ։ൃ ख๏Λ͢͞ɻ ▸ DevOpsͷ࣮ݱʹ͸ߏ੒؅ཧπʔϧͰ͋ΔChef΍Puppet͕

    ༻͍ΒΕΔ͜ͱ΋͋ΓɺDevOpsͱ͍͏ޠ͔۟Β͜͏ͨ͠ πʔϧ͕Πϝʔδ͞ΕΔ͜ͱ΋͋Δɻ
  12. Twitter: #ISAOcorp ৽͍͠ϓϩδΣΫτΛ։࢝͢Δࡍʹ཈͓͑ͯ͘΂͖DEVOPSͷ৺ಘʹ͍ͭͯ What’s DevOps?

  13. Twitter: #ISAOcorp ৽͍͠ϓϩδΣΫτΛ։࢝͢Δࡍʹ཈͓͑ͯ͘΂͖DEVOPSͷ৺ಘʹ͍ͭͯ ߟ͑Δ΂͖ࣄ(1) ▸ ։ൃνʔϜͱӡ༻νʔϜͷίϛϡχέʔγϣϯʹ͍ͭͯ ▸ ίʔυϕʔεͷίϛϡέʔγϣϯΛ໨ࢦ͢΂͠ɻto be programable.

    ▸ ৽͍͠։ൃऀ͕νʔϜʹࢀՃͨ͠ΒͲΜͳΦϖϨʔγϣϯ͕ඞཁ͔ʁ ▸ ༷ʑͳΦϖϨʔγϣϯͷίετΛࢼࢉ͠Α͏ɻ ▸ ͳΔ΂͘γϯϓϧͰগͳ͍खॱΛ৺ֻ͚Δ΂͠ɻ ▸ ࢀՃোน͸ͳΔ΂͘ഉআ͢ΔɻίϯτϦϏϡʔτ͠΍͍͢؀ڥΛ৺ֻ͚Δɻ ▸ OSSͷΞϓϩʔνΛࢀߟʹ͢ΔɻΨΠυΛॆ࣮ͤ͞Δ౳ɻ ▸ ςελϒϧɻ
  14. Twitter: #ISAOcorp ৽͍͠ϓϩδΣΫτΛ։࢝͢Δࡍʹ཈͓͑ͯ͘΂͖DEVOPSͷ৺ಘʹ͍ͭͯ ߟ͑Δ΂͖ࣄ(2) ▸ deployखॱ ▸ ԿεςοϓͷΦϖϨʔγϣϯ͔ʁͳΔ΂͘গͳ͍εςοϓΛ৺ֻ͚Δɻ ▸ ϩʔϧόοΫ͸Մೳ͔ʁ

    ▸ ϩʔΧϧ؀ڥɺεςʔδϯά؀ڥɺຊ൪؀ڥͷࠩҟΛ೺Ѳ͍ͯ͠Δ͔ʁ ▸ ۃྗࠩҟ͸গͳ͘͠Α͏ɻ ▸ εέʔϥϏϦςΟ ▸ αʔό୆਺ͷ૿ݮ͸؆୯ʹͰ͖Δ͔ʁ to be immutable.
  15. Twitter: #ISAOcorp ΞδΣϯμ ▸ ৽͍͠ϓϩδΣΫτΛ։࢝͢Δࡍʹ཈͓͑ͯ͘΂͖DevOpsͷ৺ಘ ʹ͍ͭͯ ▸ DevOpsΛࢧ͑Δपลπʔϧʹ͍ͭͯ ▸ OpsWorksͷ֓ཁʹ͍ͭͯ

    ▸ OpsWorksΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTips ▸ ࠓ·Ͱىͬͨ͜໰୊ͱղܾํ๏ ▸ ·ͱΊ
  16. Twitter: #ISAOcorp DEVOPSΛࢧ͑Δपลπʔϧʹ͍ͭͯ Version Control System ▸ ͢΂ͯͷߟ͑ํ͸͜͜ʹؼ݁͢Δɻ ▸ ؀ڥ΍υΩϡϝϯτ΋͢΂ͯόʔδϣϯ؅ཧ͞Ε͍ͯΔ΂͖ɻ

    ▸ ݴ͏·Ͱ΋ແ͍͕GitҰ୒ʂϦʔφε͞ΜʹܟҙΛɻ ▸ GitHub͕σϕϩούͷίϛϡχςΟΛരൃతʹՃ଎ͤͨ͞ʂ
  17. Twitter: #ISAOcorp DEVOPSΛࢧ͑Δपลπʔϧʹ͍ͭͯ CI Tool ▸ “ܧଓతΠϯςάϨʔγϣϯɺCIʢӳ: continuous integrationʣ ▸

    ϏϧυɺςετΛܧଓతʹ࣮ߦ͢Δɻ ▸ gitͷcommitʹ࿈ಈͯ͠commit୯ҐͰςετͨ͠Γɻ ▸ ݸਓతʹJenkins͸޷͖͡Όͳ͍ɻଐਓԽ͢Δ(ଏʹݴ͏ Jenkins͓͡͞ΜʹͳΔ)͠ɺͳΜͰ΋ΞϦʹͳͬͯ͠·͏ɻ
  18. Twitter: #ISAOcorp DEVOPSΛࢧ͑Δपลπʔϧʹ͍ͭͯ CI Tool 2016.08.22࣌఺ ग़యݩ:stackshare
 http://stackshare.io/continuous-integration

  19. Twitter: #ISAOcorp DEVOPSΛࢧ͑Δपลπʔϧʹ͍ͭͯ Provisioning Tools ▸ Chef͸ϑϧελοΫ&ઌൃɻ ▸ ߏ੒؅ཧπʔϧͷதͰݱࡏਓؾ͕͋Δͷ͸Ansibleɻ 2016.08.22࣌఺

    ग़యݩ:stackshare
 http://stackshare.io/server-configuration-and- automation
  20. Twitter: #ISAOcorp DEVOPSΛࢧ͑Δपลπʔϧʹ͍ͭͯ Other ▸ docker ▸ Vagrant

  21. Twitter: #ISAOcorp ΞδΣϯμ ▸ ৽͍͠ϓϩδΣΫτΛ։࢝͢Δࡍʹ཈͓͑ͯ͘΂͖DevOpsͷ৺ಘ ʹ͍ͭͯ ▸ DevOpsΛࢧ͑Δपลπʔϧʹ͍ͭͯ ▸ OpsWorksͷ֓ཁʹ͍ͭͯ

    ▸ OpsWorksΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTips ▸ ࠓ·Ͱىͬͨ͜໰୊ͱղܾํ๏ ▸ ·ͱΊ
  22. Twitter: #ISAOcorp OPSWORKSͷ֓ཁʹ͍ͭͯ OpsWorks ▸ OpsWorksͬͯԿʁ ▸ AWSαʔϏεͷҰͭͰελοΫΛ·ͱΊͯ؅ཧ͢Δҝͷ࢓૊Έɻ ▸ ChefΛ࢖ͬͯϓϩϏδϣχϯά͢Δɻ

    ▸ ͲΜͳγνϡΤʔγϣϯͰ༗ޮ׆༻Ͱ͖Δͷʁ ▸ Α͋͘ΔελοΫͰELBʹΞϓϦέʔγϣϯαʔόΛͿΒԼ͛ͯɺDB͸RDS࢖ͬͯΔ ৔߹ͳͲΛ࢖ͬͯΔ৔߹ͳͲɻ ▸ ΞϓϦέʔγϣϯͷσϓϩΠɺߏ੒؅ཧΛू໿͍ͨ͠৔߹ͳͲɻ ▸ OpsWorksͷৄ͍֓͠ཁ͸ͪ͜Β ▸ AWS https://docs.aws.amazon.com/ja_jp/opsworks/latest/userguide/welcome.html
  23. Twitter: #ISAOcorp OPSWORKSͷ֓ཁʹ͍ͭͯ શମ૾

  24. Twitter: #ISAOcorp OPSWORKSͷ֓ཁʹ͍ͭͯ શମ૾ ▸ ࠷্Ґͷ֓೦͕stack ▸ ͦͷԼ͕Layerͱ͍͏֓೦ ▸ ͜͜ॏཁʂ

    ▸ ΞϓϦέʔγϣϯαʔόͷ͋ΒΏΔ΋ͷΛ؅ཧ͢Δɻద༻͢ΔϨγϐͱ͔ɻ ▸ Πϯελϯε୯ମͰ͸ͳ͘LayerΛҙࣝ͢ΔΑ͏ʹ͢Δɻ ▸ CookbookͷϦϙδτϦΛඥ෇͚Δ ▸ ΞϓϦέʔγϣϯͷϦϙδτϦΛඥ෇͚Δ ▸ ELBΛඥ෇͚Δ ▸ RDSΛඥ෇͚Δ ▸ ৄ͘͠͸ɺҎԼͷϋϯζΦϯࢿྉΛ
 http://www.slideshare.net/AmazonWebServicesJapan/aws-opsworks
  25. Twitter: #ISAOcorp OPSWORKSͷ֓ཁʹ͍ͭͯ OpsWorksͷಛ௃(1) ▸ ελοΫΛؙ͝ͱ؅ཧͰ͖Δɻ ▸ Πϯελϯεͷछྨ ▸ 24/7

    : ͍ͭͰ΋खಈͰ্͛Լ͛Ͱ͖Δɻ ▸ Time-based : ىಈΛεέδϡʔϦϯάͰ͖Δɻ ▸ ෛՙ͕͔͔Δ࣌ؒଳ΍༵೔Λࢦఆͯ͠ىಈ୆਺ΛࢦఆՄೳɻ ▸ Load-based : CPUɺϝϞϦ࢖༻཰ʹΑͬͯΦʔτεέʔϦϯάͰ͖Δɻ ▸ ͜ͷΦʔτεέʔϧ͸࣮༻͸೉͍͠ɻɻChefΛ࣮ߦ͢ΔͨΊΠϯε λϯεͷىಈ͕࣌ؒͲ͏ͯ͠΋͔͔ͬͯ͠·͏ɻ
  26. Twitter: #ISAOcorp OPSWORKSͷ֓ཁʹ͍ͭͯ OpsWorksͷಛ௃(2) ▸ ϥΠϑαΠΫϧΠϕϯτͱ͍͏֓೦ͰɺΠϯελϯεىಈ࣌ɺ deploy࣌ͳͲͦΕͧΕͰద༻͢ΔϨγϐΛࢦఆͰ͖Δɻ ▸ deployͷϩʔϧόοΫ΋Ͱ͖Δɻ ▸

    ελοΫΛΫϩʔϯͰ͖Δɻ ▸ ઃఆΛ͢΂ͯҾ͖ܧ͛Δɻ ▸ ຊ൪؀ڥ͔ΒΫϩʔϯͯ͠εςʔδϯά؀ڥΛߏங͢Δͱ ͔ɻ
  27. Twitter: #ISAOcorp OPSWORKSͷ֓ཁʹ͍ͭͯ Lifecycle Event(Α͘࢖͏΍ͭ) ▸ Setup ▸ Πϯελϯεىಈ࣌ʹ࣮ߦ͞ΕΔɻ ▸

    ΊͪΌͪ͘Ό࢖͏ͱ͜Ζɻ ▸ Deploy ▸ σϓϩΠͷࢦࣔΛͨ࣌͠ʹൃੜ͢Δɻ ▸ ΊͪΌͪ͘Ό࢖͏ͱ͜Ζɻ ▸ Configure ▸ Πϯελϯε͕ىಈɺఀࢭͨ͠ࡍʹε λοΫ಺ͷ͢΂ͯͷΠϯελϯεͰൃ ੜ͢ΔɻΠϯελϯεͷIPΛશΠϯε λϯεͰ؅ཧ͍ͯ͠Δ࣌ͱ͔࢖͑Δɻ
  28. Twitter: #ISAOcorp OPSWORKSͷ֓ཁʹ͍ͭͯ Lifecycle Event(͋·Γ࢖Θͳ͍΍ͭ) ▸ Undeploy ▸ ΞϓϦέʔγϣϯΛ࡟আ ͨ࣌͠ʹൃੜɻ

    ▸ Shutdown ▸ ΠϯελϯεΛఀࢭ͢Δ ࣌ʹൃੜ͢Δ ▸ ޙॲཧతͳ΋ͷɻԿ͔͠ Βͷ઀ଓ੾ͬͨΓɻ
  29. Twitter: #ISAOcorp OPSWORKSͷ֓ཁʹ͍ͭͯ OpsWorksͷΠέͯΔͱ͜Ζ ▸ Chefͷ஌ݟΛ׆͔ͤΔ ▸ AWSͷطଘϦιʔεΛར༻Ͱ͖Δ ▸ AMIΛར༻Ͱ͖Δ

    ▸ ϦιʔεΛϨΠϠ୯ҐͰϞχλͰ͖Δ ▸ Ϧιʔε഑෼ΛεέδϡʔϦϯάͰ͖Δ ▸ ELB΁ͷඥ෇͚Λࣗಈతʹ΍ͬͯ͘ΕΔ
  30. Twitter: #ISAOcorp OPSWORKSͷ֓ཁʹ͍ͭͯ OpsWorksͷΠέͯͳ͍ͱ͜Ζ(௚ͯ͠ཉ͍͠఺ͦͷ̍) ▸ Πϯελϯεͷىಈ͕஗͍ ▸ LayerͱAppͷඥ෇͚͕ͳ͍(ͳͥͳͷ͔ٙ͘͢͝໰)ͷͰෳ ਺LayerͰͦΕͧΕผAppΛdeploy͢Δͷ͕໘౗ɻશͯͷ Layerʹdeployࢦ͕ࣔඈΜͰ͠·͏ɻ

    ▸ Ͱ͖ͳ͍Θ͚Ͱ͸ͳ͍ɻσϓϩΠϑοΫΛར༻ͯ͠ΞϓϦ έʔγϣϯ໊Ͱ൑அ͢Ε͹Մೳɻ
  31. Twitter: #ISAOcorp OPSWORKSͷ֓ཁʹ͍ͭͯ OpsWorksͷΠέͯͳ͍ͱ͜Ζ(௚ͯ͠ཉ͍͠఺ͦͷ̎) ▸ instance storeΛར༻ͨ͠৔߹ͷAMIͷΦϖϨʔγϣϯ͕൥ ࡶɻ ▸ ࣮ߦ͢ΔϨγϐΛมߋͨ͠৔߹ɺىಈ࣌ʹ࣮ߦϨγϐͷϦε

    τΛࣗಈͰߋ৽ͯ͘͠Εͳ͍ɻ ▸ ىಈͨ͠ޙʹupdate_custom_CookbookΛ࣮ߦͯ͠ɺ࠶౓ setupΛ͠ͳ͍ͱ͍͚ͳ͍ɻ ▸ Chef11ܥ->12ܥ΁ͷΞοϓάϨʔυ͸ෆՄɻstackΛ࡞Γ௚ ͔͢͠ͳ͍ɻɻ
  32. Twitter: #ISAOcorp OPSWORKSͷ֓ཁʹ͍ͭͯ Chef12ʹ͍ͭͯ ▸ Chef12ͰมΘͬͨࣄ ▸ ໊લۭؒ ▸ build-inΫοΫϒοΫͷ੾Γ཭͠

    ▸ Berkshelfͷαϙʔτ΍Ίͨ ▸ ίϛϡχςΟΫοΫϒοΫΛΨϯΨϯ׆༻Ͱ͖ΔΑ͏ʹͳͬͨ ▸ ৄ͘͠͸ެࣜϦϑΝϨϯεͰ
 http://docs.aws.amazon.com/ja_jp/opsworks/latest/userguide/ chef-12-linux.html
  33. Twitter: #ISAOcorp ΞδΣϯμ ▸ ৽͍͠ϓϩδΣΫτΛ։࢝͢Δࡍʹ཈͓͑ͯ͘΂͖DevOpsͷ৺ಘ ʹ͍ͭͯ ▸ DevOpsΛࢧ͑Δपลπʔϧʹ͍ͭͯ ▸ OpsWorksͷ֓ཁʹ͍ͭͯ

    ▸ OpsWorksΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTips ▸ ࠓ·Ͱىͬͨ͜໰୊ͱղܾํ๏ ▸ ·ͱΊ
  34. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS ͜ͷTips͸ҎԼ͕લఏͰ͢ ▸ ΞϓϦέʔγϣϯͷ؀ڥ ▸ OS͸ubuntu ▸ ݴޠ͸PHP

    ▸ ։ൃ؀ڥ ▸ mac ▸ OpsWorks ▸ Chef11.10ར༻ ▸ ※ฐࣾͷϓϩδΣΫτGoalousͰશͯͷTipsΛ࠾༻͓ͯ͠Γ·͢ɻ
  35. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS VagrantͱOpsWorksͰར༻͢ΔCookbooksΛڞ༗͢Δ ▸ VagrantͰϩʔΧϧ։ൃ؀ڥΛߏங ▸ ChefͷϨγϐ͸ݶΓͳ͘ڞ௨Խ͢Δ ▸ ϩʔΧϧ؀ڥͰಈ͍͚ͨͲεςʔδϯάͰಈ͔ͳ͍ɻ

    ͱ͔ճආͰ͖Δɻ
  36. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS VagrantͱOpsWorksͰར༻͢ΔCookbooksΛڞ༗͢Δ ▸ Version ▸ Chef Development Kit

    Version: 0.17.17 ▸ Vagrant 1.8.4 ▸ virtual box: Version 5.0.20
  37. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS VagrantͱOpsWorksͰར༻͢ΔCookbooksΛڞ༗͢Δ

  38. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS VagrantͱOpsWorksͰར༻͢ΔCookbooksΛڞ༗͢Δ ▸ OpsWorks͔Βར༻͢ΔCookbook ͷϦϙδτϦʹҎԼΛؚΊΔ ▸ ެ։؀ڥͷΈʹద༻͢Δ Cookbook

    ▸ ϩʔΧϧ։ൃ؀ڥͷΈʹద༻͢Δ Cookbook ▸ ͜ͷϦϙδτϦ͸ɺୈҰ֊૚ʹ CookbookΛฒ΂Δඞཁ͋Γɻ ▸ ChefͷϦϙδτϦͱ͸σΟϨΫ τϦߏ੒͕ҧ͏఺ʹ஫ҙɻ
  39. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS VagrantͱOpsWorksͰར༻͢ΔCookbooksΛڞ༗͢Δ ▸ CookbooksͷϦϙδτϦΛΞϓ ϦέʔγϣϯͷϦϙδτϦʹ submoduleͱͯ͠૊ΈࠐΉ ▸ ͜ΕͰVagrant͔ΒࢀরͰ͖ΔΑ

    ͏ʹͳΔɻ ▸ git clone —recursive git@github.com:hoge/fuga ▸ Vagrant up ▸ Ҏ্ʂʂ
  40. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS BerkshelfΛར༻͢Δ ▸ Berkshelf͸ChefͷCookbookΛύοέʔδ؅ཧతʹ؅ ཧͯ͘͠ΕΔ΍ͭɻRubyͰ͍͏gemΈ͍ͨͳ΋ͷɻ ▸ Berksfileͱ͍͏ϑΝΠϧͰґଘΛ؅ཧ͢Δɻ ▸

    OpsWorksͰChef11.10Λબ୒ͨ͠৔߹ʹར༻Մೳɻ ▸ VagrantͰ͸ɺChefDKͷΠϯετʔϧ͕ඞཁɻ
  41. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS OpsWorksͰͷBerkshelfͷઃఆ ▸ stackͷsettingͰҎԼΛઃఆ ▸ Chef version: 11.10

    ▸ Manage Berkshelf: yes
  42. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS VagrantͰͷBerkshelfͷઃఆ(1) ▸ ChefDKΛΠϯετʔϧ ▸ pathͷઃఆ ▸ export

    PATH=/opt/Chefdk/bin:$PATH ▸ Vagrant-BerkshelfΛΠϯετʔϧ ▸ Vagrant plugin install Vagrant-Berkshelf ▸ VagrantfileͰBerkshelfͷઃఆ(࣍ͷεϥΠυ)
  43. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS VagrantͰͷBerkshelfͷઃఆ(2)

  44. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS ChefͷCookbooksͷϦϙδτϦʹberksfileΛ഑ஔ

  45. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS Berkshelfͷ஫ҙ఺(1) ▸ VagrantͱOpsWorksͰ BerkshelfΛར༻͢Δ৔߹ͷ ஫ҙ఺Ͱ͢ɻ ▸ build-essentialͱapt͸όʔ

    δϣϯࢦఆ(͠ͳ͍ͱChef12 ࢓༷ʹͳͬͯ͠·͍ίέΔ) ▸ metadata͸ࢦఆ͠ͳ͍
  46. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS Berkshelfͷ஫ҙ఺(2) ▸ ࣗલͷCookbook͸͢΂ͯ pathࢦఆͰهࡌ ▸ VagrantͰBerkshelfར༻ ࣌ʹCookbook_pathΛ্

    ॻ͖ͯ͠͠·͏ҝ ▸ ࣗલͷCookbookʹ͸ metadata.rbΛ഑ஔ͢Δ
  47. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS travisʹdeployͤ͞Δ ▸ travisΛར༻ͯ͠ςετ׬ྃޙ ʹOpsWorksʹσϓϩΠࢦࣔ Λग़͢Α͏ʹ͢Δɻ ▸ gitͷϒϥϯνΛ֤؀ڥʹඥ෇

    ͚Δɻ ▸ GitHubͷϓϧϦΫͷϚʔδΛ ܖػʹϫϯετοϓͰσϓϩ ΠՄೳɻ<-- ૉఢʂ
  48. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS travisʹdeployͤ͞Δ

  49. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS travisʹdeployͤ͞Δ ▸ .travis.ymlϑΝΠϧʹσϓϩΠ ઌΛࢦఆ ▸ app-id͸OpsWorksͷAppͷ OpsWorks

    ID ▸ දهͷҧ͍ʹ஫ҙʂ
  50. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS OpsWorks.phpΛ͏·͘ར༻͢΂͠  ▸ OpsWorks.php ͸setup, deploy࣌ʹग़ྗ͞ΕΔϑΝΠ ϧɻ

    ▸ ΞϓϦέʔγϣϯίʔυ͕ஔ͔ Ε͍ͯΔσΟϨΫτϦͷϧʔτ ʹ഑ஔ͞ΕΔɻ ▸ stack಺ͷ͋ΒΏΔϦιʔεͷ ઀ଓ৘ใ͕هࡌɻ ▸ ΞϓϦέʔγϣϯ಺͔Β༰қʹ ઀ଓͰ͖Δɻ
  51. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS OpsWorks.phpΛ͏·͘ར༻͢΂͠  ▸ frameworkͷdatabaseઃ ఆͰઃఆΛஔ͖׵͑Δɻ

  52. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS खಈΠϯετʔϧɺઃఆ͸ޚ๏౓ʂ ▸ ΠϯελϯεʹSSHͯ͠ύοέʔδΠϯε τʔϧͨ͠Γɺઃఆมߋͨ͠Γ͢Δͷ͸μ ϝʂઈରʂ ▸ ඞͣChefͷrecipeͰద༻͢ΔΑ͏ʹ͢Δɻ

    ▸ test kitchenͰVagrant্ͰrecipeΛςετ ͢Δͱͳ͓Α͠ʂ ▸ ΠϯελϯεͰ͸ͳ͘Layerʹ໨Λ޲͚Δɻ
  53. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS OpsWorksͷcustome jsonʹ؀ڥݻ༗ͷ৘ใΛ࣋ͨͤΔ ▸ stackͷsettingͷAdvanced optionsͷCustom JSONʹ؀ڥ ݻ༗ͷ஋Λkey

    valueͰهࡌɻ ▸ CookbookͰ͜ΕΒͷkey valueΛΞϓϦέʔγϣϯͷม ਺ʹల։ɻ ▸ ͜ΕͰCustom JsonͷΈͰ؀ڥ ผͷઃఆ͕Մೳɻ
  54. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS ىಈ࣌ؒΛ୹ॖ͢Δ৔߹͸AMIͷར༻Λݕ౼ ▸ Πϯελϯεͷ৽ن௥Ճ࣌͸15෼Ҏ্͔͔Δέʔ ε΋͋Δɻ ▸ ىಈ࣌ؒͷ୹ॖΛ͍ͨ͠৔߹͸AMIΛར༻͢Δɻ ▸

    OpsWorksͰͷAMIར༻ʹؔͯ͠͸ҎԼΛࢀর
 http://docs.aws.amazon.com/ja_jp/opsworks/ latest/userguide/workinginstances-custom- ami.html ▸ ࠷৽ͷϓϩϏδϣχϯάࡁΈͷΠϯελϯεͰ AMIΛͱΔɻ ▸ Πϯελϯε௥Ճ࣌ʹcustom AMIΛࢦఆ(ӈਤ) ▸ ͜ΕͰىಈ͕࣌ؒ5෼ͱ͔ʹ୹ॖՄೳɻ
  55. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS AMIར༻࣌ͷ஫ҙ఺ ▸ ႈ౳ੑ͕ࣦΘΕͳ͍Α͏ʹؾΛ͚ͭΔɻ ▸ Πϯελϯε௥Ճ࣌ͷΦϖϨʔγϣϯ͕૿ ͑Δɻ ▸

    ͍ͭ࣌఺ͷAMIͳͷ͔؅ཧ͕ඞཁʹͳΔɻ ▸ ※ͦ΋ͦ΋ԿͷҝʹChefΛར༻͍ͯ͠Δ ͔ʁOpsWorksΛར༻͍ͯ͠Δ͔Α͘ߟ͑ ΔɻAMIΛར༻͢Ε͹ͦͷ෼ίετͱϦεΫ ͕ൃੜ͢ΔࣄΛ೦಄ʹஔ͘ඞཁ͋Γɻ
  56. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS instance storeͷར༻ ▸ OpsWorksͰͷΠϯελϯεͷϘϦϡʔϜ͸EBSΑΓinstance store ͷํ͕޲͍͍ͯΔɻ ▸

    instance store͸Πϯελϯεఀࢭ࣌ʹഁغ͞ΕΔɻ ▸ ΑΓImmutable ʹͳΔɻ ▸ instance store͸͕͔͔ۚΒͳ͍ɻEBSͷ৔߹͸ఀࢭ͍ͯͯ͠΋͓ ͕͔͔ۚΔɻେྔͷΠϯελϯεΛѻ͏৔߹͸ݕ౼ͯ͠΋ྑ͍͔΋ɻ ▸ ͨͩ͠ɺAMIΛར༻͢Δ৔߹ͷΦϖϨʔγϣϯ͕௒ΊΜͲ͘͞ ͍ɻɻ
  57. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS σϓϩΠϑοΫΛར༻͢΂͠(ͦͷ̍) ▸ deploy࣌ʹ௥ՃॲཧΛߦ͍͍ͨ৔߹͸ίʔϧόοΫΛར༻͢Δɻ ▸ ΞϓϦέʔγϣϯίʔυʹdeployσΟϨΫτϦΛ༻ҙ͠ɺҎԼͷϑΝΠϧΛ഑ஔ ▸ before_migrate.rb

    – νΣοΫΞ΢τεςʔδͷ׬ྃޙɺҠߦεςʔδͷલʹ ࣮ߦ͠·͢ɻ ▸ before_symlink.rb – Ҡߦεςʔδͷ׬ྃޙɺγϯϘϦοΫϦϯΫεςʔδͷ લʹ࣮ߦ͠·͢ɻ ▸ before_restart.rb – γϯϘϦοΫϦϯΫεςʔδͷ׬ྃޙɺ࠶ىಈεςʔδͷ લʹ࣮ߦ͠·͢ɻ ▸ after_restart.rb – ࠶ىಈεςʔδͷ׬ྃޙʹ࣮ߦ͠·͢ɻ ▸ ͜ΕͰΞϓϦέʔγϣϯݻ༗ͷॲཧΛ௥ՃͰ͖Δɻ
  58. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS σϓϩΠϑοΫΛར༻͢΂͠(ͦͷ̎) ▸ ஫ҙ఺ͱͯ͠͸ɺCookbookͱΞϓϦέʔγϣϯ͕ͳ Δ΂͘૬ޓʹґଘ͠ͳ͍Α͏ʹ͢Δɻ ▸ setupͰ࣮ߦ͞ΕΔϨγϐͱσϓϩΠϑοΫ͕ґଘ͠ ߹ͬͯͨΓ͢Δͱdeploy࣌ʹsetupΛ࣮ߦ͠ͳ͍ͱ

    ͍͚ͳ͘ͳΔɻ ▸ ৄ͘͠͸ެࣜϦϑΝϨϯεʹͯ
 https://docs.aws.amazon.com/ja_jp/opsworks/latest/ userguide/workingcookbook-extend-hooks.html
  59. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS ΫοΫϒοΫͷ্ॻ͖໰୊(Chef11ܥ) ▸ OpsWorksͷΫοΫϒοΫ͸ɺ૊ΈࠐΈΫοΫϒοΫɺ BerkshelfΫοΫϒοΫɺΧελϜΫοΫϒοΫͱ̏छྨ͋Δɻ ▸ ্هΫοΫϒοΫ͸ಉ໊͡લͷϨγϐ͕ଘࡏ͢Δ৔߹ɺϚʔδ ͞ΕΔɻ<-

    ͜͜ΊͪΌͪ͘ΌϋϚΔɻɻɻ ▸ ՄೳͰ͋Ε͹Chef12ਪ঑ɻ ▸ ৄ͘͠͸ެࣜϦϑΝϨϯεͰ
 https://docs.aws.amazon.com/ja_jp/opsworks/latest/ userguide/workingcookbook-chef11-10.html
  60. Twitter: #ISAOcorp OPSWORKSΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTIPS ChefͷόʔδϣϯΞοϓͷ஫ҙ఺ ▸ update_custom_CookbookΛߦͬͯ΋Chef version͸ߋ ৽͞Εͳ͍ɻ ▸ ΦϖϨʔγϣϯ

    ▸ OpsWorksͷstackઃఆͰChefͷόʔδϣϯΛ੾Γସ͑ ▸ ৽نͰ1୆ϨΠϠʹ௥Ճ ▸ ৽ن௥Ճͨ͠Πϯελϯε͕ىಈͨ͠ΒɺଞΛ͢΂ͯ ࡟আ͠ɺ࠶౓௥Ճ͢Δɻ
  61. Twitter: #ISAOcorp ΞδΣϯμ ▸ ৽͍͠ϓϩδΣΫτΛ։࢝͢Δࡍʹ཈͓͑ͯ͘΂͖DevOpsͷ৺ಘ ʹ͍ͭͯ ▸ DevOpsΛࢧ͑Δपลπʔϧʹ͍ͭͯ ▸ OpsWorksͷ֓ཁʹ͍ͭͯ

    ▸ OpsWorksΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTips ▸ ࠓ·Ͱىͬͨ͜໰୊ͱղܾํ๏ ▸ ·ͱΊ
  62. Twitter: #ISAOcorp ࠓ·Ͱىͬͨ͜໰୊ͱղܾํ๏ inodeރׇ໰୊ ▸ ݱ৅ ▸ deploy͕Կ౓΋ࣦഊ͢Δ͕ɺChefͷϩάݟͯ΋ຖճΤϥʔ͕ҧ͏ɻɻ ▸ ݪҼ

    ▸ node_modules഑ԼͷϑΝΠϧ਺͕7ສΛ௒͍͑ͯͨʂ ▸ ࣦഊͨ͠ੈ୅Λอ͓࣋ͯ͠Γɺinode͕ރׇʂ ▸ inode֬ೝํ๏: df -i ▸ ରԠ ▸ ؅ཧ͢Δੈ୅ΛσϑΥϧτͷ̑ੈ୅͔Β̎ੈ୅ʹมߋͨ͠ɻ ▸ custom jsonͰ؅ཧ͢Δੈ୅਺ΛࢦఆՄೳ(ӈਤ)
  63. Twitter: #ISAOcorp ࠓ·Ͱىͬͨ͜໰୊ͱղܾํ๏ Chef11.04໰୊ ▸ ݱ৅ ▸ OpsWorksͰChef11.04Λར༻͍ͯ͠ΔͱcloneͰ͖ͳ͍ɻadd instanceͰ͖ͳ͍(௒க໋తʂʂ) ▸

    ຖճɺύϥϝʔλ͕ෆਖ਼ͱ͍͏ෆ਌੾ͳΤϥʔදࣔɻ ▸ ݪҼ ▸ Α͘Θ͔ΒΜɻOpsWorksଆͷ࢓༷มߋʹΑΔ΋ͷɻ ▸ ରԠ ▸ Chef11.10ʹΞοϓάϨʔυͨ͠Βղফɻ
  64. Twitter: #ISAOcorp ࠓ·Ͱىͬͨ͜໰୊ͱղܾํ๏ stack setting͕อଘͰ͖ͳ͍ ▸ ݱ৅ ▸ OpsWorksͰstack settingΛอଘ͠Α͏ͱ͢ΔͱOpsWorks

    id͕ݟ͔ͭΒͳ͍ɻͱ͔༁ͷΘ͔Βͳ͍Τϥʔ͕ɻ ▸ ݪҼ ▸ Α͘Θ͔ΒΜɻOpsWorksͷόάɻଟ෼ɻ ▸ ରԠ ▸ twittter౳ͰAWSαϙʔτʹͭ͘͜͠ݴ͍ଓ͚ͨΒ࣍ͷ೔ղ ফ͞Ε͍ͯͨɻ
  65. Twitter: #ISAOcorp ΞδΣϯμ ▸ ৽͍͠ϓϩδΣΫτΛ։࢝͢Δࡍʹ཈͓͑ͯ͘΂͖DevOpsͷ৺ಘ ʹ͍ͭͯ ▸ DevOpsΛࢧ͑Δपลπʔϧʹ͍ͭͯ ▸ OpsWorksͷ֓ཁʹ͍ͭͯ

    ▸ OpsWorksΛ࣮ۀ຿ʹ׆༻͢ΔͨΊͷTips ▸ ࠓ·Ͱىͬͨ͜໰୊ͱղܾํ๏ ▸ ·ͱΊ
  66. Twitter: #ISAOcorp ·ͱΊ ▸ ϓϩδΣΫτΛ։࢝͢Δࡍ͸ɺεέʔϥϏϦςΟΛߟྀͯ͠؀ڥߏஙɺσ ϓϩΠखॱΛ໌֬ʹ͠Α͏ɻΦϖϨʔγϣϯΛγϯϓϧʹɺଐਓԽͤ͞ͳ ͍Α͏ʹ͢Δํ๏Λݕ౼͠Α͏ɻ ▸ immutable Ͱ͋Εʂ࠷௿Ͱ΋Կ͔໰୊͋Ε͹0͔Β࡞Γͳ͓͠Ό͍͍͡Ό

    Μɻͱݴ͑Δঢ়ଶʹ͠Α͏ɻ ▸ Chef͸৭ʑݴΘΕ͍ͯΔ͚ͲϓϩϏδϣχϯάπʔϧͷσϑΝΫτͩ͠ɺ ·ͣ͸৮ͬͯΈΑ͏ʂ ▸ ༷ʑͳΫϥ΢υͷπʔϧΛར༻͠Α͏ɻ ▸ Ϛωʔδ͞Ε͍ͯͯεέʔϥϒϧͳπʔϧ͕٢ɻ ▸ ૊ΘΘͤΔࣄͰϋοϐʔʹͳΕ·͢ʂ ▸ OpsWorksΑ͍Α( ´ ˜ ` )ů
  67. ISAO͸ΤϯδχΞ ΛઈࢍืूதͰ͢ʂ

  68. ͝ਗ਼ௌ ͋Γ͕ͱ͏ ͍͟͝·ͨ͠ʂ