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
jopf-seminar-chef-and-ansible
Search
Yutaro Sugai
February 23, 2015
Technology
3
3.9k
jopf-seminar-chef-and-ansible
Chef・Ansible等を用いた環境の自動構築方法
日本OSS推進フォーラム主催 第5回アプリケーション部会勉強会
http://connpass.com/event/11707/
Yutaro Sugai
February 23, 2015
Tweet
Share
More Decks by Yutaro Sugai
See All by Yutaro Sugai
devlove-kansai-sre-scrum
hokkai7go
0
10k
sre-lounge8
hokkai7go
6
6.4k
88_techbookfest5_in_omotesandorb
hokkai7go
1
100
Career Keynote at LDD '18 in Muroran
hokkai7go
1
550
What has been realized to improve maintainability at "Eight".
hokkai7go
0
910
Serverless and tough access management
hokkai7go
1
1.4k
"1st try and team productivity"
hokkai7go
1
290
Technology to support Eight, Infrastructure part
hokkai7go
0
570
AWS and Serverless and Monitoring
hokkai7go
1
2.1k
Other Decks in Technology
See All in Technology
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
170
これまでの計測・開発・デプロイ方法全部見せます! / Findy ISUCON 2024-11-14
tohutohu
3
370
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
110
iOS/Androidで同じUI体験をネ イティブで作成する際に気をつ けたい落とし穴
fumiyasac0921
1
110
AGIについてChatGPTに聞いてみた
blueb
0
130
dev 補講: プロダクトセキュリティ / Product security overview
wa6sn
1
2.3k
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
990
適材適所の技術選定 〜GraphQL・REST API・tRPC〜 / Optimal Technology Selection
kakehashi
1
170
AIチャットボット開発への生成AI活用
ryomrt
0
170
社内で最大の技術的負債のリファクタリングに取り組んだお話し
kidooonn
1
550
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
870
Shopifyアプリ開発における Shopifyの機能活用
sonatard
4
250
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Producing Creativity
orderedlist
PRO
341
39k
Embracing the Ebb and Flow
colly
84
4.5k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
KATA
mclloyd
29
14k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
120
Rails Girls Zürich Keynote
gr2m
94
13k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Transcript
ChefɾAnsibleΛ༻͍ͨڥͷ ࣗಈߏஙํ๏! ~ೖฤ~ Yutaro Sugai! 2015/2/23
͡Ίʹ ͜ͷൃදݸਓͷݟղͰ͋Γɺ ॴଐ͍ͯ͠Δʢ͍ͯͨ͠ʣ৫ͷݟղɺ Chef࣮ફೖஶऀਞͷݟղͰ͋Γ·ͤΜ ٕज़తʹؒҧ͍͕͋Ε ͘͞͠ࢦఠ͍ͯͩ͘͠͞
ࣗݾհ ɾtwitter: hokkai7go ɾGitHub: hokkai7go ɾRubyܥΧϯϑΝϨϯεͷϨϙʔτ ɾΔͼ·ฤू ɾChef࣮ફೖ ɾWebPay
ࠓͷ ChefAnsibleΛͬͨࣗಈԽʹ͍ͭͯ ͷɺσϞΛ͓ݟͤ͠·͢ɻ πʔϧɺίʔυͷʹͳΓ͕ͪͰ͕͢ ࠓࣗಈԽͷೖʹண͠·͢ɻ ࣗಈԽΛಋೖ͢Δࡍͷҙࢥܾఆʹཱͯͯ ͍͚ͨͩΕ͍Ͱ͢ɻ ओ࠵ऀ͔Βࣄલʹ͍࣭ͨʹ͑ͨΓɺ ࣗಈԽಋೖͷࡍʹߟ͑Δ͜ͱΛհ͠·͢ɻ
Chef࣮ફೖ • ධൃചதʂ • ٕज़ධ͔ࣾΒ • ݱࡏୈೋ൛ • ߽՚ࣥචਞ •
ҰͰ෯͘Χόʔ
͓ྱ • Chef࣮ફೖͷஶऀͷΈͳ͞Μ • ൃදͷػձΛ͍͍ͭͬͯͨͩͨ͘ @miyohide ࢯ • ຊOSSਪਐϑΥʔϥϜͷؔऀͷํʑ
࣭͍ͤͯͩ͘͞͞ • SIerʹ͓ۈΊͷํ • ཧ৬ͷํ • ݱͷΤϯδχΞͷํ • ChefAnsibleͳͲΛͬͨ͜ͱ͕͋Δํ
࣭͍ͤͯͩ͘͞͞ • ChefAnsibleʹڵຯ͕͋Δํ • ࣗಈԽʹڵຯ͕͋Δํ • ͳΜͱͳ͘དྷͨํ
େࣄͳ͜ͱ • ChefɾAnsibleͱ໊ʹ͋Γ·͕͢ɺ πʔϧͷಋೖ͕తͰ͋Γ·ͤΜ
େࣄͳ͜ͱ • ࣗಈԽࢸΔಓ • ࣗಈԽΛҡ࣋͢Δϓϩηε
ࣗಈԽ! ͱ
ࣗಈԽͱ https://kotobank.jp/word/ࣗಈԽ-681577ɹΑΓҾ༻ ͡Ͳ͏‐͔ʤ‐ΫϫʥʲࣗಈԽʳ ! ʦ໊ʧ(εϧ)ਓखʹΑΒͣɺػցίϯϐϡʔλʔʹΑΔॲཧ ํࣜʹม͑Δ͜ͱɻʮఔͷʕΛ࣮ݱ͢Δʯ
ࣗಈԽ ࢲୡ͕࣮ݱ͍ͨ͠ͷɺ ɾαʔόߏங ɾӡ༻ ɹͷࣗಈԽ
ࣗಈԽ ͍͖ͳΓ ɾπʔϧ ɾίʔυ ͷʹͳΔͷૣٸ͗͢Δ
తͷલʹ • ͲΜͳ৫ʁ • ͲΜͳϓϩμΫτʁ • ͩΕ͕ϓϩμΫτΛ͏ͷʁ • ϓϩμΫτ͕མͪΔͱ୭͕ࠔΔͷʁ •
མͪͨϓϩμΫτΛ୭͕͢ͷʁ • ࣗಈԽͰԿΛղܾ͢Δͷʁ • ϦϦʔεΛओಋ͢Δͷ୭ʁͲͷ৫ʁ • ϓϩδΣΫτࠓɺͲΜͳஈ֊ʁ
తͷલʹ • ͲΜͳ৫ʁ • ͲΜͳϓϩμΫτʁ • ͩΕ͕ϓϩμΫτΛ͏ͷʁ • ϓϩμΫτ͕མͪΔͱ୭͕ࠔΔͷʁ •
མͪͨϓϩμΫτΛ୭͕͢ͷʁ • ࣗಈԽͰԿΛղܾ͢Δͷʁ • ϦϦʔεΛओಋ͢Δͷ୭ʁͲͷ৫ʁ • ϓϩδΣΫτࠓɺͲΜͳஈ֊ʁ ӡ༻ʹؔΘΔਓΛ ר͖ࠐΉඞཁ
తͷલʹ • ͲΜͳ৫ʁ • ͲΜͳϓϩμΫτʁ • ͩΕ͕ϓϩμΫτΛ͏ͷʁ • ϓϩμΫτ͕མͪΔͱ୭͕ࠔΔͷʁ •
མͪͨϓϩμΫτΛ୭͕͢ͷʁ • ࣗಈԽͰԿΛղܾ͢Δͷʁ • ϦϦʔεΛओಋ͢Δͷ୭ʁͲͷ৫ʁ • ϓϩδΣΫτࠓɺͲΜͳஈ֊ʁ ϓϩμΫτͷཧղ
తͷલʹ • ͲΜͳ৫ʁ • ͲΜͳϓϩμΫτʁ • ͩΕ͕ϓϩμΫτΛ͏ͷʁ • ϓϩμΫτ͕མͪΔͱ୭͕ࠔΔͷʁ •
མͪͨϓϩμΫτΛ୭͕͢ͷʁ • ࣗಈԽͰԿΛղܾ͢Δͷʁ • ϦϦʔεΛओಋ͢Δͷ୭ʁͲͷ৫ʁ • ϓϩδΣΫτࠓɺͲΜͳஈ֊ʁ Ұ൪େࣄͳͱ͜Ζ
తͷલʹ • ͲΜͳ৫ʁ • ͲΜͳϓϩμΫτʁ • ͩΕ͕ϓϩμΫτΛ͏ͷʁ • ϓϩμΫτ͕མͪΔͱ୭͕ࠔΔͷʁ •
མͪͨϓϩμΫτΛ୭͕͢ͷʁ • ࣗಈԽͰԿΛղܾ͢Δͷʁ • ϦϦʔεΛओಋ͢Δͷ୭ʁͲͷ৫ʁ • ϓϩδΣΫτࠓɺͲΜͳஈ֊ʁ ஈ֊ʹΑΓ Δ͜ͱ͕มΘΔ
ࣗಈԽͷϝϦοτ • Πϯϑϥͷߏஙɾӡ༻ΛίʔυͰࣗಈԽ • αʔόʹࠨӈ͞Εͳ͍ • Φϖϛεͷݮ • ޮԽʢͷݮʣ •
ଐਓੑͷഉআ • खॱॻ͔Βͷଔۀ • ਖ਼͔֬ͭߴ
ࣗಈԽͷσϝϦοτ • σϝϦοτ • ࣌ؒͱख͕͔͔ؒΔ • ܧଓతʹอक͢Δ࣌ؒͱखؒ
ࣗಈԽʹσϝϦοτ ͕͋Δͱ͍͑ɺ! ख࡞ۀ+खॱॻͭ Β͍
• ਫΛҿΉ • ࣍ɺࣗಈԽͷಋೖํ๏ʹ͍ͭͯ
Ͳ͏ͬͯࣗಈԽΛ ಋೖͨ͠Β͍͍ͷʁ
ಋೖ • λΠϛϯά • ϓϩδΣΫτ͕࢝·Δͱ͖ • ։ൃڥΛߏங͢Δͱ͖ • طଘͷγεςϜʹಋೖ͢Δͱ͖ •
্هҎ֎ͷ߹(൪֎ฤ)
ಋೖ(PJ։࢝࣌) • ϓϩδΣΫτ։࢝࣌ʹࣗಈԽ͓͖͍ͯͨ͠ͷ • σϓϩΠɾCIɾߏஙࣗಈԽ • ࣮ࡍʹಈ͘ίʔυ͕ͳͯ͘Ζ͏ • ϓϩηεΛ܁Γฦ͠վળ͢Δ͜ͱ͕Ͱ͖Δ
ಋೖ(։ൃڥߏங) • ಉ͡ڥΛૉૣ͘։ൃऀʹͰ͖ΔΑ͏ʹͳΔ • όʔδϣϯͷҧ͍Ͱ·ͳ͘ͳΔ • ϝϯόʔ૿͑ͨ࣌ʹѹతʹָ • VagrantͱΈ߹ΘͤΕߏஙͷΓ͕͍͢͠͠ •
Chef, Ansibleͷೖʹ͓͢͢Ί • Chef࣮ફೖ5,6ষ͓͢͢Ί • [ؾΛ͚ͭΔ͜ͱ] όʔδϣϯཧ͠ɺܧଓతʹมߋΛՃ͑ ΒΕΔΑ͏ʹ͓ͯ͘͠
ಋೖ(։ൃڥߏங) ᶃ VM Imageऔಘ ᶄ ϦϙδτϦ͔Β ίʔυऔಘ ίʔυΛऔಘͯ͠ ܧଓతʹϓϩϏδϣχϯά
ಋೖ(طଘͷγεςϜ) • Ұ൪Ή͔͍ͣ͠ • ՔಇதͷαʔϏεʹӨڹΛ༩͍͑ͨ͢Ί • αʔόՃ͕͋ΕҰ൪ͱ͖͍ͬͭ͢
ಋೖ(൪֎ฤ) • ڥ͕มԽ͢Δͱ͖ʹಋೖ͢Δ • αʔόҠߦ • PaaS, IaaSͳͲͷҠߦ • ·ͬ͞ΒͳαʔόΛࣗಈԽͰߏங
ಋೖ(จԽ) • จԽͷಋೖ͕େࣄͰɺࠎ͕ંΕΔ͔ • ख࡞ۀΛͳ͘͠ɺࣗಈԽͰͷ࡞ۀத৺ʹ • ݽಠͳChef(ͳͲ)͍ʹͳͬͯ͠·Θͳ͍Α͏ • ·ͣಡΈॻ͖ग़དྷΔؒΛ૿͢ •
Ξϯνύλʔϯʹؾ͕͚ΔਓΛ૿͢ • ѻ͏ϛυϧΣΞOSɺίϚϯυͷཧղ͕Լͱͯ͠ඞཁʹ ͳͬͯ͘Δ • ϝϯςφϯεੑ • ಡΈॻ͖͕͍͢͠ • ӡ༻ʹϑΟοτ͢Δ͔
ࣄલʹ͍࣭ͨ(1) “࣮ࡍʹɺChefΛͬͯɺRailsΞϓϦ͕ಈ͘ڥΛߏஙͯ͠ཉ͍͠ ! ʢChefͷΠϯετʔϧ͔Β͡ΊͯɺRailsΞϓϦ͕ಈ͘·Ͱʣ”! ! →͜ͷ͋ͱσϞಈըΛ͓ݟͤ͠·͢
ࣄલʹ͍࣭ͨ(2) ”ChefͰݕࡧ͢ΔͱɺChef SoloɺChef ServerɺKnifeɺCookbookɺ ! ϨγϐɺBerkshelfͳͲɺ͞·͟·ͳ༻ޠ͕ͨ͘͞Μ͋Γ ! Α͔͘Βͳ͍ɻཧͯ͠ཉ͍͠ɻ”! ! →Chef
Solo: ελϯυΞϩϯܗࣜͷChef! →Chef Server: Chef ClientͱڞʹΫϥΠΞϯτ/αʔόܗࣜͷChef! →Ϩγϐ: Ұ൪جૅతͳߏཁૉɻίʔυͰॻ͍ͨઃఆखॱ! →Cookbook: ϨγϐʹඞཁͳσʔλϑΝΠϧΛ·ͱΊͨͷ! →Knife: खݩͷΫοΫϒοΫͱରͷαʔόΛͭͳ͙ίϚϯυϥΠϯπʔϧ
ࣄલʹ͍࣭ͨ(2) http://www.slideshare.net/yandod/devopschef-chef12 ΑΓҾ༻ Chef ServerΛͬͨߏ
ࣄલʹ͍࣭ͨ(2) http://www.slideshare.net/yandod/devopschef-chef12 ΑΓҾ༻
ࣄલʹ͍࣭ͨ(3) “RubyͷDSLΛॻ͘͜ͱͰαʔόߏஙͷࣗಈԽ͕ߦ͑Δͱͷ͜ͱ͕ͩɺ ! θϩ͔Βͯ͢Λॻ͖ى͜͢ͷେมͩ͠ɺֶशίετ͕ߴ͗͢Δ ! Α͏ʹࢥ͏ɻApacheRuby,PassengerͳͲΛΠϯετʔϧ͢ΔͨΊͷ ! ςϯϓϨʔτ͋Δͷ͔ʁ “! !
→͍͍࣭Ͱ͢Ͷʂ! →Chef supermarket( https://supermarket.chef.io/ )͕͋Γ·͢ɻ! ! ͝ར༻ܭըతʹ! ʢΉͷͰͳ͍Մೳੑɺ݁ہιʔείʔυΛಡΉӋʹͳΔ͜ͱʣ
None
Chef Supermarket • ୭͕ϝϯς͍ͯ͠Δͷʁ! • Chefࣾ! • PayPal! • HiganWorks!
• Chef׆༻ΨΠυஶऀͷᖒొ͞Μͷձࣾ! • ͳͲͳͲ(ΫοΫϒοΫ࣍ୈ)! • ͲΜͳΫοΫϒοΫ͕͋Δͷʁ! • nginx! • apache2! • rbenv! • postgresql! • mysql! • docker! • ͳͲͳͲ
ࣄલʹ͍࣭ͨ(4) “RubyͷDSLͰࣗಈԽͰ͖Δͷָͩͱࢥ͏͕ɺςετ ! ͲͷΑ͏ʹ͢Δͷ͔ɻ “! ! →͍͍࣭Ͱ͢Ͷʂ! →test-kitchen, Serverspec
Infrataster Ͱςετ͢Δͷ͕ྑͦ͞͏! →͔͠͠ɺ·ͩϕετϓϥΫςΟεͳ͍ͱೝ͍ࣝͯ͠Δ! →ࣗಈԽͷՌΛ֬ೝ͢Δͷ͕େࣄ! →ςετʹ࣌ؒΛ͍ա͗ͳ͍Α͏ʹɺ·ͣεϞʔϧελʔτͰ! ʢࣗಈԽʹɺςετʹ͕͔͔࣌ؒΔͱվળͷαΠΫϧΛճ͠ʹ͍͘ʣ
http://serverspec.org/ ΑΓ
http://infrataster.net/ ΑΓ
ࣄલʹ͍࣭ͨ(5) “్தͰࣦഊͨ͠ޙʹ࠶ɺ࣮ߦͯ͠ͳ͍͔ɻ ! ࣗ࡞ͷγΣϧεΫϦϓτͳͲͰࣗಈԽΛࢼΈΔͱɺϦϥϯॲཧͷ ! ࡞ΓࠐΈ͕େมɻ “! ! →ͳ͍ɻ! →ႈੑ(Կ࣮ߦͯ͠ಉ݁͡ՌʹͳΔੑ࣭ͷ͜ͱ)Λߟྀͯ͠ॻ͔Εͨ
ϨγϐͰ͋Εͳ͍ɻ! →ʮखॱʯͰͳ͘ʮঢ়ଶʯΛఆٛ͢ΕΑ͍(Chef࣮ફೖ §2.10 p49)! →ྫ͑…(࣍ͷεϥΠυ
ྫ͑ɺgit clone͢Δͱ͖ ॳճ͚ͩclone͍ͨ͠ͳΒɺ࣍ճҎ࣮߱ߦ͢Δඞཁ͕ͳ͍ bash_profileΛϗʔϜσΟϨΫτϦʹஔ͍͕ͨ͠ aaa ͱ͍͏༰ؚ͕·Ε͍ͯΔͳΒɺมߋΛՃ͑ͨ͘ͳ͍ http://qiita.com/hokkai7go@github/items/37895052b52105be4c51 ΑΓ
ࣄલʹ͍࣭ͨ(6) “αʔόݻ༗ͷઃఆʢϗετ໊IPΞυϨεʣͳͲΛChefͰ ! ࣮ݱ͢Δ͜ͱՄೳ͔ʁͦ͜Γख࡞ۀ͔ʁ “! ! →Մೳ͕ͩɺΫϥυڥΛ͍ͬͯͨͷͰݸਓతʹ͋·Γܦݧ͕ͳ͍! →ϗετ໊IPΞυϨεͷඥ͚Λཧ͢Δͷ͕ࡶͦ͏ʹࢥ͏
ࣄલʹ͍࣭ͨ(7) “Chefʹࣅͨπʔϧͱͯ͠PuppetansibleͳͲ͕͋ΔΑ͏͕ͩɺ ! ͦΕͧΕͷಛʁ “! ! →͍͍࣭Ͱ͢Ͷʂ
πʔϧൺֱ Chef Ansible Itamae γΣϧεΫϦϓτ อकੑ ◦ ◦ ◦ ☓
ಋೖָ͕͔ ˚ ◦ ◦ ◦ কདྷੑ ◦ ◦ ◦ ? қ ˚ ◦ ˕ ˚ ϓϥοτ ϑΥʔϜ ˕ ◦ ◦ ◦
πʔϧൺֱ • Chef • RubyͳͷͰΘ͔Γ͍͕͢ɺεΫϦϓτ͕ཚཱ͠ͳ͍ Α͏ؾΛ͚ͭΔඞཁ͕͋Δ • ͍ΖΜͳͱ͜ΖͰίʔυΛࠩ͠ࠐΊΔɺ͘·ͳ͘ಡ Ήඞཁ͕͋ΔΑ͏ʹࢥ͏ •
ઃఆରͷαʔόʹΤʔδΣϯτ(Ruby)ΛΠϯετʔ ϧ͢Δඞཁ͕͋Δ • ར༻ऀ૿͍͑ͯ͘ͱࢥ͏ • WindowsAzureʹରԠ͍ͯ͠Δ༷(Chef12͔Β)
πʔϧൺֱ • Ansible • γϯϓϧͰͱͯΑ͍ • ͔͠͠ɺyamlͰԿ͔ॻ͘ͷʹແཧ͕͋Δ ؾ͕͢Δ • ར༻ऀ૿͍͑ͯ͘ͱࢥ͏
• ΤʔδΣϯτϨε࠷ߴʂ • SSH͑͞Ͱ͖ΕΑ͍
πʔϧൺֱ • Itamae • Chef͔ΒൃΛಘͨγϯϓϧͰܰྔͳπʔϧ • ຊਓ͕։ൃɻใΛಘ͍͢ • RubyͳͷͰΘ͔Γ͍͢ •
ར༻ऀ૿͍͑ͯ͘ͱࢥ͏ • ΤʔδΣϯτϨε࠷ߴʂ
πʔϧൺֱ • γΣϧεΫϦϓτ • ॻ͘ͷϝϯςφϯεେม • Θ͔Γʹ͍͘ͷͱɺႈੑͷߟྀ͕େม • EC2ͷcloud-initͷΑ͏ʹɺॳظߏஙͰڧྗ •
γΣϧͷํݴΛߟྀ͢Δඞཁ͕͋Δ
·ͱΊ • πʔϧ͕େࣄͰͳ͍ • ࣗಈԽࢸΔಓ • ࣗಈԽΛҡ࣋͢Δϓϩηε • ͦͷ্Ͱɺࣗͨͪͷ৫ͰͲͷπʔϧΛબͿ͔ •
จԽͷಋೖ͕େม͕ͩେࣄ • ʢͳͥಋೖ͢Δͷ͔ͱ͍ͬͨʣ͚ࣾϙΤϜΛॻ͘ ͱΘΓ͍͔͢ • ࣄྫΛΓ͍ͨͷͰɺͥͻൃද͍ͯͩ͘͠͞
Q&A • ೖฤͷൃද͜ΕͰऴΘΓͰ͢ • ࣭͋Γ·͔͢ʁ
ChefɾAnsibleΛ༻͍ͨڥͷ ࣗಈߏஙํ๏! ~σϞฤ~ Yutaro Sugai! 2015/2/23
σϞ • Vagrant + Chef soloΛͬͯߏங! • vagrantͷػೳͰ͋ΔprovisionerΛར༻! • ChefͷagentΠϯετʔϧVagrant͕ࣗಈͰͬͯ͘ΕΔ!
• ΫοΫϒοΫ! • جຊతʹChef supermarketͷͷΛར༻! • nginx! • postgresql! • nodejs! • rbenv(RubyͷΠϯετʔϧཧ)! • ࣗલͰॻ͍ͨͷ্هΫοΫϒοΫͷݺͼग़͠ɺnginxͷݻ༗ઃ ఆͷΈ! • σϓϩΠrailsΞϓϦଆ͔ΒcapistranoΛར༻ͯ͠ߦ͏