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

入門Chef Solo落ち穂拾い

入門Chef Solo落ち穂拾い

Provisioning Frameworks Casual Talks vol.1 (https://gist.github.com/studio3104/5417631) での発表スライドです

Naoya Ito

May 10, 2013
Tweet

More Decks by Naoya Ito

Other Decks in Technology

Transcript

  1. ೖ໳$IFG4PMP
    མͪึर͍

    View full-size slide

  2. ຊ೔ͷ࿩୊

    View full-size slide

  3. •  ग़൛ޙͷ൓Ԡ͔Β
    •  མͪึर͍

    View full-size slide

  4. GBDFCPPLͱDIFG

    View full-size slide

  5. • $IFG$POG
    • GBDFCPPLͷதͷਓൃද
    IUUQULBLIBUFOBCMPHDPNFOUSZ

    View full-size slide

  6. •  QFPQMF
    •  5FOTPGUIPVTBOETPG
    IFUFSPHFOFPVTTZTUFNT
    •  0QTDPEF1SJWBUF$IFG
    •  l5FTUJOHBHBJOTUSFBMTZTUFNJT
    VTFGVMBOEOFDFTTBSZz

    View full-size slide

  7. $IFGͰͲ͜·Ͱ΍Δͷ

    View full-size slide

  8. •  $IFGͰશ෦΍Δͷ
    •  σϓϩΠ΋$IFGͰ
    •  TTIͯ͠௚઀มߋ͸͢Δͷ

    View full-size slide

  9. •  جຊ͸$IFG͚ͩͰ΍Δ
    – Πϯελϯεىಈޙͷߏ੒มߋ͸શͯ
    $IFGͰߦ͏ɻ௚઀มߋ͠ͳ͍
    •  ΞϓϦέʔγϣϯͷσϓϩΠ͸ྫ֎
    – DBQJTUSBOPFUD

    View full-size slide

  10. •  େࣄͳߟ͑ํ
    – (>$IFGࣗಈԽπʔϧ
    – <0,>$IFGϊʔυͷঢ়ଶ؅ཧ
    ccoonnvveerrggeennccee
    ((収束))

    View full-size slide

  11. •  ϊʔυͷঢ়ଶ͸$IFGͰهड़͞Ε͍ͯ
    ͳ͚Ε͹ͳΒͳ͍
    – 㱺TTIͰߏ੒มߋ͢Δͱهड़͞Εͯͳ͍
    ঢ়ଶ͕ଘࡏ͢Δ͜ͱʹ
    •  ΞϓϦέʔγϣϯσϓϩΠ͸ಛघ
    – SPMMCBDL΍ϒϧʔάϦʔ ϯσϓϩΠ
    – ͦΕઐ༻ͷπʔϧʹ೚ͤΔ

    View full-size slide

  12. $IFG4PMPͰͲ͜·Ͱ

    View full-size slide

  13. •  $IFG4PMP͸ͲͷϨϕϧ·Ͱ
    •  ෳ਺୆ʹ$IFG4PMP
    •  $IFG4FSWFSWT$IFG4PMP

    View full-size slide

  14. •  େن໛ ਺ඦʙ ୆

    – ͓ͦΒ͘$IFG4FSWFSҰ୒
    •  தن໛ ʙ਺े୆

    – $IFG4PMPͰ΋ؤுΕΔ
    – $IFG4FSWFSೖΕΔ͔೰ΈͲ͜Ζ
    •  খن໛ ʙे਺୆

    – $IFG4PMPͰे෼

    View full-size slide

  15. $  echo  host1  host2  host3  |  xargs  –n  1  knife  solo  cook
    ਺୆ͳΒ͜ΕͰ

    View full-size slide

  16. $  cap  provision
    YBSHTͰਏ͘ͳͬͨΒŋŋŋ

    View full-size slide

  17. $  knife  search  node  “platform:centos  AND  languages_ruby_version:
    1.8*”
    $IFG4FSWFS͸OPEFΛͰݕࡧͰ͖Δ

    View full-size slide

  18. $  sudo  chef-­‐client  –d  –i  900
    $IFG4FSWFSͰ͸$MJFOU͕ࣗ཯ߋ৽Ͱ͖Δ

    View full-size slide

  19. •  $IFG4FSWFSͷಋೖ͕໘౗
    – DIFG[FSPͬͯͷ͕ग़ͨͦ͏Ͱ͢
    – %#΍ೝূ͕ͳ͍ͷͰӡ༻ָ͕
    – ˞ະݕূ

    View full-size slide

  20. 'BCSJDWT$IFG

    View full-size slide

  21. •  ൺֱ͕࣠ͣΕ͍ͯ·͕͢ŋŋŋ
    •  'BCSJD ͱTI
    $IFG͸ίϯηϓ
    τ͕େ͖͘ҟͳΔ

    View full-size slide

  22. •  ʲೋ౓໨ʳେࣄͳߟ͑ํ
    – (>$IFGࣗಈԽπʔϧ
    – <0,>$IFGϊʔυͷঢ়ଶ؅ཧ
    ccoonnvveerrggeennccee
    ((収束))

    View full-size slide

  23. •  $IFG͸ঢ়ଶΛ؅ཧ͢Δ
    – ϨγϐͱҟͳΔঢ়ଶΛɺͦͷঢ়ଶʹͳ
    ΔΑ͏ʹ͢Δ
    •  ৔߹ʹΑͬͯ͸ʮ໭͢ʯ
    •  ʮαʔόʔߏஙࣗಈԽʯ͸ͦͷҰ໘
    •  'BCSJD͸ঢ়ଶ͸؅ཧ͠ͳ͍
    – ॻ͔Εͨ௨Γʹʮલਐʯ͢Δ͚ͩ

    View full-size slide

  24. ϨγϐΛ(JUͰ؅ཧ͢Ε͹ʮϊʔυͷঢ়ଶʯΛόʔδϣϯ؅ཧ͢Δ͜ͱ͕Ͱ͖
    Δɻ؅ཧ͍ͯ͠Δͷ͸୯ͳΔίʔυͰ͸ͳ͘ʮঢ়ଶʯɻ

    View full-size slide

  25. 7.Λڞ༗͢Δͷ
    ϨγϐΛ഑Δͷ

    View full-size slide

  26. •  ։ൃ؀ڥͷඪ४Խʹ$IFGΛ࢖͓͏
    •  Ͱ͖͕͋ͬͨ7.ΠϝʔδΛڞ༗͢΂
    ͖͔ɺϨγϐΛڞ༗͢΂͖͔ŋŋŋ

    View full-size slide

  27. •  ϨγϐΛڞ༗͠Α͏ʂ
    – ࣗ෼ͰDPOWFSHFODFͯ͠΋Β͏
    – ίʔυͰঢ়ଶΛ֎෦Խͨ͠ͷ͔ͩΒ
    – Ϩοπ4PDJBM$PEJOH

    View full-size slide

  28. ςετͲ͏͢Δͷ

    View full-size slide

  29. •  CFGPSFDPOWFSHFODFͳςετ
    •  *OUFHSBUJPOςετ

    View full-size slide

  30. •  CFGPSFDPOWFSHFODFͳςετ
    – LOJGFDPPLCPPLUFTU
    •  γϯλοΫενΣοΫͱ͔
    – GPPEDSJUJD
    •  -*/5&3Έ͍ͨͳͷ
    – DIFGTQFD
    •  Ϣχοτ
    ςετ
    – TUSBJOFS
    •  Ҏ্ͷπʔϧͷ࣮ߦΛิॿ͢Δ΋ͷ

    View full-size slide

  31. require  'chefspec'  
     
    describe  'http_server::default'  do  
       let  (:chef_run)  {  ChefSpec::ChefRunner.new.converge  'http_server::default'  }  
       it  'should  install  nginx'  do  
           chef_run.should  start_service  'nginx'  
       end  
     
       it  'should  start  nginx'  do  
           chef_run.should  start_service  'nginx'  
       end  
    end
    DIFGTQFD IUUQRJJUBDPNJUFNTGFEFFCDCGΑΓ

    View full-size slide

  32. •  *OUFHSBUJPOςετ
    – NJOJUFTUDIFGIBOEMFS
    – TFSWFSTQFD
    – 5FTU,JUDIFO
    •  ෳ਺؀ڥΛ7BHSBOUͰ্ཱͪ͛ͯ
    NJOJUFTUͰςετ૸ΒͤͨΓ͢Δ

    View full-size slide

  33. require  'minitest/spec’  
     
    describe_recipe  'spec_examples::default'  do  
       describe  "files"  do  
           it  "creates  the  config  file"  do  
               file("/etc/fstab").must_exist  
           end  
     
           it  "ensures  that  the  foobar  file  is  removed  if  present"  do  
               file("/etc/foobar").wont_exist  
           end  
       end  
    end
    NJOJUFTUDIFGIBOEMFS

    View full-size slide

  34. TFSWFSTQFD

    ଞͷਓͷൃදݟͯͶ

    View full-size slide

  35. •  ఆ൪͸UFTULJUDIFONJOJUFTU
    –  PQTDPEFެࣜͩ͠
    •  TFSWFSTQFDਪ͠
    –  *OUFHSBUJPOςετ͸ॲཧܭʹґଘ͠ͳ͍ํ͕ྑ͍
    •  কདྷԿ͔ʹ৐Γ׵͑Δ࣌΋ςετΛͦͷ··ྲྀ༻Ͱ͖Δ
    –  UFTULJUDIFOTFSWFSTQFDྑͦ͞͏ɻͨͩ͠ະݕূ
    •  ೰·͍͠ͱ͜Ζ
    – DIFGTQFD*OUFHSBUJPO5FTU͸݁ߏ৑௕ŋŋŋ
    ಉ͡Α͏ͳهड़͕ଟ͍

    View full-size slide

  36. •  $IFG੝Γ্͕ͬͯΔ
    – GBDFCPPL͕਺ສ୆ͱ͔ܹ͍͠
    •  ࢖͏ͳΒ$IFGͷίϯηϓτʹै͓͏
    – ʮϊʔυͷঢ়ଶʯΛ؅ཧ͠Α͏
    •  TFSWFSTQFDਪ͠ɻଞ΋ީิ͋ΔΑ

    View full-size slide