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
4k
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.5k
88_techbookfest5_in_omotesandorb
hokkai7go
1
110
Career Keynote at LDD '18 in Muroran
hokkai7go
1
570
What has been realized to improve maintainability at "Eight".
hokkai7go
0
930
Serverless and tough access management
hokkai7go
1
1.4k
"1st try and team productivity"
hokkai7go
1
300
Technology to support Eight, Infrastructure part
hokkai7go
0
580
AWS and Serverless and Monitoring
hokkai7go
1
2.1k
Other Decks in Technology
See All in Technology
re:Invent2024 KeynoteのAmazon Q Developer考察
yusukeshimizu
1
150
re:Invent 2024のふりかえり
beli68
0
110
20250116_JAWS_Osaka
takuyay0ne
2
200
AWS Community Builderのススメ - みんなもCommunity Builderに応募しよう! -
smt7174
0
180
いま現場PMのあなたが、 経営と向き合うPMになるために 必要なこと、腹をくくること
hiro93n
9
7.6k
メールヘッダーを見てみよう
hinono
0
100
2024年活動報告会(人材育成推進WG・ビジネスサブWG) / 20250114-OIDF-J-EduWG-BizSWG
oidfj
0
230
AWS re:Invent 2024 recap in 20min / JAWSUG 千葉 2025.1.14
shimy
1
100
Azureの開発で辛いところ
re3turn
0
240
Unsafe.BitCast のすゝめ。
nenonaninu
0
200
データ基盤におけるIaCの重要性とその運用
mtpooh
4
500
駆け出しリーダーとしての第一歩〜開発チームとの新しい関わり方〜 / Beginning Journey as Team Leader
kaonavi
0
120
Featured
See All Featured
Code Review Best Practice
trishagee
65
17k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
173
51k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Optimizing for Happiness
mojombo
376
70k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Typedesign – Prime Four
hannesfritz
40
2.5k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
The Cult of Friendly URLs
andyhume
78
6.1k
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Λར༻ͯ͠ߦ͏