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

SpecInfra at JAWS DAYS 2014

SpecInfra at JAWS DAYS 2014

Gosuke Miyashita

March 15, 2014
Tweet

More Decks by Gosuke Miyashita

Other Decks in Technology

Transcript

  1. Immutable Infrastructure࣌୅ͷ
    ߏ੒؅ཧπʔϧج൫SpecInfra
    JAWS DAYS 2014
    Immutable Infrastructure Track
    ٶԼ ߶ี

    View full-size slide

  2. ٶԼ ߶ี
    http://mizzy.org/
    @gosukenator
    mizzy@github
    http://serverspec.org/

    View full-size slide

  3. αʔόߏ੒؅ཧͱ͸

    View full-size slide

  4. αʔόͷ੩తͳঢ়ଶΛ
    ؅ཧ͢Δ͜ͱ

    View full-size slide

  5. αʔόͷ੩తͳঢ়ଶ
    !
    Πϯετʔϧ͞Ε͍ͯΔ
    ϛυϧ΢ΣΞ΍ઃఆͳͲ
    =

    View full-size slide

  6. αʔόߏ੒؅ཧπʔϧ

    View full-size slide

  7. ߏ੒؅ཧπʔϧͷجຊݪଇ
    • એݴతʮԿΛ͍͔ͨ͠Ͱ͋ͬͯɺͲ͏͢Δ͔Ͱ͸ͳ͍ʯ
    • ந৅Խʮ͋ͳͨͷ୅ΘΓʹ໘౗Λݟͯ͘ΕΔʯ
    • ႈ౳ੑʮඞཁͳͱ͖͚࣮ͩߦ͢Δʯ
    • ऩଋԽʮ์͓͚ͬͯ͹Ͳ͏ʹ͔ͳΔʯ
    ΦϥΠϦʔδϟύϯʰ΢ΣϒΦϖϨʔγϣϯ 5ষ ίʔυͱͯ͠ͷΠϯϑϥʱΑΓ

    View full-size slide

  8. Immutable͕αʔό
    ߏ੒؅ཧʹ༩͑ΔӨڹ

    View full-size slide

  9. ߏ੒؅ཧπʔϧͷجຊݪଇʢ࠶ܝʣ
    • એݴతʮԿΛ͍͔ͨ͠Ͱ͋ͬͯɺͲ͏͢Δ͔Ͱ͸ͳ͍ʯ
    • ந৅Խʮ͋ͳͨͷ୅ΘΓʹ໘౗Λݟͯ͘ΕΔʯ
    • ႈ౳ੑʮඞཁͳͱ͖͚࣮ͩߦ͢Δʯ
    • ऩଋԽʮ์͓͚ͬͯ͹Ͳ͏ʹ͔ͳΔʯ

    View full-size slide

  10. ႈ౳ੑ
    !
    ঢ়ଶ͕ෆఆͳͷͰ࣮ߦ
    ͕ඞཁ͔Ͳ͏͔൑அ
    =

    View full-size slide

  11. ऩଋԽ
    !
    ෆఆͳঢ়ଶΛҰఆͷ
    ঢ়ଶʹऩଋͤ͞Δ
    =

    View full-size slide

  12. Immutableલఏͱͨ͠
    ߏ੒؅ཧπʔϧͷجຊݪଇ
    • એݴతʮԿΛ͍͔ͨ͠Ͱ͋ͬͯɺͲ͏͢Δ͔Ͱ͸ͳ͍ʯ
    • ந৅Խʮ͋ͳͨͷ୅ΘΓʹ໘౗Λݟͯ͘ΕΔʯ
    • ႈ౳ੑʮඞཁͳͱ͖͚࣮ͩߦ͢Δʯ
    • ऩଋԽʮ์͓͚ͬͯ͹Ͳ͏ʹ͔ͳΔʯ

    View full-size slide

  13. ႈ౳ੑ/ऩଋԽ͕ෆཁͳΒ
    ߏ੒؅ཧ͸΋ͬͱ
    γϯϓϧʹͰ͖ΔͷͰ͸ʁ

    View full-size slide

  14. ImmutableͳΜ͔ͩΒ
    खಈͰΠϝʔδ࡞ͬͱ
    ͚͹͍͍Μ͡Όͳ͍ʁ

    View full-size slide

  15. Ͱ΋࠶ݱՄೳͳखॱ͸
    ࢒͓͖͍ͯͨ͠

    View full-size slide

  16. γΣϧεΫϦϓτ΍
    DockerfileͰ΋͍͍ͷ͸ʁ

    View full-size slide

  17. Dockerfile
    # Memcached
    #
    # VERSION 1.0
    !
    # use the ubuntu base image provided by dotCloud
    FROM ubuntu
    MAINTAINER Guillaume J. Charmes, [email protected]
    # make sure the package repository is up to date
    RUN echo "deb http://archive.ubuntu.com/ubuntu precise main
    universe" > /etc/apt/sources.list
    RUN apt-get update
    !
    # install memcached
    RUN apt-get install -y memcached

    View full-size slide

  18. ΋͏গ͠ந৅Խ͍ͨ͠

    View full-size slide

  19. ΍͸Γߏ੒؅ཧ
    πʔϧ͸ඞཁ

    View full-size slide

  20. configspecʹΑΔߏ੒؅ཧίʔυ

    View full-size slide

  21. syllabusʹΑΔߏ੒؅ཧίʔυ

    View full-size slide

  22. configspec/syllabus
    ͱ΋ʹίϚϯυ࣮ߦ͸
    SpecInfraΛར༻

    View full-size slide

  23. SpecInfra͸൚༻తίϚ
    ϯυ࣮ߦϑϨʔϜϫʔΫ

    View full-size slide

  24. ࣮ߦܗࣜͷࠩҟ
    ʢϩʔΧϧ/SSH/WinRM౳ʣ

    View full-size slide

  25. OS/σΟετϦϏϡʔγϣϯ
    ຖͷίϚϯυͷࠩҟ

    View full-size slide

  26. ͜ΕΒΛٵऩͯ͘͠Ε
    ΔϑϨʔϜϫʔΫ

    View full-size slide

  27. ݩʑ͸serverspecͷ
    Ұ෦ͩͬͨ΋ͷΛ෼཭

    View full-size slide

  28. SpecInfraͷ֓ཁ
    API
    OSந৅Խ
    ϨΠϠʔ
    Linux༻ίϚϯυ܈
    ࣮ߦܗࣜ
    ந৅Խ
    ϨΠϠʔ
    Darwin༻ίϚϯυ܈
    Solaris༻ίϚϯυ܈
    Windows༻ίϚϯυ܈

    API!
    ݺͼग़͠
    ίϚϯυ!
    ࣮ߦ

    View full-size slide

  29. configspecͷ࣮૷

    View full-size slide

  30. configspecʹΑΔߏ੒؅ཧίʔυ

    View full-size slide

  31. Configspec::Type::Package.new(‘apache2’)

    package(‘apache2’)
    !
    ͱॻ͚Δ

    View full-size slide

  32. configspecʹΑΔߏ੒؅ཧίʔυ

    View full-size slide

  33. package(‘apache2’).installed?
    ͕ݺ͹ΕΔ

    View full-size slide

  34. OSͷҧ͍΍࣮ߦܗࣜͷҧ͍͸
    SpecInfra͕ٵऩͯ͘͠ΕΔͷ
    Ͱbackend.installΛݺͿ͚ͩ

    View full-size slide

  35. SpecInfraΛར༻ͨ͠
    ࠷খ࣮૷

    View full-size slide

  36. Exec, SshҎ֎ʹ΋ɺCmd,
    WinRM, Docker, LXC༻ͷ
    όοΫΤϯυ͕͋Δ

    View full-size slide

  37. Immutableͩͱຖճ͍
    ͔ͪΒߏங͢Δ͔Β
    ͕͔͔࣌ؒΔͷͰ͸ʁ

    View full-size slide

  38. DockerfileόοΫΤϯυͷग़ྗ಺༰

    View full-size slide

  39. ShellScript
    όοΫΤϯυ

    View full-size slide

  40. ShellScriptόοΫΤϯυͷग़ྗ಺༰

    View full-size slide

  41. ࠓޙͷ՝୊

    View full-size slide

  42. υΩϡϝϯτ੔උ

    View full-size slide

  43. ϦϑΝΫλϦϯά
    ʢಛʹCommandҎԼʣ

    View full-size slide

  44. ςετίʔυ੔උ
    ʢserverspecͱͷ੾Γ෼͚ʣ

    View full-size slide

  45. ·ͱΊ
    • Immutableલఏʹ͢Δͱߏ੒؅ཧπʔϧʹႈ౳ੑ΍ऩ
    ଋԽ͸͍Βͳ͘ͳΓͦ͏ʢ͋ͬͯ΋͍͍͚Ͳʣ
    • SpecInfra͸OSຖͷίϚϯυͷҧ͍΍࣮ߦܗࣜΛٵऩ
    ͯ͘͠ΕΔ൚༻ίϚϯυ࣮ߦϑϨʔϜϫʔΫ
    • SpecInfraΛϕʔεʹͯࣗ͠෼ʹ͋ͬͨγϯϓϧͳߏ੒
    ؅ཧπʔϧΛͭͬͯ͘ΈΑ͏
    • ՝୊͸͍ͬͺ͍͋ΔͷͰίϛολʹͳΕΔνϟϯε

    View full-size slide

  46. ࢀߟϦϯΫ
    • Immutable Infrastructure࣌୅ͷConfiguration Management Toolͷཁ͓݅Αͼͦͷ࣮
    ૷ʹ͍ͭͯ - delirious thoughts
    • http://blog.kentarok.org/entry/2013/12/01/221729
    • infrastructure - specinfraΛ࢖ͬͯΈΑ͏ - Qiita
    • http://qiita.com/sawanoboly/items/d1e7794739d9d31a5316
    • Immutable Infrastructure ͷ༗༻ੑ - Togetter·ͱΊ
    • http://togetter.com/li/594684
    • ssig33.com - Docker ΛϓϩμΫτͷσϓϩΠʹ࢖͏
    • http://ssig33.com/text/Docker%20ΛϓϩμΫτͷσϓϩΠʹ࢖͏

    View full-size slide