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
5k
AWS Single Sign-Onを用いた、セキュアでより良いログイン体験への取り組み / AWS Single Sign-On for a better experience and more secure login
kotatsu360
3
4.5k
【解説】第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
地理情報データをデータベースに格納しよう~ GPUを活用した爆速データベース PG-Stromの紹介 ~
sakaik
1
100
Forget efficiency – Become more productive without the stress
ufried
0
240
元旅行会社の情シス部員が教えるおすすめなre:Inventへの行き方 / What is the most efficient way to re:Invent
naospon
2
260
Microsoft MVPになる前、なってから/Fukuoka_Tech_Women_Community_1_baba
nina01
0
170
SREの前に
nwiizo
11
2.6k
[JAWS-UG金沢支部×コンテナ支部合同企画]コンテナとは何か
furuton
3
340
AI機能の開発運用のリアルと今後のリアル
akiroom
0
240
Postmanの日本市場におけるDevRel (的) 活動 / Postman's DevRelish activities in Japan
yokawasa
1
120
福岡新卒エンジニアの会
teba_eleven
1
180
End of Barrel Files: New Modularization Techniques with Sheriff
rainerhahnekamp
0
280
What to do after `laravel new`
mattstauffer
0
140
mikroBus HAT を用いた簡易ベアメタル開発
tarotene
0
260
Featured
See All Featured
Designing for Performance
lara
604
68k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
42
2.2k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Speed Design
sergeychernyshev
24
600
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Become a Pro
speakerdeck
PRO
25
5k
Automating Front-end Workflow
addyosmani
1366
200k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Adopting Sorbet at Scale
ufuk
73
9.1k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
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