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

Opening - Itamae Meetup#1

Ff2949d62ab50cb0095c769882ffe018?s=47 Ryota Arai
December 09, 2015

Opening - Itamae Meetup#1

Ff2949d62ab50cb0095c769882ffe018?s=128

Ryota Arai

December 09, 2015
Tweet

Transcript

  1. Itamae Meetup #1 Ryota Arai

  2. ߥҪ ྑଠ • ΫοΫύουͷΤϯδχΞ • Πϯϑϥ෦ॴଐ DevدΓͷOps • Itamae΍Infratasterͷ࡞ऀ •

    @ryotarai (GitHub), @ryot_a_rai (Twi>er)
  3. Itamae • CFEngine • Puppet • Chef • Ansible •

    Itamae
  4. Itamae • Chefʹ͔ͭΕͨਓͷͨΊͷߏ੒؅ཧπʔϧ • ChefʹࣅͨRuby DSL • Chefʹൺ΂γϯϓϧ • SSHܦ༝Ͱͷ࣮ߦΛαϙʔτ

    • ࣮ߦର৅ʹItamaeΛΠϯετʔϧ͠ͳ͍Ͱ࣮ߦͰ͖Δ
  5. Chef vs Itamae • ௿ֶ͍शίετ • ֮͑Δࣄฑ͕গͳ͍ • খͯ͘͞ϋϚΓͲ͜Ζ͕গͳ͍ •

    ͍͟ͱͳͬͨΒίʔυΛ͙͢ಡΊΔେ͖͞ • ChefDKͱ͔ͭΒ͍
  6. Chef • Recipes • Cookbooks • Roles • Environments •

    Berkshelf
  7. Itamae • Recipes • Cookbooks -> Recipe • Roles ->

    Recipe • Environments -> Recipe • Berkshelf -> Gem, Bundler
  8. Itamae # recipe.rb package "nginx" service "nginx" template "/etc/nginx/nginx.conf" do

    notifies :restart, "service[nginx]" end $ itamae local recipe.rb $ itamae ssh -h your-server recipe.rb
  9. Itamaeͷݱঢ় • 513 stars • 802 commits • 38 plugin

    gems • 35 contributors • ?? users
  10. ͱ͜ΖͰ

  11. Α͍͘ΘΕΔ͜ͱ ʮItamaeͷϩΰͳ͍ΜͰ͔͢ʙʯ

  12. None
  13. ·ͱ΋ͳ΍ͭͰ͖·ͨ͠

  14. None
  15. ࣗ͝༝ʹ͓࢖͍͍ͩ͘͞ github.com/itamae-kitchen/itamae-logos

  16. ؓ࿩ٳ୊

  17. ࣮ݧతػೳͷ঺հ

  18. Itamaeͷ࣮ݧతػೳ • ࣮ݧతػೳ: ͻΐͬͱͨ͠Βফ͑ͨΓ࢓༷͕มΘͬͨΓ͢Δ͔΋ • --recipe-graphΦϓγϣϯ • --profileΦϓγϣϯ • Handler

  19. --recipe-graphΦϓγϣϯ

  20. --recipe-graphΦϓγϣϯ • Ϩγϐͷґଘؔ܎ΛdotܗࣜͰग़ྗͰ͖Δ • include_recipeͨ͠Ϩγϐ • Ϩγϐ܊͕େ͖͘ͳͬͯ͘Δͱศར͔΋͠Εͳ͍

  21. None
  22. --recipe-graphΦϓγϣϯ Itamae v1.9.0Ҏ߱ʢv1.9.0Ҏલ͸--dotΦϓγϣϯʣ $ itamae local --recipe-graph /path/to/itamae-graph.dot recipe.rb $

    dot -Tpng -o /path/to/itamae-graph.{png,dot}
  23. --profileΦϓγϣϯ

  24. --profileΦϓγϣϯ • ࣮ߦͨ͠ίϚϯυ͝ͱʹ͔͔͕ͬͨ࣌ؒऔಘͰ͖Δ • ݫີʹ͸Specinfraͷrun_commandʹ͔͔ͬͨ࣌ؒ • JSONͰग़ྗ͞ΕΔ • ϘτϧωοΫͷௐࠪʹ༗ޮ͔΋͠Εͳ͍

  25. --profileΦϓγϣϯ $ itamae local --profile /path/to/profile.json recipe.rb $ cat /path/to/profile.json

    | jq . | head [ { "command": "mkdir -p /tmp/itamae_tmp", "duration": 0.0037856101989746094 }, { "command": "chmod 777 /tmp/itamae_tmp", "duration": 0.0025980472564697266 }, {
  26. --profileΦϓγϣϯ

  27. Handler

  28. Handler • ࣮ߦ࣌ͷΠϕϯτΛड͚औͬͯ೚ҙͷॲཧΛߦ͏ • action_started, attribute_updatedͳͲ • ChefͷHandlerʹࣅ͍ͯΔ • ಠࣗͷHandler΋ॻ͚Δ

    • ࣮ݧతػೳͱ͍͏Ґஔ͚ͮɻͻΐͬͱ͢Δͱ࢓༷͕มߋ͞ΕΔ ͔΋
  29. $ cat config.yml handlers: - type: json path: /path/to/itamae-log.json $

    itamae local -c config.yml recipe.rb $ cat /tmp/itamae-log.json | head {"time":"2015-12-08T15:47:55+09:00","event":"recipe_started", "payload":{"path":"/Users/ryota-arai/src/github.com/ryotarai/itamae/tmp/recipe.rb"}} {"time":"2015-12-08T15:47:55+09:00","event":"resource_started", "payload":{"resource_type":"execute","resource_name":"echo included"}} {"time":"2015-12-08T15:47:55+09:00","event":"action_started", "payload":{"action":"run"}} {"time":"2015-12-08T15:47:55+09:00","event":"attribute_changed", "payload":{"from":{"executed":false}, "to":{"action":"run","command":"echo included","executed":true}}}
  30. Handler • debug handler • ϩάग़ྗ • json handler •

    JSON per lineͰϑΝΠϧग़ྗ • fluentd handler • fluent-loggerͰFluentdʹग़ྗ
  31. Handler Gem • lib/itamae/handler/<handler type>.rb͕ࣗಈతʹ require͞ΕΔ • itamae-handler-<type> gemΛͭͬͯ͘Gemfileʹॻ͍͓ͯ ͚ͩ͘ͰOK

  32. Handler Gem # lib/itamae/handler/mail.rb module Itamae module Handler class Mail

    < Base def event(type, payload = {}) super send_mail(subject: type.to_s, body: payload.inspect) end end end end
  33. Handler Gem • ৄ͘͠͸ h$ps:/ /github.com/itamae-kitchen/itamae/tree/ master/lib/itamae/handler Λ

  34. CookpadͱItamae

  35. CookpadͰͷϫʔΫϑϩʔ • Jenkins͕Git্ͷϨγϐΛtar.gzʹ͔ͨΊͯS3ʹΞοϓϩʔυ • ֤ϗετͰS3͔Βμ΢ϯϩʔυ͠ItamaeΛ࣮ߦ͢Δckpd- itamaeίϚϯυΛ༻ҙ͍ͯ͠Δ • itamae ssh͸ւΛ௒͑Δͱॏ͍ͷͰϩʔΧϧ࣮ߦΛ࢖͍ͬͯ Δ

    • omnibus-itamaeͷdebύοέʔδΛར༻͍ͯ͠Δ
  36. omnibus-itamae • Chef͕ࣾ։ൃ͍ͯ͠ΔOmnibusͱ͍͏ύοέʔδϯάπʔϧΛ ࢖ͬͯdeb, rpmύοέʔδΛ࡞੒ • /opt/itamaeҎԼʹRubyຊମ΋ؚΊͯΠϯετʔϧ͞ΕΔ • fat͚ͩͲɺsystem rubyͷόʔδϣϯʹࠨӈ͞Εͳ͍

    • Fluentdʹ͓͚Δtd-agentͷΑ͏ͳ΋ͷ
  37. omnibus-itamae • ϏϧυࡁΈύοέʔδˏBintray • Ubuntu 14.04, CentOS 7༻ • खݩͰ΋ϏϧυՄೳ

    $ echo 'deb https://dl.bintray.com/itamae/itamae trusty contrib' | sudo tee /etc/apt/sources.list.d/itamae.list $ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv D401AB61 $ sudo apt-get update $ sudo apt-get install itamae
  38. ՝୊ • ϨγϐΛมߋͨ͠ࡍʹશ୆ʹ൓ө͢ΔΘ͚Ͱ͸ͳ͍ • Ϩγϐͱϗετͷݱঢ়͕཭Εͯɺࠩ෼͕େ͖͘ͳΔ • applyͨ͠ΒࢥΘ͵มߋͰো֐ʹͳͬͨΓ • ಛఆͷϗετ͚ͩઃఆ͕ҟͳ͍ͬͯͯো֐͕ىͬͨ͜Γ •

    ϦεΫ͕େ͖͘ͳΔ
  39. Itamae Server • ݱࡏ։ൃதʢҰԠΦʔϓϯιʔεʹ͸ͳ͍ͬͯΔʣ • Itamaeͷ࣮ߦͱϩάͷӾཡ͕Ͱ͖Δαʔό • Itamae࣮ߦ෦෼ʢBackendʣ͸ࠩ͠ସ͑Մೳ • HandlerΛ͔ͭͬͯϩάૹ৴

    • itamae-handler-itamae_server
  40. None
  41. ߏ੒ྫ

  42. Itamae Server • ItamaeΛ࣮ߦ͢ΔBackend͸ࠩ͠ସ͑Մೳ • ྫ͑͹ɺConsulɺSSHɺStretcherͳͲ • ඇಉظͰitamae-handler-itamae_server͕ϩάΛItamae Serverʹ ૹ৴͢Δ

  43. Itamaeͷࠓޙ • όάϑΟοΫεɺػೳ௥Ճ • ֶशίετΛ্͛ͣεϞʔϧελʔτͰ͖ΔΑ͏ʹҡ࣋ • Itamae v2ʢ༧ఆʣ • ϦϑΝΫλɺॻ͖௚͠ʢಛʹResource::BaseΛࣺ͍ͯͨʣ

    • ϨγϐɺϓϥάΠϯͷޙํޓ׵ੑ͸ҡ࣋ • όοΫΤϯυΛinfra_operator΁Ҡߦ͢Δ͔΋
  44. ϑΟʔυόοΫΛٻΊ͍ͯ·͢ • Twi%erͰ@ryot_a_rai • Slack: h%ps:/ /itamae-slackin.herokuapp.com/ • Issue: h%ps:/

    /github.com/itamae-kitchen/itamae/issues • PR: h%ps:/ /github.com/itamae-kitchen/itamae/pulls