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

jopf-seminar-chef-and-ansible

Yutaro Sugai
February 23, 2015

 jopf-seminar-chef-and-ansible

Chef・Ansible等を用いた環境の自動構築方法
日本OSS推進フォーラム主催 第5回アプリケーション部会勉強会
http://connpass.com/event/11707/

Yutaro Sugai

February 23, 2015
Tweet

More Decks by Yutaro Sugai

Other Decks in Technology

Transcript

  1. ໨తͷલʹ • ͲΜͳ૊৫ʁ • ͲΜͳϓϩμΫτʁ • ͩΕ͕ϓϩμΫτΛ࢖͏ͷʁ • ϓϩμΫτ͕མͪΔͱ୭͕ࠔΔͷʁ •

    མͪͨϓϩμΫτΛ୭͕௚͢ͷʁ • ࣗಈԽͰԿΛղܾ͢Δͷʁ • ϦϦʔεΛओಋ͢Δͷ͸୭ʁͲͷ૊৫ʁ • ϓϩδΣΫτ͸ࠓɺͲΜͳஈ֊ʁ
  2. ໨తͷલʹ • ͲΜͳ૊৫ʁ • ͲΜͳϓϩμΫτʁ • ͩΕ͕ϓϩμΫτΛ࢖͏ͷʁ • ϓϩμΫτ͕མͪΔͱ୭͕ࠔΔͷʁ •

    མͪͨϓϩμΫτΛ୭͕௚͢ͷʁ • ࣗಈԽͰԿΛղܾ͢Δͷʁ • ϦϦʔεΛओಋ͢Δͷ͸୭ʁͲͷ૊৫ʁ • ϓϩδΣΫτ͸ࠓɺͲΜͳஈ֊ʁ ӡ༻ʹؔΘΔਓΛ ר͖ࠐΉඞཁ
  3. ໨తͷલʹ • ͲΜͳ૊৫ʁ • ͲΜͳϓϩμΫτʁ • ͩΕ͕ϓϩμΫτΛ࢖͏ͷʁ • ϓϩμΫτ͕མͪΔͱ୭͕ࠔΔͷʁ •

    མͪͨϓϩμΫτΛ୭͕௚͢ͷʁ • ࣗಈԽͰԿΛղܾ͢Δͷʁ • ϦϦʔεΛओಋ͢Δͷ͸୭ʁͲͷ૊৫ʁ • ϓϩδΣΫτ͸ࠓɺͲΜͳஈ֊ʁ ϓϩμΫτ΁ͷཧղ
  4. ໨తͷલʹ • ͲΜͳ૊৫ʁ • ͲΜͳϓϩμΫτʁ • ͩΕ͕ϓϩμΫτΛ࢖͏ͷʁ • ϓϩμΫτ͕མͪΔͱ୭͕ࠔΔͷʁ •

    མͪͨϓϩμΫτΛ୭͕௚͢ͷʁ • ࣗಈԽͰԿΛղܾ͢Δͷʁ • ϦϦʔεΛओಋ͢Δͷ͸୭ʁͲͷ૊৫ʁ • ϓϩδΣΫτ͸ࠓɺͲΜͳஈ֊ʁ Ұ൪େࣄͳͱ͜Ζ
  5. ໨తͷલʹ • ͲΜͳ૊৫ʁ • ͲΜͳϓϩμΫτʁ • ͩΕ͕ϓϩμΫτΛ࢖͏ͷʁ • ϓϩμΫτ͕མͪΔͱ୭͕ࠔΔͷʁ •

    མͪͨϓϩμΫτΛ୭͕௚͢ͷʁ • ࣗಈԽͰԿΛղܾ͢Δͷʁ • ϦϦʔεΛओಋ͢Δͷ͸୭ʁͲͷ૊৫ʁ • ϓϩδΣΫτ͸ࠓɺͲΜͳஈ֊ʁ ஈ֊ʹΑΓ ΍Δ͜ͱ͕มΘΔ
  6. ಋೖ(։ൃ؀ڥߏங) • ಉ͡؀ڥΛૉૣ͘։ൃऀʹ഑෍Ͱ͖ΔΑ͏ʹͳΔ • όʔδϣϯͷҧ͍Ͱ೰·ͳ͘ͳΔ • ϝϯόʔ૿͑ͨ࣌ʹѹ౗తʹָ • Vagrantͱ૊Έ߹ΘͤΕ͹ߏஙͷ΍Γ௚͕͠͠΍͍͢ •

    Chef, Ansible౳ͷೖ໳ʹ͓͢͢Ί • Chef࣮ફೖ໳5,6ষ΋͓͢͢Ί • [ؾΛ͚ͭΔ͜ͱ] όʔδϣϯ؅ཧ͠ɺܧଓతʹมߋΛՃ͑ ΒΕΔΑ͏ʹ͓ͯ͘͠
  7. ಋೖ(จԽ) • จԽͷಋೖ͕େࣄͰɺࠎ͕ંΕΔ͔΋ • ख࡞ۀΛͳ͘͠ɺࣗಈԽͰͷ࡞ۀத৺ʹ • ݽಠͳChef(ͳͲ)࢖͍ʹͳͬͯ͠·Θͳ͍Α͏ • ·ͣ͸ಡΈॻ͖ग़དྷΔ஥ؒΛ૿΍͢ •

    Ξϯνύλʔϯʹؾ͕෇͚ΔਓΛ૿΍͢ • ѻ͏ϛυϧ΢ΣΞ΍OSɺίϚϯυ౳΁ͷཧղ͕Լ஍ͱͯ͠ඞཁʹ ͳͬͯ͘Δ • ϝϯςφϯεੑ • ಡΈॻ͖͕͠΍͍͢ • ӡ༻ʹϑΟοτ͢Δ͔
  8. ࣄલʹ௖͍࣭ͨ໰(2) ”ChefͰݕࡧ͢ΔͱɺChef SoloɺChef ServerɺKnifeɺCookbookɺ ! ϨγϐɺBerkshelfͳͲɺ͞·͟·ͳ༻ޠ͕ͨ͘͞Μ͋Γ ! Α͘෼͔Βͳ͍ɻ੔ཧͯ͠ཉ͍͠ɻ”! ! →Chef

    Solo: ελϯυΞϩϯܗࣜͷChef! →Chef Server: Chef ClientͱڞʹΫϥΠΞϯτ/αʔόܗࣜͷChef! →Ϩγϐ: Ұ൪جૅతͳߏ੒ཁૉɻίʔυͰॻ͍ͨઃఆखॱ! →Cookbook: Ϩγϐʹඞཁͳσʔλ΍ϑΝΠϧΛ·ͱΊͨ΋ͷ! →Knife: खݩͷΫοΫϒοΫͱର৅ͷαʔόΛͭͳ͙ίϚϯυϥΠϯπʔϧ
  9. ࣄલʹ௖͍࣭ͨ໰(3) “RubyͷDSLΛॻ͘͜ͱͰαʔόߏஙͷࣗಈԽ͕ߦ͑Δͱͷ͜ͱ͕ͩɺ ! θϩ͔Β͢΂ͯΛॻ͖ى͜͢ͷ͸େมͩ͠ɺֶशίετ͕ߴ͗͢Δ ! Α͏ʹࢥ͏ɻApache΍Ruby,PassengerͳͲΛΠϯετʔϧ͢ΔͨΊͷ ! ςϯϓϨʔτ͸͋Δͷ͔ʁ “! !

    →͍͍࣭໰Ͱ͢Ͷʂ! →Chef supermarket( https://supermarket.chef.io/ )͕͋Γ·͢ɻ! ! ͝ར༻͸ܭըతʹ! ʢ๬Ή΋ͷͰ͸ͳ͍Մೳੑ΍ɺ݁ہιʔείʔυΛಡΉӋ໨ʹͳΔ͜ͱ΋ʣ
  10. Chef Supermarket • ୭͕ϝϯς͍ͯ͠Δͷʁ! • Chefࣾ! • PayPal! • HiganWorks!

    • Chef׆༻ΨΠυஶऀͷᖒొ͞Μͷձࣾ! • ͳͲͳͲ(ΫοΫϒοΫ࣍ୈ)! • ͲΜͳΫοΫϒοΫ͕͋Δͷʁ! • nginx! • apache2! • rbenv! • postgresql! • mysql! • docker! • ͳͲͳͲ
  11. ࣄલʹ௖͍࣭ͨ໰(4) “RubyͷDSLͰࣗಈԽͰ͖Δͷ͸ָͩͱ͸ࢥ͏͕ɺςετ͸ ! ͲͷΑ͏ʹ͢Δͷ͔ɻ “! ! →͍͍࣭໰Ͱ͢Ͷʂ! →test-kitchen, Serverspec ΍

    Infrataster Ͱςετ͢Δͷ͕ྑͦ͞͏! →͔͠͠ɺ·ͩϕετϓϥΫςΟε͸ͳ͍ͱೝ͍ࣝͯ͠Δ! →ࣗಈԽͷ੒ՌΛ֬ೝ͢Δͷ͕େࣄ! →ςετʹ࣌ؒΛ࢖͍ա͗ͳ͍Α͏ʹɺ·ͣ͸εϞʔϧελʔτͰ! ʢࣗಈԽʹ΋ɺςετʹ΋͕͔͔࣌ؒΔͱվળͷαΠΫϧΛճ͠ʹ͍͘ʣ
  12. πʔϧൺֱ Chef Ansible Itamae γΣϧεΫϦϓτ อकੑ ◦ ◦ ◦ ☓

    ಋೖָ͕͔ ˚ ◦ ◦ ◦ কདྷੑ ◦ ◦ ◦ ? ೉қ౓ ˚ ◦ ˕ ˚ ϓϥοτ ϑΥʔϜ ˕ ◦ ◦ ◦
  13. πʔϧൺֱ • Chef • RubyͳͷͰΘ͔Γ΍͍͕͢ɺεΫϦϓτ͕ཚཱ͠ͳ͍ Α͏ؾΛ͚ͭΔඞཁ͕͋Δ • ͍ΖΜͳͱ͜ΖͰίʔυΛࠩ͠ࠐΊΔ෼ɺ͘·ͳ͘ಡ Ήඞཁ͕͋ΔΑ͏ʹࢥ͏ •

    ઃఆର৅ͷαʔόʹΤʔδΣϯτ(Ruby)ΛΠϯετʔ ϧ͢Δඞཁ͕͋Δ • ར༻ऀ͸૿͍͑ͯ͘ͱࢥ͏ • Windows΍Azureʹ΋ରԠ͍ͯ͠Δ໛༷(Chef12͔Β)
  14. ·ͱΊ • πʔϧ͕େࣄͰ͸ͳ͍ • ࣗಈԽ΁ࢸΔಓ • ࣗಈԽΛҡ࣋͢Δϓϩηε • ͦͷ্Ͱɺࣗ෼ͨͪͷ૊৫Ͱ͸ͲͷπʔϧΛબͿ͔ •

    จԽͷಋೖ͕େม͕ͩେࣄ • ʢͳͥಋೖ͢Δͷ͔ͱ͍ͬͨʣࣾ಺޲͚ϙΤϜΛॻ͘ ͱ఻ΘΓ΍͍͔͢΋ • ࣄྫΛ஌Γ͍ͨͷͰɺͥͻൃද͍ͯͩ͘͠͞
  15. σϞ • Vagrant + Chef soloΛ࢖ͬͯߏங! • vagrantͷػೳͰ͋ΔprovisionerΛར༻! • ChefͷagentΠϯετʔϧ͸Vagrant͕ࣗಈͰ΍ͬͯ͘ΕΔ!

    • ΫοΫϒοΫ! • جຊతʹChef supermarketͷ΋ͷΛར༻! • nginx! • postgresql! • nodejs! • rbenv(RubyͷΠϯετʔϧ΍؅ཧ)! • ࣗલͰॻ͍ͨͷ͸্هΫοΫϒοΫͷݺͼग़͠΍ɺnginxͷݻ༗ઃ ఆͷΈ! • σϓϩΠ͸railsΞϓϦଆ͔ΒcapistranoΛར༻ͯ͠ߦ͏