Slide 1

Slide 1 text

Itamae Meetup #1 Ryota Arai

Slide 2

Slide 2 text

ߥҪ ྑଠ • ΫοΫύουͷΤϯδχΞ • Πϯϑϥ෦ॴଐ DevدΓͷOps • Itamae΍Infratasterͷ࡞ऀ • @ryotarai (GitHub), @ryot_a_rai (Twi>er)

Slide 3

Slide 3 text

Itamae • CFEngine • Puppet • Chef • Ansible • Itamae

Slide 4

Slide 4 text

Itamae • Chefʹ͔ͭΕͨਓͷͨΊͷߏ੒؅ཧπʔϧ • ChefʹࣅͨRuby DSL • Chefʹൺ΂γϯϓϧ • SSHܦ༝Ͱͷ࣮ߦΛαϙʔτ • ࣮ߦର৅ʹItamaeΛΠϯετʔϧ͠ͳ͍Ͱ࣮ߦͰ͖Δ

Slide 5

Slide 5 text

Chef vs Itamae • ௿ֶ͍शίετ • ֮͑Δࣄฑ͕গͳ͍ • খͯ͘͞ϋϚΓͲ͜Ζ͕গͳ͍ • ͍͟ͱͳͬͨΒίʔυΛ͙͢ಡΊΔେ͖͞ • ChefDKͱ͔ͭΒ͍

Slide 6

Slide 6 text

Chef • Recipes • Cookbooks • Roles • Environments • Berkshelf

Slide 7

Slide 7 text

Itamae • Recipes • Cookbooks -> Recipe • Roles -> Recipe • Environments -> Recipe • Berkshelf -> Gem, Bundler

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

Itamaeͷݱঢ় • 513 stars • 802 commits • 38 plugin gems • 35 contributors • ?? users

Slide 10

Slide 10 text

ͱ͜ΖͰ

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

·ͱ΋ͳ΍ͭͰ͖·ͨ͠

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

ؓ࿩ٳ୊

Slide 17

Slide 17 text

࣮ݧతػೳͷ঺հ

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

--recipe-graphΦϓγϣϯ

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

--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}

Slide 23

Slide 23 text

--profileΦϓγϣϯ

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

--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 }, {

Slide 26

Slide 26 text

--profileΦϓγϣϯ

Slide 27

Slide 27 text

Handler

Slide 28

Slide 28 text

Handler • ࣮ߦ࣌ͷΠϕϯτΛड͚औͬͯ೚ҙͷॲཧΛߦ͏ • action_started, attribute_updatedͳͲ • ChefͷHandlerʹࣅ͍ͯΔ • ಠࣗͷHandler΋ॻ͚Δ • ࣮ݧతػೳͱ͍͏Ґஔ͚ͮɻͻΐͬͱ͢Δͱ࢓༷͕มߋ͞ΕΔ ͔΋

Slide 29

Slide 29 text

$ 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}}}

Slide 30

Slide 30 text

Handler • debug handler • ϩάग़ྗ • json handler • JSON per lineͰϑΝΠϧग़ྗ • fluentd handler • fluent-loggerͰFluentdʹग़ྗ

Slide 31

Slide 31 text

Handler Gem • lib/itamae/handler/.rb͕ࣗಈతʹ require͞ΕΔ • itamae-handler- gemΛͭͬͯ͘Gemfileʹॻ͍͓ͯ ͚ͩ͘ͰOK

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

Handler Gem • ৄ͘͠͸ h$ps:/ /github.com/itamae-kitchen/itamae/tree/ master/lib/itamae/handler Λ

Slide 34

Slide 34 text

CookpadͱItamae

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

՝୊ • ϨγϐΛมߋͨ͠ࡍʹશ୆ʹ൓ө͢ΔΘ͚Ͱ͸ͳ͍ • Ϩγϐͱϗετͷݱঢ়͕཭Εͯɺࠩ෼͕େ͖͘ͳΔ • applyͨ͠ΒࢥΘ͵มߋͰো֐ʹͳͬͨΓ • ಛఆͷϗετ͚ͩઃఆ͕ҟͳ͍ͬͯͯো֐͕ىͬͨ͜Γ • ϦεΫ͕େ͖͘ͳΔ

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

ߏ੒ྫ

Slide 42

Slide 42 text

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

Slide 43

Slide 43 text

Itamaeͷࠓޙ • όάϑΟοΫεɺػೳ௥Ճ • ֶशίετΛ্͛ͣεϞʔϧελʔτͰ͖ΔΑ͏ʹҡ࣋ • Itamae v2ʢ༧ఆʣ • ϦϑΝΫλɺॻ͖௚͠ʢಛʹResource::BaseΛࣺ͍ͯͨʣ • ϨγϐɺϓϥάΠϯͷޙํޓ׵ੑ͸ҡ࣋ • όοΫΤϯυΛinfra_operator΁Ҡߦ͢Δ͔΋

Slide 44

Slide 44 text

ϑΟʔυόοΫΛٻΊ͍ͯ·͢ • 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