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

패커로 AMI 빌드하고, 베이그런트로 이미지 검증하기

Afeb8054efb8e03aab4ed7d90a52f11c?s=47 nacyot
July 28, 2018

패커로 AMI 빌드하고, 베이그런트로 이미지 검증하기

Afeb8054efb8e03aab4ed7d90a52f11c?s=128

nacyot

July 28, 2018
Tweet

Transcript

  1. ಁழPacker۽ AMI ࠽٘ೞҊ Hashicorp Korea User Group 1st Meetup @nacyo_t

    ߬੉Ӓ۠౟Vagrant۽ ੉޷૑ Ѩૐೞӝ
  2. ׼Ӕ݃௄

  3. 44bits.io

  4. • Part 1. ಁழ • hashicorp/packer • Part 2. ߬੉Ӓ۠౟

    • hashicorp/vagrant য়ט੄ ઱ઁ Hashicorp
  5. • Part 1. ಁழ • ಁழ ࣗѐ ߂ AMI ࠽٘ೞӝ

    • Part 2. ߬੉Ӓ۠౟ • ੼૓੸ ੉޷૑ ੘ࢿ য়ט੄ ઱ઁ Hashicorp
  6. ಁழ: ߧਊ ழझథ ੉޷૑ ࠽٘ بҳ Part 1

  7. • ఋѶ গ೒ܻா੉࣌੉ ੘زೞח Ӑഋ ࢚క • ೐۽࠺੷׬੉ ՘դ ࢚కܳ

    ੉޷૑۽ ੷੢ ழझథ ੉޷૑ ࠽٘?
  8. “ ೐۽࠺੷׬੉ۆ ࢲߡ ١੄ ਃࣗܳ ࢎਊೡ ࣻ ੓ח ࢚క ۽

    ݅٘ח ੺ରܳ ݈ೠ׮. ৈӝীח ೧׼ ਃࣗী ੗ਗਸ ೡ׼ೞҊ, ੋझఢझചೞҊ, ҳࢿਸ ೠ റ, хदա DNS ৬ э਷ ੋ೐ۄ ࢲ࠺झী ١۾ೞח ੺ରо ನೣػ׮. ೐ ۽࠺੷׬ ੺ରо ৮ܐغݶ ೧׼ ਃࣗח ࢎਊೡ ળ࠺о ػ Ѫ੉׮. ௏٘۽ ੋ೐ۄ ҙܻೞӝ 6੢, Kief Morris
  9. • և਷ ੄޷ • ೞ٘ਝয৬ ֎౟ਕ௼ ੗ਗਸ ನೣ • hashicorp/terraform

    • ગ਷ ੄޷ • ਍৔୓ઁ ਤীࢲ গ೒ܻா੉࣌ਸ प೯ оמೠ ࢚క • hashicorp/packer ೐۽࠺੷׬
  10. • և਷ ੄޷ • ೞ٘ਝয৬ ֎౟ਕ௼ ੗ਗਸ ನೣ • hashicorp/terraform

    • ગ਷ ੄޷ • ਍৔୓ઁ ਤীࢲ গ೒ܻா੉࣌ਸ प೯ оמೠ ࢚క • hashicorp/packer ೐۽࠺੷׬
  11. • গ೒ܻா੉࣌੉ ز੘ೞח ੋझఢझܳ Ӓ؀۽ ੷੢ • ࢲߡҙܻ੗о ࢲߡܳ ૒੽

    ࣻ੿ • ߸҃ ࢎ೦੉ ੓ਵݶ ੉ ࢚కܳ ׮द Ӓ؀۽ ੷੢ • ࢲߡ੄ ࢚కܳ ੤ഝਊ оמೠ ഄन੸ੋ ߑߨ! ӝઓ੄ ੉޷૑ ࠽٘
  12. ӝઓ੄ ੉޷૑ ࠽٘ AMI A AMI A' AMI A'' AMI

    A''' EC2 A EC2 A' EC2 A'' EC2 A'''
  13. • গ೒ܻா੉࣌੉ ز੘ೞח ੋझఢझܳ Ӓ؀۽ ੷੢ • ࢲߡҙܻ੗о ࢲߡܳ ૒੽

    ࣻ੿ • ߸҃ ࢎ೦੉ ੓ਵݶ ੉ ࢚కܳ ׮द Ӓ؀۽ ੷੢ • ࢲߡ੄ ࢚కܳ ੤ഝਊ оמೠ ഄन੸ੋ ߑߨ! • ҙܻо য۵Ҋ ੤അ ࠛоמ New! ӝઓ੄ ੉޷૑ ࠽٘
  14. • ੉޷૑ ࠽٘ җ੿ਸ ੿ഛ൤ ੤അ ࠛо • ੗زചо য۵Ҋ

    ੉޷૑ ࠽٘/࢏ઁܳ ࣚࣻ ೧ঠೣ • جইоҊ ੓ח ࢲߡܳ ୭؀ೠ ߑ஖ೞѱ غח ࠗ੘ਊ • ঱ઁ ೙ਃೡ૑ ݽܰ޲۽ ੉੹ ੉޷૑ب ࢏ઁ ࠛо • ੉޷૑ח ҅ࣘ ऺ੉ӝ݅ ೣ ӝઓ੄ ੉޷૑ ࠽٘ ޙઁ੼
  15. brew install packer

  16. • ಁழ੄ ࠽٘ח ࠽؊৬ ೐۽࠺੷ց੄ ઑ೤ • ࠽؊: ౠ੿ ೒ۖಬ੄

    ੉޷૑ܳ ݅٘ח ೒۞Ӓੋ • ೐۽࠺੷ց: ೐۽࠺੷׬ਸ ࣻ೯ೞח ೒۞Ӓੋ ಁழ੄ ҳࢿ ਃࣗ ࠽؊ / ೐۽࠺੷ց
  17. Builder Image Provisioner Image

  18. Builder: docker Docker Image Provisioner shell Docker Image

  19. Builder: virtualbox-ovf VirtualBox VM Provisioner chef-solo OVF

  20. Builder: amazon-ebs AMI Provisioner ansible-local AMI

  21. { "builders": [ ... ], "provisioners": [ ... ] }

    ಁழ ࢸ੿ ౵ੌ
  22. "builders": [ { "type": "amazon-ebs", "region": "ap-northeast-2", "availability_zone": "ap-northeast-2c", "source_ami":

    "ami-9d6fd8f3", "instance_type": "t2.small", "ssh_username": "ubuntu", "ami_name": "image {{isotime \"2006-01-02 1504\" | clean_ami_name}}", "security_group_ids": [ "sg-b8ad09d1", "sg-5594bc3f" ], "subnet_id": "subnet-abcacae1", "ssh_interface": "public_ip", "associate_public_ip_address": true } ], ࠽؊: amazon-ebs
  23. "provisioners": [ { "type": "ansible", "playbook_file": "./provisioner/server.yml", "host_alias": "server", "extra_arguments":

    [ "--extra-vars", "ansible_python_interpreter=/usr/bin/python3" ] } ] ೐۽࠺੷ց: ansible
  24. • ಁழ ೐۽ં౟ • ೐۽࠺੷ց৬ ೣԋ ௏٘۽ ҙܻ • ߸҃੉

    ੓ਸ ٸ݃׮ ݒߣ ੉޷૑ܳ ࢜۽ ࠽٘ • ߸҃ ࢎ೦੉ ݽف ੷੢غ޲۽ ੤അ੉ оמ೧૗ • ௏٘ച۽ ҙܻغ޲۽ ੗زചо оמ೧૗ ಁழ੄ ੉޷૑ ࠽٘ ౠ૚
  25. Packer Build Builder: amazon-ebs AMI Provisioner ansible-local AMI

  26. Packer Build Repo 8b819 AMI A Repo 2ce54 AMI B

    Repo 099c3 AMI C Repo 934b6 AMI D commit
  27. AMI A AMI A' AMI A'' AMI A''' EC2 A

    EC2 A' EC2 A'' EC2 A''' Packer Build Repo 8b819 AMI A Repo 2ce54 AMI B Repo 099c3 AMI C Repo 934b6 AMI D commit ੋझఢझ ӝ߈ ੉޷૑ ࠽٘ ಁழܳ ࢎਊೠ ੉޷૑ ࠽٘
  28. 1. ੋझఢझ ߂ ੐द ܻࣗझ ࢤࢿ 2. ੋझఢझী ޷ܻ ળ࠺ೠ

    ೐۽࠺੷ց۽ ೐۽࠺੷׬ 3. ೐۽࠺੷׬੉ ՘աݶ ࢚కܳ ੉޷૑۽ ੷੢ 4. ੋझఢझ ߂ ੐द ܻࣗझ ઁѢ ಁழ۽ ੉޷૑ ࠽٘ җ੿
  29. • nacyot/packer_and_vagrant ؘݽ 01 ಁழ۽ AMI ࠽٘

  30. • ੉ ݽٚ җ੿੉ ױ ೠ ߑী ੉ܖয૗ • ࠽٘

    दр੉ ӡ׮ • ਗ஗੸ਵ۽ ࠽٘ җ੿ী ѐੑೡ ࣻ হ਺ • ೐۽࠺੷׬ীࢲ ޙઁо ࢤӝݶ ୊਺ࠗఠ ׮द ಁழ੄ ױ੼
  31. ߬੉Ӓ۠౟۽ ੼૓੸ ੉޷૑ ੘ࢿ Part 2

  32. brew cask install vagrant

  33. ठۄ੉٘ ৔࢚

  34. • ߬੉Ӓ۠౟੄ ߅झח ೐۽߄੉؊৬ ೐۽࠺੷ց੄ ઑ೤ • ೐۽߄੉؊: ౠ੿ ೒ۖಬ੄

    VMਸ ݅٘ח ೒۞Ӓੋ • ೐۽࠺੷ց: ೐۽࠺੷׬ਸ ࣻ೯ೞח ೒۞Ӓੋ ߬੉Ӓ۠౟੄ ҳࢿਃࣗ ೐۽߄੉؊ / ೐۽࠺੷ց
  35. • ೐۽߄੉؊ vs. ࠽؊ • ಁழ੄ ࠽؊ח ߬੉Ӓ۠౟੄ ೐۽߄੉؊ী ؀਽

    • ೐۽߄੉؊: Ѿҗޛ۽ VMਸ ݅ٝ • ࠽٘: Ѿҗޛ۽ ੉޷૑ܳ ݅ٝ • ೐۽࠺੷ց = ೐۽࠺੷ց ߬੉Ӓ۠౟৬ ಁழ ࠺Ү (1)
  36. • ಁழ੄ ੉޷૑ ࠽٘ • ܻࣗझ ࢤࢿ, ੉޷૑ ࠽٘, ܻࣗझ

    ઁѢо ೠߣী • ߬੉Ӓ۠౟੄ VM ળ࠺ җ੿ • upਸ ೞݶ VMਸ ࢤࢿೞҊ ೐۽࠺੷׬੉ ૓೯ؽ • ೐۽࠺੷ցо ߸҃غݶ ୶о۽ provision оמ • VM਷ ਗೞח द੼ী destroy оמ ߬੉Ӓ۠౟৬ ಁழ ࠺Ү (2)
  37. Packer Build Repo 8b819 AMI A Repo 2ce54 AMI B

    Repo 099c3 AMI C Repo 934b6 AMI D commit
  38. ग܉٬Ѣ੄ ಁழ ࠽٘ ࠽٘ܳ प೯ೞӝ ੹ө૑ח ࠽٘੄ ࢿҕ ৈࠗܳ ঌ

    ࣻ হ਺ ೐۽࠺੷ց ௏٘ সؘ੉౟
  39. Packer Build Repo 8b819 AMI A Repo 2ce54 Error! Repo

    099c3 Error! Repo 934b6 AMI D commit
  40. Repo a3e89 Packer build Repo 32ab21 AMI VM vagrant up

    VM' VM'' vagrant provision vagrant provision error! update provisioner code
  41. о࢚ ݠन? о࢚ ݠनҗ ಁழ ࠽٘ ജ҃਷ ׮ܰ׮

  42. • VM ؀न AWS ੋझఢझо प೯ • ಁழо पઁ۽ ࠽٘ೞח

    ജ҃ਸ Ӓ؀۽ ࢎਊ оמ • AMI ੉޷૑ܳ ࢎਊ оמ • ই݃ઓ ֿܻझ ജ҃ب ࢎਊ оמ • ݃૑݄ ழ޿੉ 2016֙... vagrant-aws ߬੉Ӓ۠౟ AWS ೐۽߄੉؊
  43. • nacyot/packer_and_vagrant ؘݽ 02 vagrant-aws ೐۽࠺੷׬

  44. • destroyܳ ೞ૑ ঋਵݶ ੋझఢझо ҅ࣘ թই੓਺ • ੗ز੸ਵ۽ ઙܐೞب۾

    ҳࢿೞח ѱ ߬झ౟ • ޷ޑೞѱ ಁழ ࠽٘ ജ҃җ ׮ܳ ࣻ ੓਺ • оמೞ׮ݶ ݽٚ ২࣌ਸ ಁழ ജ҃җ زੌೞѱ • ೐۽࠺੷׬ਸ ৈ۞ߣ ೞ׮ࠁݶ ࢚కо ׳ۄ૗ • ಁழ ࠽٘ ੹ীח destroy റ ׮द up೧ࢲ Ѩૐ ߬੉Ӓ۠౟੄ ೣ੿
  45. • ಁழܳ ࢎਊ೧ ੉޷૑ ࠽٘ܳ ੗زച • ߬੉Ӓ۠౟ܳ ࢎਊ೧ ੉޷૑

    ࠽٘ җ੿ਸ ޷ܻ Ѩૐ • ׼Ӕ݃௄ীࢲ पઁ۽ ࢎਊೞҊ ੓ח ߑߨ • Үള: әೡࣻ۾ جইо੗ Ѿۿ
  46. None
  47. Thank you @nacyo_t