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
Microsoft MVPになる前、なってから/Fukuoka_Tech_Women_Community_1_baba
nina01
0
170
LINEヤフー株式会社における音声言語情報処理AI研究開発@SP/SLP研究会 2024.10.22
lycorptech_jp
PRO
2
280
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
110
What to do after `laravel new`
mattstauffer
0
140
Mini Tokyo 3D × PLATEAU - 公共交通デジタルツインにリアルな風景を
nagix
1
230
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
28
12k
ジョブマッチングサービスにおける相互推薦システムの応用事例と課題
hakubishin3
3
620
dev 補講: プロダクトセキュリティ / Product security overview
wa6sn
0
1.6k
Postmanの日本市場におけるDevRel (的) 活動 / Postman's DevRelish activities in Japan
yokawasa
1
120
第23回Ques_タイミーにおけるQAチームの在り方 / QA Team in Timee
takeyaqa
0
190
これまでの計測・開発・デプロイ方法全部見せます! / Findy ISUCON 2024-11-14
tohutohu
3
250
隣接領域をBeyondするFinatextのエンジニア組織設計 / beyond-engineering-areas
stajima
1
230
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
427
64k
Code Reviewing Like a Champion
maltzj
520
39k
Code Review Best Practice
trishagee
64
17k
It's Worth the Effort
3n
183
27k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Thoughts on Productivity
jonyablonski
67
4.3k
The Cost Of JavaScript in 2023
addyosmani
45
6.7k
Teambox: Starting and Learning
jrom
133
8.8k
Unsuck your backbone
ammeep
668
57k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
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