レガシーなAnsibleを改善していくための方針/How to improve the legacy Ansible

Ed9f86b572d4af79dd5d83dadc372596?s=47 t11a22
April 17, 2019

レガシーなAnsibleを改善していくための方針/How to improve the legacy Ansible

Ansible Night in Tokyo 2019.04の発表資料
https://ansible-users.connpass.com/event/125609/

Ed9f86b572d4af79dd5d83dadc372596?s=128

t11a22

April 17, 2019
Tweet

Transcript

  1. ϨΨγʔͳ"OTJCMFΛ վળ͍ͯͨ͘͠Ίͷํ਑ "OTJCMF/JHIUJO5PLZP

  2. XIPBNJ 5XJUUFSUB 8FCۀք೥໨ όοΫΤϯυΤϯδχΞ GSPNۚ୔ࢢ

  3. Զͷʢࢲͷʣ"OTJCMFܦݧஊ

  4. ϨΨγʔͳ"OTJCMFΛͲ͏΍ͬͯ௚͍͔ͯ͘͠ʁ

  5. ͸ͳ͢͜ͱ

  6. ɾഎܠ ɾΊ͟͢ͱ͜Ζ ɾϦϑΝΫλ·ͰͷಓͷΓ ɾϦϑΝΫλํ਑ ɾ·ͱΊ

  7. എܠ

  8. ߏ੒ਤ ΦϯϓϨ IPTUT୆ QSETUHEFW $POUSPM.BDIJOF .BOBHFNFOU/PEF TTI

  9. ɾαʔόʹखಈͰมߋΛՃ͑ͯ͋Δ ɾ݅Λ௒͑ΔDIBOHFE ɾ$IFDLNPEF͕GBJMFE͢Δ ɾҎલ͍࣮ͭߦ͞Ε͔ͨఆ͔Ͱ͸ͳ͍ ɾTUHͱQSEͰࠩҟ͕͋Δ ɾWFSTJPO ೥य़࣌఺

  10. Ί͟͢ͱ͜Ζ

  11. Ί͟͢ͱ͜Ζ QMBZCPPLͱαʔόͷࠩ෼͕ͳ͍ ႈ౳ੑ͕୲อ͞Ε͍ͯΔ ճ໨Ҏ߱͸DIBOHFE ɹ΋͘͠͸ɺDIBOHFE͕ආ͚ΒΕͳ͍৔߹ OBNFͳͲͰͦΕ͕Θ͔ΔΑ͏ʹͳ͍ͬͯΔ

  12. Ί͟͢ͱ͜Ζ ఆظతʹ࣮ߦ͞Ε͍ͯΔ ࣮ߦཤྺ͕؅ཧ͞Ε͍ͯΔ

  13. ϦϑΝΫλ·ͰͷಓͷΓ

  14. Քಇ͍ͯ͠Δαʔόͱͷࠩ෼Λͳ͘͢ αʔόͷίϐʔΛͱͬͯݕূ؀ڥΛ࡞Δ ݱࡏՔಇ͍ͯ͠Δαʔόͷઃఆ஋Λίʔυʹ൓ө͢Δ "OTJCMFΛ࣮ߦݕূ͢Δ ໰୊ͳ͍͜ͱ͕֬ೝͰ͖ͨΒຊ൪αʔόͰ࣮ߦ͢Δ

  15. Քಇ͍ͯ͠Δαʔόͱͷࠩ෼Λͳ͘͢ ɾҰ୴݅௒ͷDIBOHFE͸ແࢹ ɾ$IFDLNPEF͕GBJMFE͢ΔͷΛमਖ਼

  16. "OTJCMFͷόʔδϣϯΛ্͛Δ ɾ࠷৽ͷ҆ఆ൛ʹ্͛Δ ɾಈ࡞ݕূΛ͢Δ

  17. ͜ΕͰαʔόͱQMBZCPPL͕ಉ͡ঢ়ଶʹͳͬͨ ࣍͸ํ਑ΛܾΊΔ

  18. ϦϑΝΫλํ਑

  19. ͳΔ΂͘UBTLͷத਎͸৮Βͣʹ֎ງΛຒΊ͍ͯ͘

  20. ·ͣ͸$*؀ڥΛ੔͑Δ ɾ"89ͷಋೖ ɾ$*ͷಋೖ

  21. "89ͷಋೖ ɾ࣮ߦཤྺ͕࢒ͬͯͳ͍ ɾ"OTJCMFͷϗετʹ௚઀44)ͯ͠࡞ۀͨ͘͠ͳ͍ &$Ͱ"OTJCMF"89ΛཱͯΔ &$ &#4 &*1ͷ࠷খݶߏ੒Ͱ࡞Δ

  22. "89ͷಋೖ ެࣜʹ$'OςϯϓϨʔτ͕͋Δ͕ɺࠓճͷέʔεʹରͯ͠৑௕ ͳͷͰݟૹΓ https://aws.amazon.com/jp/quickstart/architecture/awx/

  23. $POUSPM.BDIJOF "89 .BOBHFNFOU/PEF

  24. $*ͷಋೖ $JSDMF$*&OUFSQSJTFͰύΠϓϥΠϯ࡞੒ (JU)VC"DUJPOT͸(JU)VC&OUFSQSJTFʹରԠͯ͠ͳ͍ͨΊ ݟૹΓ

  25. $*ͷಋೖ ΍Γ͍ͨ͜ͱ ϦϞʔτCSBODIʹQVTI ͍ܰॲཧ  ɾ੩తղੳ TZOUBYDIFDL BOTJCMFMJOU ɾςετ Ϣχοτςετ

  26. QVTISFNPUFCSBODI BOTJCMFQMBZCPPL ɾTZOUBYDIFDL ɾBOTJCMFMJOU ɾVOJUUFTU

  27. $*ͷಋೖ ΍Γ͍ͨ͜ͱ ඇಉظPSεέδϡʔϧ࣮ߦ ॏ͍ॲཧ  ɾႈ౳ੑͷݕূ ɾςετ ౷߹ςετ 

  28. $POUSPM.BDIJOF "89 .BOBHFNFOU/PEF 13NBSHF UPXFSDMJ ݕূ༻αʔό ɾEFQMPZ ɾ*OUFHSBUJPOUFTU

  29. ͜ΕͰݕূαΠΫϧ͕੔ͬͨ ͔͜͜ΒϦϑΝΫλϦϯά

  30. ɾ࢖ΘΕ͍ͯͳ͍SPMFͷ࡟আ ɾϢχοτςετͷಋೖ ɾϩʔΧϧݕূ؀ڥΛ࡞Δ ɾσΟϨΫτϦߏ੒ΛϕετϓϥΫςΟεʹ ɾSPMF୯ҐͰλά෇͚ ɾ࣮ߦ࣌ؒͷܭଌ ɾύϑΥʔϚϯενϡʔχϯά ɾႈ౳ੑͷमਖ਼

  31. ࢖ΘΕ͍ͯͳ͍SPMFΛ࡟আ ߏ੒ਤΛݩʹલ೚ऀʹ஍ಓʹ֬ೝ

  32. Ϣχοτςετͷ௥Ճ ɾϦϑΝΫλ͍ͯ͘͠ࡍʹ࠷௿ݶͷηʔϑωοτΛઃ͚͍ͨ 1"5)ɺϓϩηεͷঢ়ଶɺϙʔτͷ֬ೝ "OTJCMFͷUBTLͱͯ͠Ϣχοτςετ௥Ճ ɹUFTUJOGSBֶशίετͷ఺͔ΒݟૹΓ

  33. ϩʔΧϧݕূ؀ڥΛ࡞Δ ɾUBTLʹมߋΛՃ͑ͨͱ͖ɺ ɹຖճϦϞʔταʔόʹରͯ͠ݕূ͢Δͷ͸େม ɾႈ౳ੑ֬ೝͷͨΊ࡞ͬͯյͤΔ؀ڥ͕΄͍͠

  34. ϩʔΧϧݕূ؀ڥΛ࡞Δ ݕূ༻%PDLFS؀ڥΛ༻ҙ͢Δ ɾ$*Ͱ࢖༻͢Δ͜ͱ΋ߟྀ͠ɺ7BHSBOUͰͳ͘%PDLFSΛબ୒ ɾύεϫʔυ͋ΓͩͱTVEPͰ͖ͳ͍όά͕͋Δ https://github.com/ansible/ansible/issues/31759 ɾطଘΦϯϓϨαʔόͱͷࠩҟ͸ߟྀͷඞཁ͋Γ

  35. σΟϨΫτϦߏ੒ΛϕετϓϥΫςΟεʹ ɾSPMFTσΟϨΫτϦ͕ͳ͍ IPHF@SPMFTDFOUPTʜͷΑ͏ͳσΟϨΫτϦߏ੒ ɾSPMF͕̎ͭͷσΟϨΫτϦʹผΕ͍ͯΔ ɾ૬ରύεࢦఆͩΒ͚

  36. σΟϨΫτϦߏ੒ΛϕετϓϥΫςΟεʹ https://docs.ansible.com/ansible/latest/user_guide/ playbooks_best_practices.html#alternative-directory-layout HSPVQIPTU͝ͱʹม਺͕ҟͳ͍ͬͯͨͷͰɺ"MUFSOBUJWF %JSFDUPSZ-BZPVUΛ࢖༻

  37. σΟϨΫτϦߏ੒ΛϕετϓϥΫςΟεʹ SPMFͷ૬ରύεࢦఆ͕ͳ͘ͳͬͨ QMBZCPPL࣮ߦ࣌ͷίϚϯυ΋୹͘ͳͬͨ QMBZCPPL͕؀ڥ͝ͱʹผΕ͓ͯΓ؅ཧ͕େม͕ͩ·ͱΊΔͷ ͸ϘϦϡʔϜ͕େ͖͍ͷͰޙճ͠ʜ

  38. SPMF୯ҐͰλά෇͚ ్தͰGBJMFEͨ͠ͱ͖ʹGBJMFEͨ͠SPMF͔Β࣮ࢪ͍ͨ͠ SPMF୯ҐͰλάΛ͚ͭΔ UBHTIPHF BOTJCMFQMBZCPPLTJUFZNMUBHTIPHF

  39. ࣮ߦ࣌ؒͷܭଌ ႈ౳ੑΛ௚͢ࡍʹɺ͕͔͔͍࣌ؒͬͯΔ΋ͷ͔Β௚͍ͨ͠ $BMMCBDL1MVHJOTͷQSPpMF@UBTLTΛ࢖͏ ansible.cfg [defaults] callback_whitelist = profile_tasks

  40. ύϑΥʔϚϯενϡʔχϯά ެࣜ#MPHΛࢀরͯ͠ઃఆ͢Δ IUUQTXXXBOTJCMFDPNCMPHBOTJCMFQFSGPSNBODF UVOJOHBOTJCMFDGH ansible.cfg [defaults] pipelining = True ssh_args

    = -o ControlMaster=auto -o ControlPersist=300s
  41. ႈ౳ੑͷमਖ਼ ࣌ؒͷ͔͔Δ΋ͷ͔Βमਖ਼͍ͯ͘͠ ຖճιʔεͷ%-ͱίϯύΠϧΛ͍ͯ͠ΔUBTLͳͲ ɾTIFMM DPNNBOENPEVMFΛ୅ସͰ͖ͳ͍͔ݕ౼͢Δ ɾXIFOTUBUFNFOUΛ࢖༻͢Δ

  42. ·ͱΊ

  43. ϨΨγʔͳ"OTJCMFͱૺ۰ͨ͠ͱ͖͸ ɾ$*؀ڥΛͭͬͯ͘଍৔ΛݻΊΑ͏ ɾςετΛॻ͍ͯ֎ງΛຒΊΑ͏ ɾஈ֊తʹվળ͠Α͏ ɾܭଌɾվળαΠΫϧΛճͦ͏ ɾͳΔ΂͘#FTU1SBDUJDFTʹد͍ͤͯ͜͏ ɾϓϩμΫτͷϑΣʔζΛݟࣺͯͯΔํ޲ੑ΋ߟ͑Α͏

  44. ͓ΘΓ