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

共通言語「Ansible」

4ee67506d99fd4d363bc178dea584105?s=47 seri
June 02, 2016

 共通言語「Ansible」

「Ansible Meetup in Tokyo 2016.06」での発表資料です。
http://ansible-users.connpass.com/event/31222/

4ee67506d99fd4d363bc178dea584105?s=128

seri

June 02, 2016
Tweet

More Decks by seri

Other Decks in Technology

Transcript

  1. ڞ௨ݴޠʮ"OTJCMFʯ !BVUIFSηϦ ڞ௨ݴޠʮ"OTJCMFʯ

  2. γεςϜΛߏங͢Δ͞·͟·ͳιϑτ΢ΣΞ • 1)1 • 1IBMDPO • OHJOY • .Z42- •

    +BWB • (BUMJOH • 'BCSJD • ;BCCJY • 'MVFOUE • ,JCBOB     FUDʜ
  3. ൴΋͍·͢

  4. ؀ڥ͍ͬͺ͍ • ։ൃ؀ڥ • 45(؀ڥ • ෛՙࢼݧ؀ڥ • ຊ൪؀ڥ •

    ࣍ظຊ൪؀ڥ
  5. ։ൃ༻ 45(ɾຊ൪༻ ΞϓϦ༻ ෛՙ؀ڥ༻

  6. αʔό୆਺ ໿୆

  7. ؅ཧऀɾɾɾ̍ਓʂ

  8. ɾɾɾώϟο

  9. αʔό؅ཧऀͷঢ়گ • +BWBͷ8FCΞϓϦέʔγϣϯ։ൃϚϯʢਓ͕͍ͳ͍͔Β΍ͬͯʣ • طଘ؀ڥҾܧ͗ʢ։ൃ؀ڥ͔Βຊ൪؀ڥ·ͰߏஙࡁΈʣ • "OTJCMFʁ΁ʔʢͦΜͳͷ͋ΔΜͩʣ • ࢀը౰ॳ͸ਓνʔϜ •

    ࠓ͸ਓνʔϜ • αʔόϚγϯࣗମΛௐୡɾ؅ཧ͢ΔΠϯϑϥνʔϜ͕
 ผ్ଘࡏ͢Δ ͦΜͳνʔϜͷ͓࿩Ͱ͢
  10. Ansible׆༻ࣄྫ

  11. ౰ࣾͷΑ͋͘Δαʔόௐୡγʔϯ ΠϯϑϥνʔϜ • αʔό༻్ • εϖοΫ • ୆਺ • ΞΧ΢ϯτ

    • ௨৴ཁ݅ • ϛυϧ΢ΣΞཁٻ ։ൃνʔϜ ֬ೝ ґཔ
  12. ൿ఻ͷεΫϦϓτ αʔό׬੒ʂ ΠϯϑϥνʔϜ

  13. ΠϯϑϥνʔϜ ։ൃνʔϜ ड͚౉͠ ࣮ࡍͷߏங࡞ۀ͸ ΄ͱΜͲ΍Βͳͯ͘ࡁΜͩɻ αʔόϝϯς΋΍ͬͯ໯͑Δʂ Ͱ͖·ͨ͠ɻ root͸ͪ͜ΒͰ
 ؅ཧ͠·͢ɻ ೚ͤͯ҆৺

  14. ޙ೔ɾɾɾ • ͜͜ͷઃఆ஋Λม͍͑ͨ • ͜͜΋ม͍͑ͨ • ͜ͷϛυϧ͍Εͯ • ઃఆ஋ڭ͑ͯ •

    ͜͜ม͑ͨʁ • ௥Ճґཔग़ͯ͠ • ͪΐͬͱ଴ͬͯ • ಋೖखॱڭ͑ͯ • ͜ͷࢿྉϝϯςͯ͠ • ͜͜ม͑ͨʁ
  15. αʔόઃఆͷओ୲౰͕ɺ
 ։ൃνʔϜͰ͸ͳ͘ΠϯϑϥνʔϜͰ ͋Δ͕ނͷ࡞ۀϥά

  16. ୹ظతʹ͸ָ͕ͩ ௕ظతʹ͸खؒ

  17. ࣗνʔϜͷαʔόௐୡγʔϯ ΠϯϑϥνʔϜ • αʔό༻్ • εϖοΫ • ୆਺ • ΞΧ΢ϯτ

    • ௨৴ཁ݅ • ϛυϧ΢ΣΞཁٻ • Ansibleͷίʔυ ։ൃνʔϜ ֬ೝ ґཔ
  18. ൿ఻ͷεΫϦϓτ αʔό׬੒ʂ ΠϯϑϥνʔϜ ඪ४ߏ੒ͷ

  19. ΠϯϑϥνʔϜ ։ൃνʔϜ ड͚౉͠ Α͠ɺAnsibleͰ ؀ڥߏஙͩʂ Ͱ͖·ͨ͠ɻ root౉͢ͷͰ ඞཁͳ࡞ۀͯ͠ ͍ͩ͘͞ɻ ࣗ෼ͨͪͰߏங

  20. "OTJCMFͰ؀ڥߏங • "OTJCMFͷίʔυ͸྆νʔϜʹରͯ͠Φʔϓϯ 㱺ෳ਺νΣοΫʹΑΔϛε๷ࢭ • ΠϯϑϥνʔϜ͕جຊઃఆͨ͠ޙ͔Βߋ৽ • αʔόʹೖΒͳͯ͘΋"OTJCMFͷίʔυ͔Βઃఆ஋Λ֬ೝͰ͖Δ 㱺ηΩϡϦςΟରࡦ •

    ։ൃνʔϜଆ͕ಋೖ͢Δϛυϧ΢ΣΞʹ੹೚Λ࣋ͯΔ 㱺αʔϏεʹ߹Θͤͨࡉ͔͍νϡʔχϯά • ։ൃνʔϜͷΠϯϑϥ࡞ۀྔ͸૿Ճ 㱺ͭΒ͍
  21. ։ൃதͷ"OTJCMF׆༂ϙΠϯτ ։ൃ؀ڥͷߏங •7BHSBOUͱ"OTJCMFͰϩʔΧϧ؀ڥΛαΫοͱߏங •αʔόͷઃఆมߋ΋ϓϧϦΫͰՄೳ σϓϩΠ •؀ڥࠩ෼ϑΝΠϧͷ҉߸Խͱ෮߸ʢ"OTJCMF7BVMUʣ •҉߸Խ͢Δ͜ͱʹΑΔର৅ϑΝΠϧͷίʔυ؅ཧ •σϓϩΠ࣌ʹ͸GBCSJDͷλεΫ಺Ͱ෮߸

  22. Ansibleͷམͱ݀͠

  23. έʔεɿ৽ͨͳαʔόΛ༻ҙ͍ͨ͠ • ࣍ظຊ൪؀ڥɺෛՙࢼݧ؀ڥΛ৽ͨʹߏங͍ͨ͠
 ʢ߹Θͤͯ୆ۙ͘ʣ • Ҏલྲྀͨ͠"OTJCMF͕͋Δ͔Β
 ͲΜͳ୆਺ͷΠϯετʔϧ΋େৎ෉ Ͱ΋࣮ࡍ͸ɾɾɾ

  24. • ྲྀ͢ஈ֊ʹͳͬͯΤϥʔൃੜ • ֎෦αʔόͱͷ͚݀͋ཁٻͷΑ͏ͳɺ
 "OTJCMF؅ཧ֎ͷ࡞ۀΛࣦ೦ • ྲྀ͚ͩ͢Ͱ͸ऴΘΒͣɺεέδϡʔϧ஗Ԇ͕ൃੜ "OTJCMFΛ࡞Δ͚ͩͰຬ଍ͤͣʹ
 υΩϡϝϯτΛͪΌΜͱ࢒͢͜ͱ͕େࣄ έʔεɿ৽ͨͳαʔόΛ༻ҙ͍ͨ͠

  25. έʔεɿ"OTJCMFා͍ 1. ຊ൪ͱಉҰͷωοτϫʔΫηάϝϯτ্Ͱྲྀ͢ͷ͸݁ߏා͍ • ࡞੒ऀ͕࢒͍ͬͯͳ͍ͱ࣮ߦ͕ਏ͍ • Ҿ͖ܧ͗͸͘͢͝ॏཁ •Ͱ΋࡞੒ऀ͸࣮ߦ͢Ε͹େৎ෉ɺఔ౓ʹ͔͠ࢥ͍ͬͯͳ͍ͨΊΪϟοϓ͕ੜ͡Δ •Ҿ͖ܧ͗ͰҰ౓Ұॹʹ1MBZCPPLΛྲྀ͢͜ͱ͕Ͱ͖Δͱ͍͍ 2.

    ඪ४ԽAnsible͸Կ͕ೖΔͷ͔Θ͔Βͳͯ͘ා͍ • ֬ೝίϚϯυ΍ESZSVO͕͋Δ͕ɺ1MBZCPPL͕ෳࡶͰ
 Ͳ͏͍͏ಈ࡞ʹͳΔ͔Θ͔Βͳ͍ •͜Ε΋΍ͬͺΓυΩϡϝϯτ͕͋Δ͔Ͳ͏͔͍ͩ͠
  26. έʔεɿ"OTJCMFΛྲྀͯ͠ΈͨΒ • Ҿ͖ܧ͍ͩ"OTJCMFΛྲྀͨ͠ΒɺTZTDPOGJH഑Լ͕
 ॻ͖มΘͬͯ͠·ͬͨʂ ΠϯϑϥνʔϜͷౖ͓Γʹ৮Εͯ͠·ͬͨɻ

  27. έʔεɿ"OTJCMFΛྲྀͯ͠ΈͨΒ ࣄલʹ΍͓ͬͯ͘΂͖͜ͱ  • ؅ཧ͠ͳ͍ʢ؅ཧͰ͖ͳ͍ʣ΋ͷΛఆٛΛ͓ͯ͘͠ • ෦ॺؒΛ·͙ͨ৔߹͸ϧʔϧ͗Ί΋ॏཁ • TZTDPOGJH഑ԼʢJQUBCMFTͳͲʣ͸͍͡Βͳ͍ͱ͔ •

    ӡ༻ϧʔϧΛܾΊ͓ͯ͘ • ϓϧϦΫͷϨϏϡΞʔʹ͢Δͱ͔͠ͳ͍ͱ͔ • ;BCCJYͷ؂ࢹઃఆ͸ΠϯϑϥνʔϜʹ࣋ͬͯ΋Β͏ͱ͔
  28. Ծॳͷສೳײ • αʔόߏஙͷ࡞ۀʹʮ"OTJCMFʯͱ͍͏୯ޠ͕ొ৔͢Δ΄Ͳɺ
 "OTJCMFͰશ෦Ͱ͖Δ͔ͷΑ͏ʹײ͍ͯͨ͡ɻ • 4.51αʔόͷઃఆ͕Ͱ͖͍ͯͳ͔ͬͨΓɺΞϓϦέʔγϣϯͷ ίʔυࣗମʹमਖ਼͕ඞཁͩͬͨΓ͕ͨ͠ɺͦΕΛҙࣝ͠ͳ͍Α͏ ʹͳͬͯ͠·͍ͬͯͨɻ • ྲྀͤ͹େৎ෉ɺͱ͍͏ͱ͜Ζ͔ΒυΩϡϝϯτ࡞੒͕


    ૄ͔ʹͳ͍ͬͯͨɻ • ͦΕ͸͓લͷϕετϓϥΫςΟε໰୊ɻ
  29. "OTJCMF͕ෳࡶԽ͢Δͱ໰୊΋ෳࡶԽ͢Δ

  30. ΋ͬͱγϯϓϧʹ

  31. Ansible͕ͭͳ͙ੈք

  32. ͍Ζ͍Ζͳͭͳ͕Γ • αʔϏε։ൃνʔϜͱΠϯϑϥνʔϜ͸ٕज़ελοΫ͕جຊҧ͏ 㱺"OTJCMFͳΒͲͪΒ΋Θ͔ΔͨΊɺͦ͜Λى఺ʹձ࿩͕Ͱ͖Δ • "OTJCMF͸࢓༷͕γϯϓϧͳͷͰɺͱ͖ͬͭ΍͍͢ɻ 㱺Πϯϑϥͷ࣮࡞ۀΛ͠ͳ͍ਓ΋Πϯϑϥͷ؅ཧํ๏ʹ৮ΕΒΕΔ • Πϯϑϥઃఆ͕ίʔυ؅ཧͰ͖Δ 㱺ΞϓϦ࣮૷ͱαʔόઃఆมߋ͕ϦϙδτϦͰඥ෇͘

  33. "OTJCMFΛΤϯδχΞͷ ڞ௨ݴޠʹ "OTJCMFΛΤϯδχΞͷ ڞ௨ݴޠʹ

  34. ͓·͚

  35. Shansible 4IBOHSJ-B"OJNF"1*ʢΞχϝʹؔ࿈͢ΔσʔλΛ3&45Ͱఏڙ͢Δ"1*ʣͷ
 ։ൃ؀ڥΛߏங͢Δ7BHSBOUͱ"OTJCMFͷϦϙδτϦɻ • https://github.com/Project-ShangriLa/shansible/tree/feature/sora ळ༿ݪ*5ઓུݚڀॴ ʢIUUQBLJCBMBCJOGPʣ

  36. 1.9͔Β2.0΁มߋ࣌ͷΤϥʔରԠ • failed to resolve remote temporary directory ͷΤϥʔ •

    https://github.com/ansible/ansible/issues/13876 • ERROR! SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh • http://www.torutk.com/projects/swe/wiki/AnsibleͰSSH઀ଓ [defaults]
 host_key_checking = False 
 [ssh_connection]
 ssh_args = -o ControlMaster=no
 pipelining = True
 scp_if_ssh = True ansible-playbookΛ࣮ߦ͢ΔσΟϨΫτϦʹ ӈهͷansible.cfgΛ഑ஔɻ ղܾࡦ
  37. 1.9͔Β2.0΁มߋ࣌ͷΤϥʔରԠ • failed_whenͱchanged_whenͰϦετ͕࢖͑ͳ͍ • https://github.com/ansible/ansible/issues/13905 failed_when: - "'pecl/zip is already

    installed' not in task_result.stdout" - "task_result.rc == 0" changed_when: - "'pecl/zip is already installed' not in task_result.stdout" - "task_result.rc != 0" failed_when: '"pecl/zip is already installed" not in task_result.stdout and task_result.rc != 0' changed_when: '"pecl/zip is already installed" not in task_result.stdout and task_result.rc == 0'