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
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
100
Zennのパフォーマンスモニタリングでやっていること
ryosukeigarashi
0
150
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
130
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
4
1.4k
AWS Lambda のトラブルシュートをしていて思うこと
kazzpapa3
2
180
FlutterアプリにおけるSLI/SLOを用いたユーザー体験の可視化と計測基盤構築
ostk0069
0
100
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
180
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
870
rootlessコンテナのすゝめ - 研究室サーバーでもできる安全なコンテナ管理
kitsuya0828
3
390
OCI Security サービス 概要
oracle4engineer
PRO
0
6.5k
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
140
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
Docker and Python
trallard
40
3.1k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
900
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Code Review Best Practice
trishagee
64
17k
Building Your Own Lightsaber
phodgson
103
6.1k
KATA
mclloyd
29
14k
Rails Girls Zürich Keynote
gr2m
94
13k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
Fireside Chat
paigeccino
34
3k
A better future with KSS
kneath
238
17k
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Λར༻ͯ͠ߦ͏