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

Puppet & Chef

Puppet & Chef

新卒研修でやった座学の内容。
既に Puppet & serverspec で研修を進めていたので、まとめと周辺知識の関連付け。

Shinya Tsunematsu

June 21, 2013
Tweet

More Decks by Shinya Tsunematsu

Other Decks in Programming

Transcript

  1. 2013/06/21 @tnmt
    Puppet ΍ Chef ͷجૅ
    ͳΜͰඞཁͳͷͱ͔

    View full-size slide

  2. ຊ೔ͷΞδΣϯμ
    ✤ Puppet, Chefͱ͸
    ✤ Puppet, Chefͷඞཁੑ
    ✤ Puppet, Chefͷߏ੒
    ✤ ΠϯϑϥͷίʔυԽͱͦͷपล஌ࣝ

    View full-size slide

  3. Puppet, Chefͱ͸

    View full-size slide

  4. Puppet, Chef
    ✤ Provisioning Framework < Configuration Management
    Framework

    View full-size slide

  5. Configuration Management
    ✤ ߏ੒؅ཧͷλεΫྫ
    ✤ ωοτϫʔΫઃఆ
    ✤ Ϣʔβ࡞੒ɾ؅ཧ
    ✤ ιϑτ΢ΣΞΠϯετʔϧઃఆ
    ✤ ͜ΕΒΛ”͋Δ΂͖ঢ়ଶ”ʹҡ࣋͢Δ͜ͱ͕ߏ੒؅ཧ
    ✤ ͦΕΛ࣮ݱ͢ΔͨΊͷπʔϧ͕Puppet, Chef

    View full-size slide

  6. Puppet, Chefͷඞཁੑ

    View full-size slide

  7. ৄ͘͠͸
    ✤ mizzy͞ΜͷPuppet࿈ࡌॳճ http://gihyo.jp/admin/serial/01/
    puppet/0001 ΍
    ✤ antipop͞Μͷ”ೖ໳Puppet”ୈ1ষ ʮͳͥPuppet͕ඞཁͳͷ͔ʁʯ
    ✤ Λࢀߟʹ…͍ͬͯ͏ͱ͋ΕͳͷͰ࣮ࡍಡΈ߹Θͤ

    View full-size slide

  8. ߏ੒؅ཧλεΫͷ࣮ݱํ๏ʢ̍ʣ
    ✤ खॱॻʹΑΔखಈઃఆ
    ✤ ख࡞ۀʹΑΔ࣌ؒͷϩε
    ✤ ΦϖϨʔγϣϯϛεͷՄೳੑ
    ✤ खॱॻͷߋ৽๨Εɺܗ֚Խɺ੔߹ੑҡ͕࣋೉͍͠

    View full-size slide

  9. ߏ੒؅ཧλεΫͷ࣮ݱํ๏ʢ̎ʣ
    ✤ εΫϦϓτʹΑΔࣗಈԽ
    ✤ εΫϦϓτͷ඼࣭ҡ͕࣋ݸਓͷεΩϧʹΑΔ
    ✤ ߏ੒มߋ΁ͷ௥ै͕೉͍͠ʢޙड़͢Δႈ౳ੑʣ

    View full-size slide

  10. ͜͜Ͱ
    ✤ खॱॻ͕ͻͲ͍ͱ͜ΖΛݟͤΔʢٽ͖ͳ͕Βʣ

    View full-size slide

  11. Chef, Puppetେࣄɾخ͍͜͠ͱ
    ✤ ႈ౳ੑ
    ✤ ίʔυ඼࣭ͷۉҰԽ
    ✤ ίϥϘϨʔγϣϯՄೳ

    View full-size slide

  12. ႈ౳ੑ
    ✤ Կ౓࣮ߦͯ͠΋ಉ͡ঢ়ଶʹͳΔ͜ͱ
    ✤ ৽نɾطଘʹରͯ͠ͷૢ࡞Ͱ΋ಉ͡

    View full-size slide

  13. ίʔυ඼࣭ͷۉҰԽ
    ✤ େମ୭͕ॻ͍ͯ΋ࣅͨΑ͏ͳײ͡ʹͳΔ
    ✤ ݚमͰ࡞ͬͯΔ manifest ݟͯ΋ͦ͏ͩΑͶʁ
    ✤ ଞͷਓ͕ॻ͍ͯΔͷΛݟΕ͹େମԿ΍ͬͯΔ͔෼͔Δ
    ✤ ී௨ʹ࢖͍ͬͯΕ͹ݸਓͷεΩϧʹ͋Μ·Γࠨӈ͞Εͳ͍
    ✤ ෳࡶͳه๏ॻ͖࢝ΊΔͱ·ͨผ͚ͩͲ…

    View full-size slide

  14. ίϥϘϨʔγϣϯՄೳ
    ✤ ΤϯδχΞಉ࢜Ͱ૬ޓʹվળ͕Մೳ
    ✤ Opsಉ࢜Ͱ΋ɻDev͕ॻ͍͍͍ͨͬͯ (DevOps)
    ✤ VCSΛ༻͍ͨվળ (Pull Request, ϨϏϡʔ)
    ✤ ௥੻Մೳͱ͍͏ϝϦοτ

    View full-size slide

  15. Puppet, Chefͷߏ੒

    View full-size slide

  16. Puppet, Chefͷൺֱ
    ݴޠ σΟϨΫτϦߏ੒
    Puppet ֎෦DSL ൺֱతࣗ༝
    Chef ಺෦DSL (Ruby) ܾ·͍ͬͯΔ

    View full-size slide

  17. ͱ͸͍͑
    ✤ ઌ΄Ͳͷ͸֤ϓϩμΫτͷ࢓༷తͳͱ͜ΖͷൺֱͰ
    ✤ ʢೖ໳ Puppet ʹ΋هࡌͯ͋͠Δʣ
    ✤ ࣮ࡍʹఏڙ͞ΕΔػೳͱͯ͠͸େ͖ࠩ͘͸ͳ͍
    ✤ Ҏ߱͸ڞ௨͍ͯ͠Δӡ༻ʢ࢖͍ํʣͷઆ໌

    View full-size slide

  18. Master, Agentܕ
    ✤ Puppetͷmanifest, Chefͷrecipe Λूத؅ཧ͢ΔϚελʔɺద༻͢Δ
    ΤʔδΣϯτͷܗΛऔΔ͜ͱ͕ग़དྷΔ
    ✤ طଘͷϖύϘ঎ࡐ͸͜ͷߏ੒Λऔ͍ͬͯΔͱ͜Ζ͕ଟ͍
    ✤ node৘ใͷ؅ཧ͕ඞཁ
    ✤ PuppetͩͱςΩετʢ࣮ྫʣɺLDAPͳͲऔΕΔ
    ✤ ‘puppet agent’ ‘chef-client’

    View full-size slide

  19. ୯ମͰ࣮ߦ
    ✤ manifest, recipe Λద༻͢Δαʔόʹ഑ஔͯ͠୯ମͰ࣮ߦ͢Δ
    ✤ Master, AgentܕΑΓ͓खܰ
    ✤ ‘puppet apply’, ‘chef-solo’
    ✤ ࠷ۙ͸ͪ͜Β͕ਓؾग़͖ͯͯΔʢޙड़ʣ

    View full-size slide

  20. ΠϯϑϥͷίʔυԽ

    View full-size slide

  21. ίϥϘϨʔγϣϯՄೳͱॻ͍ͨ
    ✤ Manifest, Cookbooks Λόʔδϣϯ؅ཧग़དྷͯɺෳ਺ਓͰ؅ཧ
    ✤ ϨϏϡʔͨ͠Γվળͨ͠Γग़དྷΔ
    ✤ ͜Εͬͯී௨ʹϓϩάϥϜͱҰॹ

    View full-size slide

  22. ϓϩάϥϜͱҰॹ
    ✤ ͜ΜͳྲྀΕ͕ग़དྷΔΑ͏ʹͳΔ
    ✤ खݩͷvagrantͰmanifest΍recipeΛ࡞੒ͯ͠ (development)
    ✤ ࣾ಺ͷmaglica؀ڥͳͲͰ֬ೝͯ͠ (integration)
    ✤ ࣮ࡍͷαʔϏεͷεςʔδϯάͰ֬ೝͯ͠ (staging)
    ✤ ຊ൪ʹ౤ೖ (production)

    View full-size slide

  23. ϓϩάϥϜͱҰॹ
    ✤ ͜͏͍͏ͱ͖͸୯ମ࣮ߦ͕ศརͩͶ
    ✤ ֤؀ڥʹpupper-server΍chef-serverΛߏங͢Δͷ͸͠ΜͲ͍
    ✤ ͔͠΋ͦΕΒ͸ӡ༻ʹͦΕͳΓʹख͕͔͔ؒΔ

    View full-size slide

  24. Vagrant
    ✤ ‘vagrant provision’ ίϚϯυ
    ✤ http://docs-v1.vagrantup.com/v1/docs/provisioners.html
    ✤ ࡞ͬͯյͯ͠ͱ͍͏ͷ͕؆୯ʹग़དྷΔ

    View full-size slide

  25. ࠓ·ͰͷδϨϯϚ
    ✤ manifest΍recipeͷ֬ೝ͕େม
    ✤ ࡞੒
    ✤ ద༻
    ✤ ֬ೝ ʢ໨ࢹʣ

    View full-size slide

  26. ໘౗ͳ͜ͱ͸CI
    ✤ ͜͜࠷ۙ೤͍τϐοΫ
    ✤ ϓϩάϥϚϒϧʹαʔόߏங͕ग़དྷΔΑ͏ʹͳͬͨ
    ✤ ֬ೝ΍ςετΛCIͰճͤΔΑͱ͍͏ͷͰઌਓ͕ϊ΢ϋ΢ΛஷΊͯڞ༗
    ͖͍ͯͯ͠Δ

    View full-size slide

  27. ႈ౳ੑສࡀ
    ✤ طଘͷαʔό΁ͷద༻
    ✤ ৽نαʔόͷߏங
    ✤ ͲͪΒʹͰ΋࢖͑ΔɺͲͪΒ΋֬ೝग़དྷΔ

    View full-size slide

  28. CIྫ (Puppet)
    ✤ “Ukigumo ͱ serverspec Ͱ Puppet ͷܧଓతΠϯςάϨʔγϣϯ”
    ✤ http://mizzy.org/blog/2013/03/27/2/
    ✤ puppet-lxc-box Ͱ࡞ͬͨίϯςφʹରͯ͠ܧଓతʹ puppet apply ͠
    ͯ݁ՌΛϨϙʔτ

    View full-size slide

  29. CIྫ (Chef)
    ✤ “Vagrant + Chef Solo + serverspec + Jenkins ͰαʔόʔߏஙΛ CI”
    ✤ http://d.hatena.ne.jp/naoya/20130520/1369054828
    ✤ vagrant ʹΑͬͯ࡞੒ͨ͠ vm ʹରͯ͠ɺ৽ن࡞੒→knife-soloద༻
    →serverscpec→ഁغ ͱ͍͏ྲྀΕ

    View full-size slide

  30. ઌ΄ͲͷCIͷλΠτϧΛݟ௚͢
    ✤ “Ukigumo ͱ serverspec Ͱ Puppet ͷܧଓతΠϯςάϨʔγϣϯ”
    ✤ “Vagrant + Chef Solo + serverspec + Jenkins ͰαʔόʔߏஙΛ CI”

    View full-size slide

  31. serverspecʹ͍ͭͯ͸
    ✤ ࠓ೔ͷ hbstudy#45 Ͱʂʂ̍

    View full-size slide

  32. ͓·͚ʣ΋͏̍ͭͷςετ
    ✤ αʔϏε؂ࢹ (ϞχλϦϯά͡Όͳͯ͘ࢮ׆؂ࢹͳͲ)
    ✤ ϖύϘͰ͸NagiosΛ࢖͍ͬͯΔ
    ✤ NagiosपΓ͸ࠇా͞Μ͕ࠓ౓࿩ͯ͘͠Ε·͢
    ✤ serverspec͕ϗϫΠτϘοΫεςετͳΒ, αʔϏε؂ࢹ͸ϒϥοΫϘ
    οΫεςετ
    ✤ ʢ௥هʣ࣮ࡍӡ༻தͷNagiosը໘ΛݟͯΈͨ

    View full-size slide