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
700
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
780
Apache Mesos with Amazon EC2 SpotFleet
kotatsu360
4
1.6k
Other Decks in Technology
See All in Technology
社外コミュニティで学び社内に活かす共に学ぶプロジェクトの実践/backlogworld2024
nishiuma
0
270
alecthomas/kong はいいぞ / kamakura.go#7
fujiwara3
1
300
事業貢献を考えるための技術改善の目標設計と改善実績 / Targeted design of technical improvements to consider business contribution and improvement performance
oomatomo
0
100
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
330
GitHub Copilot のテクニック集/GitHub Copilot Techniques
rayuron
37
15k
C++26 エラー性動作
faithandbrave
2
780
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
360
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
170
Snykで始めるセキュリティ担当者とSREと開発者が楽になる脆弱性対応 / Getting started with Snyk Vulnerability Response
yamaguchitk333
2
190
OpenAIの蒸留機能(Model Distillation)を使用して運用中のLLMのコストを削減する取り組み
pharma_x_tech
4
570
.NET 9 のパフォーマンス改善
nenonaninu
0
1k
NilAway による静的解析で「10 億ドル」を節約する #kyotogo / Kyoto Go 56th
ytaka23
3
380
Featured
See All Featured
Adopting Sorbet at Scale
ufuk
73
9.1k
4 Signs Your Business is Dying
shpigford
181
21k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
Thoughts on Productivity
jonyablonski
67
4.4k
Visualization
eitanlees
146
15k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Become a Pro
speakerdeck
PRO
26
5k
Faster Mobile Websites
deanohume
305
30k
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