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

Puppet Book

Puppet Book

#pfcasual

Kentaro Kuribayashi

May 10, 2013
Tweet

More Decks by Kentaro Kuribayashi

Other Decks in Technology

Transcript

  1. એ఻
    ʰೖ໳Puppetʱ
    Automate Your Infrastructure

    View full-size slide

  2. @kentaro
    Software engineer
    Rubyist / Perl Monger
    Agile DevOps-er
    Kentaro Kuribayashi
    paperboy&co.

    View full-size slide

  3. ˒ લͷۈ຿ઌͰ͸Puppet΍
    ChefΛ࢖͚ͬͯͨͲແࢹͬ
    ͯͨ
    ˒ ͍·ͷձࣾͰPuppetΛ࢖Θ
    ͟ΔΛಘͳ͘ͳͬͨͷͰ
    PuppetͱΘͨ͠

    View full-size slide

  4. ϒΫϩάͷύϒʔ
    http://p.booklog.jp/book/70667
    ୡਓग़൛ձ
    http://tatsu-zine.com/books/puppet
    Amazon
    http://www.amazon.co.jp/dp/B00CL92JC0

    View full-size slide

  5. อଘ༻
    ؍৆༻
    ීٴ༻

    View full-size slide

  6. http://tmix.jp/design/detail/518356

    View full-size slide

  7. ೔ຊॳͷPuppetຊ

    View full-size slide

  8. ˒ ΦʔϓϯιʔεͳγεςϜࣗಈ؅ཧπʔϧ
    Puppet by mizzy
    ˒ Puppet Best Practice? by mizzy
    ˒ Puppetͷεεϝ by mizzy
    ˒ Puppet Dojo by @trombik
    ͜Ε·ͰͷPuppetʹؔ͢Δ೔ຊޠϦιʔε
    ͜Ε·Ͱ೔ຊޠॻ੶φγ

    View full-size slide

  9. http://www.flickr.com/photos/bogdansuditu/2377844553/
    ຊॻͷλʔήοτ૚

    View full-size slide

  10. ΦϖϨʔγϣϯΤϯδχΞΑΓ
    ΋Ή͠ΖΞϓϦέʔγϣϯ։ൃ
    ऀΛ૝ఆ
    ΞϓϦ։ൃऀ͕PuppetΛ࢖ͬͯγεςϜߏங
    ʹࢀՃͰ͖Δ͙Β͍·Ͱ

    View full-size slide

  11. lຊॻͷ໨ඪ͸ɺ͜ͷຊΛಡΜͩಡऀ͕Puppetͷ
    جຊʹ͍ͭͯͻͱͱ͓Γ஌ΓɺΦϖϨʔγϣϯΤ
    ϯδχΞͷॻ͍ͨmanifest αʔόͷ͋Δ΂͖ঢ়
    ଶΛهड़ͨ͠ઃఆϑΝΠϧͷΑ͏ͳ΋ͷɻޙड़
    ʹ
    มߋΛՃ͑ͨΓɺ͋Δఔ౓ͷن໛ͷ΋ͷͳΒࣗྗ
    Ͱ͍͔ͪΒॻ͚ΔΑ͏ʹͳͬͨΓ͢Δ͜ͱͰ͢ɻ
    ͦͷͨΊɺຊॻ͸͋͑ͯϦϑΝϨϯεͱͯ͠ͷ໢
    ཏੑΛ໨ࢦ͠·ͤΜɻ࣮ࡍͷֶशஈ֊Ͱඞཁͱͳ
    Δ஌ࣝʹ͠΅ͬͯઆ໌͠·͢ɻz
    ʮ͸͡ΊʹʯΑΓ

    View full-size slide

  12. ຊॻͷ಺༰

    View full-size slide

  13. جૅฤ 112ষ

    lHello, World!z͔Βɺͻͱͱ͓ΓͷϦιʔεΛ࢖͑ΔΑ͏ʹͳΔ·Ͱ
    Ԡ༻ฤ 13ষ

    td-agentΫϥελΛ࡞੒͠ɺserverspecͰςετɺσϓϩΠͱద༻·Ͱ

    View full-size slide

  14. ˒ VagrantΛ׆༻ͨ͠։ൃ؀ڥ
    ˒ ϋϯζΦϯͰֶ΂ΔΑ͏ߏ੒
    ˒ ΄Μͱʹඞཁͳ͜ͱͷΈઆ໌
    جૅฤͷϙΠϯτ

    View full-size slide

  15. ˒ class/moduleͳͲେن໛ͳ
    manifestΛॻ͘ͷʹ͔ܽͤͳ͍஌
    ࣝʹ͍ͭͯղઆ
    ˒ ࣮ફతtd-agentΫϥελΛ࡞੒
    ˒ serverspecʹΑΔςετʹ͍ͭͯ
    ˒ capistranoͰmanifestΛద༻
    Ԡ༻ฤͷϙΠϯτ

    View full-size slide

  16. Ԡ༻ฤͰߏங͢ΔγεςϜ

    View full-size slide

  17. Learning Puppet͚ͩͰ͸ֶ΂ͳ͍
    manifestߏ੒ͷϊ΢ϋ΢ʹ͍ͭͯղ
    આ͍ͯ͠Δͱ͜Ζ͕େ͖ͳҧ͍ɻ
    Leaning Puppet͸Α͍υΩϡϝϯτ
    ͕ͩɺݴޠཁૉҎ্ͷ͜ͱ͸ֶ΂ͳ͍

    View full-size slide

  18. ຊॻΛಡΉ͚ͩ
    Ͱجૅ͔Β࣮ફ
    ͰͷԠ༻త஌ࣝ
    ·ͰशಘՄೳɻ

    View full-size slide

  19. Infrastructure as Code

    View full-size slide

  20. ։ൃ Πϯϑϥ

    View full-size slide

  21. γεςϜঢ়ଶΛίʔυͰهड़
    pull requestͰ૬ޓϨϏϡʔ
    ιʔγϟϧγεςϜߏங!!1
    ܦݧతɺҰࢠ૬఻తɺൿ఻ͷλϨΛͰ͖Δ͚ͩ
    ͳ͘͢ɺίʔυԽ͞ΕͨγεςϜߏங

    View full-size slide

  22. maglicaͳͲ ։ൃ؀ڥ

    https://github.com/mizzy/maglica
    AWS EC2ͳͲ ຊ൪؀ڥ

    http://aws.amazon.com/
    Vagrant ϩʔΧϧ؀ڥ

    http://www.vagrantup.com/

    View full-size slide

  23. αʔό͕ίʔυͰ͍͡
    ΕΔΑ͏ʹͳͬͨ͜ͷ
    Ϋϥ΢υ࣌୅Ͱ͸ʜʜ
    http://www.flickr.com/photos/nirak/644337888/

    View full-size slide

  24. ΤϯδχΞͷڞ௨ݴޠ
    ͱͯ͠ͷʮίʔυʯͷ
    ໾ׂ͸·͢·͢େ͖͍
    http://www.flickr.com/photos/trinity-of-one/20562069/

    View full-size slide

  25. ϓϥοτϑΥʔϜ
    ݻ༗ͷख࡞ۀ
    Puppet/Chef
    ϓϥοτϑΥʔϜ
    ݻ༗ͷΞηϯϒϥ
    ߴڃݴޠ
    says...

    View full-size slide

  26. http://en.wikipedia.org/wiki/File:Boschsevendeadlysins.jpg
    ϓϩάϥϚͷࡾେඒಙ

    View full-size slide

  27. ແਫ਼(laziness)
    ୹ؾ(impatience)
    ၗຫ(hubris)

    View full-size slide

  28. ແਫ਼(laziness)
    ୹ؾ(impatience)
    ၗຫ(hubris)

    View full-size slide

  29. γεςϜߏஙʹ
    ʮແਫ਼ʯΛ࣋ͪࠐΉ

    View full-size slide

  30. ˒ खॱॻ࡞੒͕໘౗
    ˒ खॱॻߋ৽͕໘౗
    ˒ εΫϦϓτԽ͢Δͷ͕໘౗
    ˒ εΫϦϓτΛอक͢Δͷ͕໘౗
    ˒ ႈ౳ੑΛ୲อ͢Δͷ͕໘౗
    ˒ ͱʹ͔͘໘౗

    View full-size slide

  31. Ұݟ໘౗ͳPuppet ΍
    Chef
    ΛֶͿͷ͸ʮ໘
    ౗Λճආ͢ΔͨΊͳΒ
    ͍͘ΒͰ΋໘౗Λ͜ͳ
    ͢ʯͱ͍͏ʮແਫ਼ʯͷ
    ൃ࿐ʹଞͳΒͳ͍ɻ

    View full-size slide

  32. Chefͱͷൺֱ

    View full-size slide

  33. ݴޠ σΟϨΫτϦߏ੒
    Puppet ֎෦DSL ൺֱతࣗ༝
    Chef
    ಺෦DSL
    (Ruby)
    ෆࣗ༝

    View full-size slide

  34. package { 'zsh':
    ensure => installed
    }
    Puppet
    package 'zsh' do
    action :install
    end
    Chef

    View full-size slide

  35. ͍ͨͯ͠มΘΒͳ͍

    View full-size slide

  36. $ knife configure
    $ knife cookbook create hello -o cookbooks
    $ $EDITOR cookbooks/hello/recipes/default.rb
    $ $EDITOR localhost.json
    $ $EDITOR solo.rb
    $ chef-solo -c solo.rb -j localhost.json
    ChefͷHello, World!
    // localhost.json
    {
    "run_list" : [
    "recipe[hello]"
    ]
    }
    # solo.rb
    file_cache_path "/tmp/chef-solo"
    cookbook_path ["/home/ec2-user/chef-
    repo/cookbooks"]
    # default.rb
    log “Hello, World!”

    View full-size slide

  37. $ $EDITOR hello.pp
    $ puppet apply hello.pp
    PuppetͷHello, World!
    # hello.pp
    notice(“Hello, World!”)

    View full-size slide

  38. Ͳͬͪʹ͠Ζ΍ΕΔ͜ͱ͸ಉ͡
    Puppet͸ϑΝΠϧຕ͔Β࢝
    ΊΒΕΔ ಋೖোน͕௿͍

    ಠࣗDSLͷֶशίετͱ͍ͬͯ΋ɺRubyΛ஌Β
    ͳ͍ͻͱʹͱͬͯ͸Chefͩͬͯίετߴ

    View full-size slide

  39. ˒ ೔ຊॳͷPuppetʹؔ͢Δॻ੶ʰೖ
    ໳PuppetʱΛಡΉͱΫϥ΢υ࣌୅
    ͷڞ௨ޠʮίʔυʯΛֶ΂Δ
    ˒ Puppet/Chef͸γεςϜߏஙʹ
    ʮଵଦʯΛ࣋ͪࠐΉ
    ˒ Puppet/ChefͲͬͪͰ΋͍͍͚Ͳ
    Έͳ͞Μ͕ࢥͬͯΔΑΓPuppet͸
    ؆୯Ͱ͢Ϥ

    View full-size slide

  40. ˒ ͲͬͪΛ࢖͏ʹͤΑɺ͘͢ͳ͘ͱ
    ΋͜ͷຊʹॻ͔Ε͍ͯΔ͜ͱʹͭ
    ͍ͯ͸஌্ͬͨͰɺબͼ·͠ΐ͏

    View full-size slide

  41. ϒΫϩάͷύϒʔ
    http://p.booklog.jp/book/70667
    ୡਓग़൛ձ
    http://tatsu-zine.com/books/puppet
    Amazon
    http://tatsu-zine.com/books/puppet

    View full-size slide