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

Engine Yardで使われる Chefの活用レシピ

9b69fbdeb0713def44a8731091ce5885?s=47 Yusuke Ando
April 05, 2013
1.4k

Engine Yardで使われる Chefの活用レシピ

9b69fbdeb0713def44a8731091ce5885?s=128

Yusuke Ando

April 05, 2013
Tweet

Transcript

  1. $IFGͷ׆༻Ϩγϐ &OHJOF:BSEͰ࢖ΘΕ͍ͯΔ

  2. ZBOEP $BOEZ$BOFQIQ ʮ࠙਌ձϐβൃ஫ΞϓϦʯ

  3. Copyright © 2013 Engine Yard. All Rights Reserved. 3 2006೥ɿ

    Engine Yard ઃཱ (Ruby࣮ߦ؀ڥͷఏڙ։࢝) 2008೥ɿ Amazon༷͕Engine Yardʹग़ࢿΛൃද 2009೥ɿ AWSج൫ͷPaaSΛఏڙ։࢝ ࠷େڃͷAWSϦηʔϥʔʹ 2011೥ɿ PHP࣮ߦ؀ڥͷఏڙ։࢝ 2012೥ɿ Engine Yard ೔ຊ๏ਓઃཱ Node.js࣮ߦ؀ڥͷఏڙ։࢝ എܠ: Engine Yard, Inc.ͷϏϧ(ӈख)͕ݐͭ1929೥ͷαϯϑϥϯγεί Engine YardͷาΈ
  4. &OHJOF:BSE$MPVE 1MBUGPSNBTB4FSWJDF ઃఆෆཁͰࣗಈͰΞϓϦΛσϓϩΠ ӡ༻ɾ؂ࢹΛαϙʔτରԠ Πϯϑϥؔ࿈ͷਓ݅අΛθϩʹ ສ୯ҐͷΠϯελϯεΛҰׅӡ༻

  5. &OHJOF:BSE$MPVE

  6. "84 $IFG αϙʔτ

  7. "HFOEB $IFGͱ͸ $IFG4PMPͷར༻ ΑΓ࣮ફతͳར༻ྫ

  8. $IFGͱ͸

  9. $IFG 3VCZ੡ͷγεςϜ؅ཧπʔϧ ઃఆϑΝΠϧΛݩʹαʔόΛࣗಈઃఆ 6OJY-JOVY.BD8JOEPXTରԠ ແঈ൛Ͱ΋ར༻Մೳ ࠃ಺֎Ͱٸ଎ʹελϯμʔυʹ

  10. DPPLCPPLΛݩʹઃఆ recipe cookbook 3VCZͰॻ͔ΕͨϨγϐͷू·Γ͕ΫοΫϒοΫ $IFG͸ϨγϐΛݩʹϗετΛࣗಈͰઃఆ͢Δ

  11. SFDJQJFTͷྫ log "Hello Chef" package "apache2" do action :install end

    service "apache2" do action :start end
  12. *OGSBTUSVDUVSFBT$PEF 2011/2 ΠϯϑϥΛίʔυͰهड़͢Δ ࣌୅͕౸དྷͨ͠

  13. ʮγΣϧεΫϦϓτͰ໰୊ͳ͍ʯ ႈ౳ੑ͸͋Δ͔ʁ

  14. ႈ౳ੑ ͋Δૢ࡞Λճߦͬͯ΋ෳ਺ճ ߦͬͯ΋݁Ռ͕ಉ͡Ͱ͋Δ͜ͱ Λ͍͏֓೦

  15. ΠϯετʔϧεΫϦϓτ͸ ߏங௚ޙͷঢ়ଶ͔͠อূͰ͖ͳ͍ $IFG͸Կ౓Ͱ΋࣮ߦՄೳͰ γεςϜΛఆٛ͞Εͨঢ়ଶʹͰ͖Δ

  16. $IFGͷߏ଄ ໨తͷϊʔυ܈ ؅ཧ༻αʔό

  17. όϦΤʔγϣϯ )PTUFE$IFG 0QT$PEF͕ϗεςΟϯά͢Δ ϊʔυ਺ʹԠͨ͡՝ۚ 1SJWBUF$IFG 'JSFXBMM಺ͰՔಇ͢Δ ༗ঈ൛͸αϙʔτ͋Γ

  18. )PTUFE$IFG

  19. 1SJDF

  20. $IFG4FSWFS 044 ࣮͸ɺ࢖ͬͨࣄͳ͍Ͱ͢ʜ

  21. DIFGTPMP αʔόʔෆཁͷDIFG ϩʔΧϧ্ͷΫοΫϒοΫΛ࣮ߦՄೳ (6*͸࢖͑ͳ͍ DIFGTPMPΛΩοΫ͢Δπʔϧ΋ଟ͍ FY 7BHSBOU &OHJOF:BSE

  22. ͜Μͳ੠΋

  23. Chef Server $IFG$MJFOU ։ൃऀͷPC Workstation Node Cookbook Node DIFGDMJFOU DIFGDMJFOU

    "1* Cookbook LOJGF
  24. ։ൃऀͷPC Workstation Node $IFG4PMP,OJGF4PMP Node DIFGTPMP Cookbook LOJGF Cookbook DIFGTPMP

    Cookbook TTI TTI
  25. DIFGTPMPେਓؾ

  26. ·ͣ͸$IFG4PMPͰ ϨγϐΛ࢖ͬͨߏஙʹ ׳ΕΔͷ͕٢

  27. $IFG4PMPͷར༻

  28. ηοτΞοϓ $ curl -L https://www.opscode.com/chef/install.sh | sudo bash $IFGͷ࣮ߦʹඞཁͳ3VCZ΍3VCZHFNTΛ γεςϜͱ͸ಠཱͯ͠Πϯετʔϧ

  29. TPMPSC Ұ࣍σΟϨΫτϦͷ৔ॴͷઃఆ ΫοΫϒοΫͷύεͷઃఆ FUDDIFGTPMPSC ࣮ߦ࣌ʹଘࡏ͠ͳ͍৔߹͸ܯࠂ

  30. TPMPSC file_cache_path "/var/chef-solo" cookbook_path ["/var/chef-solo/cookbooks"] file_cache_path "/var/chef-solo" cookbook_path ["/var/chef-solo/cookbooks", "/var/chef-solo/site-cookbooks"]

    ෳ਺ࢦఆՄ
  31. OPEFKTPO $IFGαʔό͔Βͷσʔλͷ୅ସ ΫοΫϒοΫ΁౉͢ม਺Λઃఆ ࣮ߦ͢ΔϨγϐΛࢦఆ͢Δ

  32. OPEFKTPO { "resolver": { "nameservers": [ "10.0.0.1" ], "search":"int.example.com" },

    "run_list": [ "recipe[resolver]" ] } { "run_list": [ "recipe[resolver]" ] } ࣮ߦ͍ͨ͠Ϩγϐ
  33. DIFGTPMP

  34. ͭ·Γ ະઃఆͷঢ়ଶ͔ΒͰ΋೚ҙͷΫοΫ ϒοΫΛ࣮ߦग़དྷΔ WBSDIFGDPPLCPPLTIPHF ͷΫοΫϒοΫΛ࣮ߦ͢ΔͳΒ $ sudo chef-solo -o hoge

  35. ςετ࣮ߦ

  36. Ϩγϐͷهड़ LOJGFίϚϯυ σΟϨΫτϦߏ଄ 3FTPVSDF ެ։͞Ε͍ͯΔΫοΫϒοΫ

  37. ΫοΫϒοΫ࡞੒ LOJGFDPPLCPPLDSFBUF\OBNF^ WBSDIFGDPPLCPPLTҎԼʹ࡞੒ $IFGαʔόΛ࢖Θͳ͍ͷͰΑ͠ͳʹ (JU)VC΍4Ͱ؅ཧ

  38. σΟϨΫτϦߏ੒ CHANGELOG.md attributes/ files/ metadata.rb recipes/ templates/ README.md definitions/ libraries/

    providers/ resources/ ϨγϐΛஔ͘ QMBUGPSNຖʹ΋ग़དྷΔ ઃఆϑΝΠϧͷͻͳܗ ϨγϐͰར༻͍ͨ͠ม਺ͳͲ
  39. SFDJQFTEFGBVMUSC log “Hello Chef” QMBUGPSNΛؾʹ͠ͳ͍৔߹

  40. Ϩγϐ 3VCZͰॻ͔ΕͨεΫϦϓτ ಺෦%4-Λ࢖ͬͯهड़ 3FTPVSDFͱݺ͹ΕΔจ๏ ૊ΈࠐΈͷ3FTPVSDF͸04ʹґଘ͠ͳ͍ ઃఆ࡞ۀΛఏڙ

  41. SFDJQJFTEFGBVMUSC log "Hello Chef" package "apache2" do action :install end

    service "apache2" do action :start end ֤؀ڥͷύοέʔδ؅ཧΛ࣮ߦ
  42. BQBDIFೖͬͨ

  43. BQUHFUͰྑ͘Ͷʁ ୯७ͳύοέʔδಋೖҎ্ͷॲཧ͕ग़ དྷΔͷ͕$IFGͷڧΈ ݻ༗ͷઃఆϑΝΠϧͷઃஔ ύοέʔδؒɺϊʔυؒͷ࿈ಈઃఆ ࣮ߦ࣌ʹ৘ใΛऔಘ͢Δػೳ

  44. UFNQMBUFϦιʔε &3#Λ࢖ͬͯಈతͳ஋Λૠೖ "QBDIFQIQOHJOYͳͲͷઃఆʹ ϓϥοτϑΥʔϜຖʹࠩ͠ସ͑΋Մೳ

  45. UFNQMBUFTEFGBVMUUFTUUYUFSC This is Sample File.<br/> <%= node[:platform] %><br/> <%= node[:platform_version]

    %> SFDJQFTEFGBVMUSC ଓ template "/var/www/test.txt" do source "test.txt.erb" mode 0644 end
  46. ಈతʹϑΝΠϧΛ࡞੒

  47. JODMVEF ผͷΫοΫϒοΫΛಡΈࠐΉ طଘͷ஌ࣝͷ࠶ར༻ ґଘؔ܎ͷఆٛ include_recipe “fuga”

  48. ͦͯ͠ ࣗྗͰهड़ͨ͠ϨγϐΛஷΊ͍ͯ͘ ωοτ্ͷϨγϐΛख௚ͯ͠͠ར༻ *OGSBTUSVDUVSFBTDPEFΛ࣮ݱ

  49. ΑΓ࣮ફతͳར༻ྫ

  50. ௚໘͢Δ՝୊ ໨తͷ؀ڥΛߏங͢ΔϨγϐͷ࣮૷ ॻ͔ΕͨϨγϐͷӡ༻อक Ϩγϐͷ഑෍ํ๏ Ϩγϐͷ൓өλΠϛϯάͷ੍ޚ

  51. Ϩγϐͷ࣮૷ 3VCZͰͷ࣮૷ʹෆ׳Ε ˠ(JU)VC্ͷϨγϐΛࢀরɾར༻ Ϩγϐͷςετ༻ͷ؀ڥ͕େྔʹ࢖͏ ˠ7BHSBOUΛ࢖͏

  52. None
  53. 7BHSBOU 7JSUVBM#PYͷϑϩϯτΤϯυ ΠϝʔδϑΝΠϧͷ؅ཧɺDIFG΍ QVQQFUͷىಈ·ͰΛશࣗಈͰ࣮ߦ $IFGϢʔβͷඞܞπʔϧ ϓϥάΠϯͰΫϥ΢υ΋ར༻Մೳ

  54. Ϩγϐͷӡ༻อक Ϩγϐͷ഑෍ (JU)VC ,OJGFTPMP /'4 $IFG4FSWFS #FSLTIFMG Ϩγϐͷ൓өλΠϛϯά $BQJTUSBOP DSPO

    DIFGDMJFOUͷEBFNPO
  55. Node Node GitHub engineyard.com Node &OHJOF:BSEͷ৔߹ DIFGTPMP Cookbook BQQMZ &OHJOF:BSE͕࣮૷ͨ͠Ϩγϐ

    Λ8FCͷૢ࡞Ͱඞཁͳ࣌ʹ൓ө ΧελϜϨγϐ
  56. GitHub ։ൃऀͷPC &OHJOF:BSE-PDBM Cookbook &OHJOF:BSE-PDBM Ϋϥ΢υ্ͱಉҰͷϨγϐͰϩʔΧϧʹ ։ൃ؀ڥΛ࡞Δπʔϧ VM DIFGTPMP BQQMZ

    7BHSBOU Node DIFGTPMP BQQMZ
  57. ར఺ ར༻ऀ͸վྑ͞Ε͚ͭͮΔϨγϐΛ Կ΋ॻ͔ͣʹར༻Ͱ͖Δ ར༻ऀͷ؀ڥͷ಺෦ߏ੒͕౷Ұ͞Ε ޮ཰తͳαϙʔτ͕Մೳ ϨγϐΛ௥Ճͯ͠೚ҙͷߏ੒΋Մೳ

  58. ڭ܇ Ϩγϐͷ࣮૷ͱద༻͸ࣗಈԽ͕ඞཁ πʔϧͷಋೖ͸݁ہඞཁ $IFGͦͷ΋ͷΛӡ༻͢Δ࿑ྗ ࣗྗPS֎෦αʔϏε &OHJOF:BSE

  59. ࣭໰ʁ IUUQCJUMZFZDIFG ຊ೔ͷεϥΠυͳͲͷ৘ใɺ ϊϕϦςΟͷϓϨθϯτ৘ใʂ