Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
create_prod_and_dev_vm_image_atst_by_packer
Search
Tatsuro Mitsuno
July 07, 2016
Technology
0
11k
create_prod_and_dev_vm_image_atst_by_packer
UZABASE Meetup#4 〜大規模サービスを支えるインフラ〜
#UzabaseMeetup
1コマンドで本番サーと開発サーバのVMイメージを作る話
Tatsuro Mitsuno
July 07, 2016
Tweet
Share
More Decks by Tatsuro Mitsuno
See All by Tatsuro Mitsuno
マルチアカウントでのIAMユーザー把握と可視化 IAMユーザー棚卸しへの取り組み / Understanding and Visualizing IAM Users with Multiple Accounts
kotatsu360
2
4.4k
AWS Configを用いたマルチアカウント・マルチリージョンでのリソース把握とコンプライアンス維持への取り組みについて / Using AWS Config for Multi-Account, Multi-Region Resource Understanding and Maintaining Compliance
kotatsu360
3
5.1k
AWS Single Sign-Onを用いた、セキュアでより良いログイン体験への取り組み / AWS Single Sign-On for a better experience and more secure login
kotatsu360
3
4.6k
【解説】第7章 はじめての本番デプロイ / zozotechbook1-ch07-deploypipeline
kotatsu360
0
1.3k
ZOZO Researchの研究活動を支える Amazon SageMaker 利用 導入課題の解決と展開について / Using Amazon SageMaker to Support ZOZO Research Activities
kotatsu360
2
690
jdk-1812-mugt-session-latter-half-iqon-crawler-on-mesos
kotatsu360
1
1.2k
IQON Crawler BackEnd ~AWS Managed Service makes women beautiful~
kotatsu360
2
13k
goodby-waiting-status-forever
kotatsu360
3
770
Apache Mesos with Amazon EC2 SpotFleet
kotatsu360
4
1.6k
Other Decks in Technology
See All in Technology
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
600
マルチプロダクトな開発組織で 「開発生産性」に向き合うために試みたこと / Improving Multi-Product Dev Productivity
sugamasao
1
310
開発生産性を上げながらビジネスも30倍成長させてきたチームの姿
kamina_zzz
2
1.7k
OCI Security サービス 概要
oracle4engineer
PRO
0
6.5k
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
330
【Startup CTO of the Year 2024 / Audience Award】アセンド取締役CTO 丹羽健
niwatakeru
0
1.3k
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
150
DynamoDB でスロットリングが発生したとき/when_throttling_occurs_in_dynamodb_short
emiki
0
260
テストコード品質を高めるためにMutation Testingライブラリ・Strykerを実戦導入してみた話
ysknsid25
7
2.7k
障害対応指揮の意思決定と情報共有における価値観 / Waroom Meetup #2
arthur1
5
490
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
140
Zennのパフォーマンスモニタリングでやっていること
ryosukeigarashi
0
190
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Embracing the Ebb and Flow
colly
84
4.5k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Six Lessons from altMBA
skipperchong
27
3.5k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
900
Fireside Chat
paigeccino
34
3k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Transcript
7"4*-: *OD ίϚϯυͰ ຊ൪αʔόͱ։ൃαʔό ͷ7.Πϝʔδ Λ࡞Δ 6;"#"4&.FFUVQ ʙେنαʔϏεΛࢧ͑ΔΠϯϑϥʙ
7"4*-: *OD ࣗݾհ w ޫୡ࿕5BUTVSP.JUTVOP !LPUBUTV w 7"4*-: *OD*OGSB&OHJOFFS
w ʙ w ҆ͯͯ҆͘͘શͳΠϯϑϥΛ࡞Δ w ੜ࢈ੑΛ্ͤ͞ΔऔΓΈ झຯ *DPOJMMVTUSBUFECZ:04)* IUUQTXXXGBDFCPPLDPNZPTIJZPOF
7"4*-: *OD
7"4*-: *OD &$*OTUBODF w BQQMJDBUJPO XFC BQJ CBUDI DSBXMFS
ʜ w NJEEMFXBSF PQT BE TPMS SFEJT OBU ʜ (PPHMF$MPVE&OHJOFগ͠ J20/
7"4*-: *OD ίϚϯυͰຊ൪ˍ։ൃαʔόΛ࡞Δ J20/αʔόͷ࡞Γํ QBDLFSCVJMECBTFKTPO WBHSBOUCPY BXTFDBNJ HDFJNBHF
શ෦Ͱ͖Δ
7"4*-: *OD ܦҢɿΞϓϦέʔγϣϯαʔόͷҠߦ w ʙ w $FOU046CVOUV w 3VCZʢҰ෦
w DIFGͱTQFD͋ͬͨ w ʮखݩͷ7.Ͱݕূͯͦ͠ͷ7.Λຊ൪Ͱͦͷ··͑ͨΒ͍͍ͷʹʯ
7"4*-: *OD ઓུ w ݱঢ়ͷࢿ࢈Λ༗ޮ׆༻ ߏཧ$IFG w ຊ൪։ൃಉ͡ϨγϐͰߏཧ͢Δ ࠩҟ$IFGͷ&OWJSPONFOUTͰԿͱ͔͢Δ w
ࠓޙͷߋ৽͕༰қɾຊ൪ͱ։ൃͷဃΛى͜͞ͳ͍ ΞΫγϣϯͰߋ৽Ͱ͖ΔૉఢͳԿ͔Λ͏
7"4*-: *OD ɹɹ1BDLFSCZ)BTIJ$PSQ w )BTIJ$PSQ w ༷ʑͳϓϥοτϑΥʔϜ্ͷϚγϯΠϝʔδΛ࡞ΔͨΊͷπʔϧ w ઃఆϑΝΠϧ+40/ w
ϓϥοτϑΥʔϜͱϓϩϏδϣϯπʔϧͷΈ߹Θͤࣗ༝ w #VJME 1SPWJTJPOΛҰ࿈ͷྲྀΕͱ࣮ͯ͠ߦ
7"4*-: *OD ઃఆϑΝΠϧ Ұ෦ $ cat base.json { "builders":[ {"type":
"virtualbox-ovf"}, {"type": "amazon-ebs" }, {"type": "googlecompute" } ], "provisioners": [ { "type": "chef-client" } ] } ˞࣮ࡍʹඞਢͷύϥϝʔλ͕ଞʹ͋Γ·͢ Vagrant BoxͷݩʹͳΔVirtualBox Amazon EC2 AMI Google Compute Engine Image VMʹchef-clientͰߏཧ
7"4*-: *OD ઓུ w ✅ݱঢ়ͷࢿ࢈Λ༗ޮ׆༻ ϓϩϏδϣχϯά$IFG w ຊ൪։ൃಉ͡ϨγϐͰߏཧ͢Δ ࠩҟ$IFGͷ&OWJSPONFOUTͰԿͱ͔͢Δ w
✅ࠓޙͷߋ৽͕༰қɾຊ൪ͱ։ൃͷဃΛى͜͞ͳ͍ ΞΫγϣϯͰߋ৽Ͱ͖ΔૉఢͳԿ͔Λ͏
7"4*-: *OD $IFGͷߏ w ࢠؔΛ࣋ͬͨSPMFʷFOWJSPONFOUͰදݱ
7"4*-: *OD SPMFT Ұ෦ w QBDLFSCBTFDPOpHVSFKTPO w QBDLFSBQJCBTFDPOpHVSFKTPO w QBDLFSBQJBQJDPOpHVSFKTPO
w QBDLFSBQJCBUDIDPOpHVSFKTPO w QBDLFSXFCDPOpHVSFKTPO ֤ϊʔυͷϩʔϧΛಡΈࠐΉ ͷमਖ਼ඞͣऔΓࠐΉ
7"4*-: *OD Ұྫ QBDLFSBQJCBTF DPOpHVSFKTPO QBDLFSBQJBQJ DPOpHVSFKTPO "run_list": [ "role[packer-base-configure]",
"recipe[fluentd]", ... "run_list": [ "role[packer-api-base-configure]", "recipe[nginx]" ]
7"4*-: *OD &OWJSPONFOUT w QBDLFS w WBHSBOU w TUBHJOH w
QSPEVDUJPO w 44)ͷઃఆɾ伴 w ࢹͷ༗ແ w %/4पΓͷઃఆ w ϩάίϨΫλʔͷઃఆ ཧ
7"4*-: *OD Ұྫ WBHSBOU w 伴WBHSBOUͷ JOTFDVSF@QSJWBUF@LFZ w ࢹPGG w
UEBHFOUͷDPOGίϝϯτ Ξτ͞ΕΔ w ϩʔΧϧσϓϩΠ༻ʹ DBQJTUSBOPΛγεςϜʹՃ QSPEVDUJPO w 伴ຊ൪༻ͷൿີ伴 w ࢹPO w UEBHFOUͷDPOG͕༗ޮͳঢ় ଶͰஔ͔ΕΔ
7"4*-: *OD "84ʹαʔόΛཱͯΔ༷ࢠ $ cat /path/to/chef-repo/nodes/packer-base.json { "name": "packer-base", "chef_environment"
: "packer", "run_list": [ "role[packer-base-configure]" ] } $ packer build base.json # => ruby2.3.1ΛೖΕͨΓmackerel-agentΛೖΕͨΓ # => packer-ubuntu1604-ruby231-{{timestamp}}ͱ͍͏໊લͷAMI͕Ͱ͖Δ
7"4*-: *OD "84ʹαʔόΛཱͯΔ༷ࢠ # packerͰ࡞ͬͨ࠷৽ͷAMI-IDΛऔͬͯ͘ΔϫϯϥΠφʔ $ aws ec2 describe-images
--owners self \ | jq '.Images[]|select((select(.Name != null)|.Name|contains("packer-ubuntu")))' \ | jq 'sort_by(.CreationDate)|reverse|.[0].ImageId' --slurp -r ami-12345678 # => ͜ͷAMIͰΠϯελϯεΛཱͯΔ # => ηΩϡϦςΟάϧʔϓͳͲΛॻ͖ࠐΜͩεΫϦϓτͰΠϯελϯεੜ
7"4*-: *OD "84ʹαʔόΛཱͯΔ༷ࢠ $ cat /path/to/chef-repo/nodes/api-stg.json { "name": "api-stg", "automatic":
{ "fqdn": "api-stg" }, "chef_environment" : "staging", "run_list": [ “role[packer-api-api-configure]" ] } $ pwd /path/to/chef-repo $ knife zero bootstrap <ΠϯελϯεͷIP> --sudo -N api-stg --no-converge $ knife zero converge ‘name:api-stg’ --sudo
7"4*-: *OD ϩʔΧϧʹαʔόΛཱͯΔ༷ࢠ $ cat Vagrantfile config.vm.define 'api' do |api|
... api.vm.provision 'chef_zero' do |chef| chef_zero_conf(chef, run_list: 'role[packer-api-api-configure]') end ... def chef_zero_conf(chef, run_list:) ... chef.run_list = run_list chef.environment = 'vagrant' ... $ vagrant up api
7"4*-: *OD ઓུ w ✅ݱঢ়ͷࢿ࢈Λ༗ޮ׆༻ ϓϩϏδϣχϯά$IFG w ✅ຊ൪։ൃಉ͡ϨγϐͰߏཧ͢Δ ࠩҟ$IFGͷ&OWJSPONFOUTͰԿͱ͔͢Δ w
✅ࠓޙͷߋ৽͕༰қɾຊ൪ͱ։ൃͷဃΛى͜͞ͳ͍ ΞΫγϣϯͰߋ৽Ͱ͖ΔૉఢͳԿ͔Λ͏
7"4*-: *OD 1SPT w ݶΓͳ͘ຊ൪ʹ͍ۙڥͰύοέʔδͷݕূ w DIFGSFDJQFͷݕূ
7"4*-: *OD $POT w Πϝʔδͷੈཧ w MBUFTUΛ͏ͱܾΊͯ͠·͑ෆཁ
7"4*-: *OD 5JQT w QBDLFSEFCVHNPEFศརͳͷͰͲΜͲΜ͏͖ QBDLFS͕ϓϩϏδϣχϯά͍ͯ͠Δαʔό44)͢Δใ͕Β͑Δ w BQUHFUͷBVUPVQEBUFཁҙ 6CVOUVىಈ࣌ʹABQUHFUVQEBUFA͕ࣗಈͰΓɺDIFGͱͿ͔ͭΔ EJTBCMFʹ͢Δ͔TMFFQͰִؒௐ
7"4*-: *OD ·ͱΊ w QBDLFSͰෳͷ7.ΠϝʔδΛಉ࣌ʹੜ ݱࡏͷQBDLFSҠߦ͘Β͍ w DIFGͰߏཧ w ຊ൪ͱ։ൃͰಉ͡༰ͷ7.Λ͑ΔڥΛߏங
7"4*-: *OD 8FBSFIJSJOH IUUQTXXXXBOUFEMZDPNDPNQBOJFTWBTJMZJOGP PLBEBQBO