初めてのChefの教室 (v1.2 Chef11対応版)

9b69fbdeb0713def44a8731091ce5885?s=47 Yusuke Ando
July 20, 2013
12k

初めてのChefの教室 (v1.2 Chef11対応版)

9b69fbdeb0713def44a8731091ce5885?s=128

Yusuke Ando

July 20, 2013
Tweet

Transcript

  1. ॳΊͯͷ$IFGͷڭࣨ ೥࠷஫໨ͷ%FW0QTπʔϧ

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

  3. 4UBSPOVT

  4. 3VCZ/PEFKT1)1ରԠ1BB4 $IFGͰΫϥ΢υΛࣗಈߏங ࣌ؒ༗ਓ؂ࢹ 44)TVEPՄೳ͔ͭαϙʔτ༗

  5. "84 $IFG αϙʔτ

  6. None
  7. None
  8. "HFOEB $IFGͱ͸ ηοτΞοϓ Ϩγϐͷهड़ ৘ใͷ୳͠ํ

  9. $IFGͱ͸

  10. None
  11. $IFG 0QTDPEFࣾͷ$$0"EBN+BDPCࢯ࡞ 3VCZ੡ͷγεςϜ؅ཧπʔϧ ઃఆϑΝΠϧΛݩʹαʔόΛࣗಈઃఆ 6OJY-JOVY.BD8JOEPXTରԠ ೥ʹ೔ຊͰେϒϨΠΫ

  12. ྺ࢙ WFSTJPO WFSTJPO WFSTJPO WFSTJPO WFSTJPO WFSTJPO

  13. *OGSBTUSVDUVSFBT$PEF 2011/2 ΠϯϑϥΛίʔυͰهड़͢Δ ࣌୅͕౸དྷͨ͠

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

  16. Chef Server $IFG$MJFOU4FSWFS ։ൃऀͷPC Workstation Node Cookbook Node DIFGDMJFOU DIFGDMJFOU

    "1* Cookbook LOJGF PIBJ PIBJ
  17. ႈ౳ੑͱPIBJ ႈ౳ੑ Կ౓࣮ߦͯ͠΋ಉ݁͡Ռ΁ऩଋ͢Δ PIBJ ࣮ߦதͷ؀ڥͷ৘ใΛऔಘ͢Δ$IFGͷ ϓϥοτϑΥʔϜΛࢧ͑ΔϞδϡʔϧ ౾ ஌ ࣝ

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

  19. 1SJDF

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

  21. )PTUFE$IFG

  22. αʔό༻ҙͱ͔໘౗ʁ

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

  24. ։ൃऀͷPC Workstation Node $IFG4PMP Node DIFGTPMP Cookbook LOJGF Cookbook DIFGTPMP

    Cookbook TTI TTI
  25. ͳΜ͔؆୯ͦ͏ʂ

  26. DIFGTPMPେਓؾ εϚϗͰ΋ಡΊΔΑʂ

  27. None
  28. ։ൃऀͷPC Workstation Node ,OJGF4PMP Node DIFGTPMP Cookbook LOJGF Cookbook DIFGTPMP

    Cookbook TTI TTI LOJGFTPMP͕શ෦ࣗಈͰ΍Δ
  29. ·ͣ͸$IFG4PMPͰ ϨγϐΛ࢖ͬͨߏஙʹ ׳ΕΔͷ͕٢

  30. ηοτΞοϓ

  31. ηοτΞοϓ 3VCZ 3VCZHFNT TPMPSC OPEFKTPO ࣗಈԽ͞ΕͨͷͰؾʹ͠ͳ͍Ͱྑ͠

  32. *OTUBMM $ curl -L https://www.opscode.com/chef/ install.sh | sudo bash $

    chef-solo -v Chef: 11.4.0 PQUʹඞཁͳ3VCZͳͲΛશͯΠϯετʔϧ HFNͰΠϯετʔϧ͸ݹ͍ํ๏
  33. 3VCZͷ؅ཧ͸஫ҙ ࣗಈԽ͞ΕͨͷͰؾʹ͠ͳ͍Ͱྑ͠

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

  35. 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"]

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

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

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

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

  40. ςετ࣮ߦ

  41. ͜͜·Ͱͷ·ͱΊ DVSM-IUUQTXXXPQTDPEFDPN DIFGJOTUBMMTIcTVEPCBTI TVEPLOJGFDPPLCPPLDSFBUFIPHF TVEPDIFGTPMPPIPHF

  42. ϓϥε ษڧ༻ͳΒ7BHSBOU͕ศར ϩʔΧϧ΁ͷ7.ߏஙͷࣗಈԽ $IFG͕ࢼͤΔ؀ڥ͕ίϚϯυҰൃ ͋ΒΏΔ։ൃऀඞܞͷπʔϧ

  43. Ϩγϐͷهड़

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

  45. LOJGFίϚϯυ DIFGαʔόͱͷ௨৴΍֤छ࡞ۀΛߦ͏ ΫϥΠΞϯτ DIFGTPMPͰར༻͢Δ৔߹͸ΫοΫϒο ΫͷॳظԽ࡞ۀʹ࢖͏ ϓϥάΠϯͰαϒίϚϯυΛ֦ுՄ

  46. αϒίϚϯυ ߦ͋Δϔϧϓ ʢ֮͑ΒΕͳ͍ʣ

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

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

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

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

  51. Α͘࢖͏ػೳ

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

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

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

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

  56. 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
  57. ಈతʹϑΝΠϧΛ࡞੒

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

  59. ͦͯ͠ ࣗྗͰهड़ͨ͠ϨγϐΛஷΊ͍ͯ͘ ωοτ্ͷϨγϐΛख௚ͯ͠͠ར༻ GPPEDSJUJD΍TFSWFSTQFDͳͲͰςετ *OGSBTUSVDUVSFBTDPEFΛ࣮ݱ

  60. &OHJOF:BSEͷ৔߹

  61. 

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

    Λ8FCͷૢ࡞Ͱඞཁͳ࣌Ϋϥ΢υʹ൓ө ΧελϜϨγϐ Amazon Web Service Windows Azure Verizon/Terremark
  63. ಥવͷ੬ऑੑରԠ

  64. ੬ऑੑରԠͳͲΛਵ࣌഑৴

  65. GitHub ։ൃऀͷPC &OHJOF:BSE-PDBM Cookbook &OHJOF:BSE-PDBM Ϋϥ΢υ্ͱಉҰͷϨγϐͰϩʔΧϧʹ ։ൃ؀ڥΛ࡞Δπʔϧ VM DIFGTPMP BQQMZ

    7BHSBOU Node DIFGTPMP BQQMZ
  66. ׆ൃͳϝϯςφϯε

  67. ৘ใͷ୳͠ํ

  68. ެ։͞Ε͍ͯΔϨγϐ ͞·͟·ͳํ๏Ͱ͞·͟·ͳஂମ͕Ϋ οΫϒοΫΛެ։͍ͯ͠Δ ϨγϐΛ࠶ར༻͢Δ৔߹͸શମͷΞʔ ΩςΫνϟʹେ͖ͳӨڹ

  69. DPNNVOJUZPQTDPEFDPN

  70. (JU)VC্ͷϦιʔε opscode-cookbooks ެࣜΫοΫϒοΫ rightscale/cookbooks_public engineyard/ey-cloud-recipes aws/opsworks-cookbooks ֤ϓϥοτϑΥʔϜ޲͚ jsierles/chef_cookbooks ͔ͭͯ͸ 37signalsͷϦϙδτϦͩͬͨ΋ͷ

  71. 4PVSDFΠϯετʔϧΛ࣮૷

  72. None
  73. 3PMF͕࣮૷͞Ε͍ͯΔ

  74. None
  75. None
  76. ͪΐͬͱมΘͬͨ෺ pivotal/pivotal_workstation Pivotalͷ։ൃऀͷPCΛηοτΞοϓ͢Δ

  77. $ISPNF

  78. .BDͷนࢴΛઃఆ

  79. ڭ܇ ެࣜϨγϐ͸ϚϧνϓϥοτϑΥʔϜ 1BB4ܥ͸޻෉͕࣮૷͞Ε͍ͯΔ ಠࣗʹॻ͘ͳΒܾΊଧͪՄೳ ʮखॱॻʯΛࣗಈԽ͢Δهड़ྗ ΫοΫϒοΫͷӡ༻ΛͲ͏͢Δʁ

  80. ݁࿦

  81. ؤுΓ͍ͨਓ ؤுΕͳ͍ਓ ͱʹ͔͘Ϩγϐॻ͘ &OHJOF:BSE΁Ͳ͏ͧʂ