Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Opening - Itamae Meetup#1
Ryota Arai
December 09, 2015
Programming
2
2.6k
Opening - Itamae Meetup#1
http://itamae.connpass.com/event/22857/
Ryota Arai
December 09, 2015
Tweet
Share
More Decks by Ryota Arai
See All by Ryota Arai
Spot Instances in Cookpad #CookpadTechConf 2017
ryotarai
7
8.1k
Itamae - Infra as Code 現状確認会
ryotarai
56
19k
Introducing Infrataster
ryotarai
9
11k
Infrataster - Infra Behavior Testing Framework #oedo04
ryotarai
17
5.5k
グリーにおけるChef導入事例 ~既存の資産を活かし新しい技術を導入する~
ryotarai
27
6.5k
Other Decks in Programming
See All in Programming
シェーダー氷山発掘記
logilabo
0
150
Value and Record Types
hschwentner
0
550
ゴーファーくんと辿るプログラミング言語の歴史/history-of-programming-languages-with-gopher
iwasiman
0
100
エンジニアによる事業指標計測のススメ
doyaaaaaken
1
190
Running Laravel/PHP on AWS (AWS Builders Day Taiwan 2022)
dwchiang
0
150
io22 extended What's new in app performance
veronikapj
0
340
Power Automateドリブンのチームマネジメント
hanaseleb
0
190
Angular‘s Future without NgModules: Architectures with Standalone Components @enterJS
manfredsteyer
PRO
0
240
What's new in Android development tools まとめ
mkeeda
0
380
インターン生・新卒向け、学校でもっと教えてほしいITエンジニア基本スキル
nearme_tech
0
130
Chart実装が楽になりました。
keisukeyamagishi
0
120
開発速度を5倍早くするVSCodeの拡張機能を作った
purp1eeeee
2
160
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
316
22k
What's new in Ruby 2.0
geeforr
336
30k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
100
5.9k
The Art of Programming - Codeland 2020
erikaheidi
32
11k
Pencils Down: Stop Designing & Start Developing
hursman
112
9.8k
Scaling GitHub
holman
451
140k
Infographics Made Easy
chrislema
233
17k
Side Projects
sachag
450
37k
GitHub's CSS Performance
jonrohan
1020
420k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
349
27k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
212
20k
How to Ace a Technical Interview
jacobian
265
21k
Transcript
Itamae Meetup #1 Ryota Arai
ߥҪ ྑଠ • ΫοΫύουͷΤϯδχΞ • Πϯϑϥ෦ॴଐ DevدΓͷOps • ItamaeInfratasterͷ࡞ऀ •
@ryotarai (GitHub), @ryot_a_rai (Twi>er)
Itamae • CFEngine • Puppet • Chef • Ansible •
Itamae
Itamae • Chefʹ͔ͭΕͨਓͷͨΊͷߏཧπʔϧ • ChefʹࣅͨRuby DSL • Chefʹൺγϯϓϧ • SSHܦ༝Ͱͷ࣮ߦΛαϙʔτ
• ࣮ߦରʹItamaeΛΠϯετʔϧ͠ͳ͍Ͱ࣮ߦͰ͖Δ
Chef vs Itamae • ֶ͍शίετ • ֮͑Δࣄฑ͕গͳ͍ • খͯ͘͞ϋϚΓͲ͜Ζ͕গͳ͍ •
͍͟ͱͳͬͨΒίʔυΛ͙͢ಡΊΔେ͖͞ • ChefDKͱ͔ͭΒ͍
Chef • Recipes • Cookbooks • Roles • Environments •
Berkshelf
Itamae • Recipes • Cookbooks -> Recipe • Roles ->
Recipe • Environments -> Recipe • Berkshelf -> Gem, Bundler
Itamae # recipe.rb package "nginx" service "nginx" template "/etc/nginx/nginx.conf" do
notifies :restart, "service[nginx]" end $ itamae local recipe.rb $ itamae ssh -h your-server recipe.rb
Itamaeͷݱঢ় • 513 stars • 802 commits • 38 plugin
gems • 35 contributors • ?? users
ͱ͜ΖͰ
Α͍͘ΘΕΔ͜ͱ ʮItamaeͷϩΰͳ͍ΜͰ͔͢ʙʯ
None
·ͱͳͭͰ͖·ͨ͠
None
ࣗ͝༝ʹ͓͍͍ͩ͘͞ github.com/itamae-kitchen/itamae-logos
ؓٳ
࣮ݧతػೳͷհ
Itamaeͷ࣮ݧతػೳ • ࣮ݧతػೳ: ͻΐͬͱͨ͠Βফ͑ͨΓ༷͕มΘͬͨΓ͢Δ͔ • --recipe-graphΦϓγϣϯ • --profileΦϓγϣϯ • Handler
--recipe-graphΦϓγϣϯ
--recipe-graphΦϓγϣϯ • ϨγϐͷґଘؔΛdotܗࣜͰग़ྗͰ͖Δ • include_recipeͨ͠Ϩγϐ • Ϩγϐ܊͕େ͖͘ͳͬͯ͘Δͱศར͔͠Εͳ͍
None
--recipe-graphΦϓγϣϯ Itamae v1.9.0Ҏ߱ʢv1.9.0Ҏલ--dotΦϓγϣϯʣ $ itamae local --recipe-graph /path/to/itamae-graph.dot recipe.rb $
dot -Tpng -o /path/to/itamae-graph.{png,dot}
--profileΦϓγϣϯ
--profileΦϓγϣϯ • ࣮ߦͨ͠ίϚϯυ͝ͱʹ͔͔͕ͬͨ࣌ؒऔಘͰ͖Δ • ݫີʹSpecinfraͷrun_commandʹ͔͔ͬͨ࣌ؒ • JSONͰग़ྗ͞ΕΔ • ϘτϧωοΫͷௐࠪʹ༗ޮ͔͠Εͳ͍
--profileΦϓγϣϯ $ itamae local --profile /path/to/profile.json recipe.rb $ cat /path/to/profile.json
| jq . | head [ { "command": "mkdir -p /tmp/itamae_tmp", "duration": 0.0037856101989746094 }, { "command": "chmod 777 /tmp/itamae_tmp", "duration": 0.0025980472564697266 }, {
--profileΦϓγϣϯ
Handler
Handler • ࣮ߦ࣌ͷΠϕϯτΛड͚औͬͯҙͷॲཧΛߦ͏ • action_started, attribute_updatedͳͲ • ChefͷHandlerʹࣅ͍ͯΔ • ಠࣗͷHandlerॻ͚Δ
• ࣮ݧతػೳͱ͍͏Ґஔ͚ͮɻͻΐͬͱ͢Δͱ༷͕มߋ͞ΕΔ ͔
$ cat config.yml handlers: - type: json path: /path/to/itamae-log.json $
itamae local -c config.yml recipe.rb $ cat /tmp/itamae-log.json | head {"time":"2015-12-08T15:47:55+09:00","event":"recipe_started", "payload":{"path":"/Users/ryota-arai/src/github.com/ryotarai/itamae/tmp/recipe.rb"}} {"time":"2015-12-08T15:47:55+09:00","event":"resource_started", "payload":{"resource_type":"execute","resource_name":"echo included"}} {"time":"2015-12-08T15:47:55+09:00","event":"action_started", "payload":{"action":"run"}} {"time":"2015-12-08T15:47:55+09:00","event":"attribute_changed", "payload":{"from":{"executed":false}, "to":{"action":"run","command":"echo included","executed":true}}}
Handler • debug handler • ϩάग़ྗ • json handler •
JSON per lineͰϑΝΠϧग़ྗ • fluentd handler • fluent-loggerͰFluentdʹग़ྗ
Handler Gem • lib/itamae/handler/<handler type>.rb͕ࣗಈతʹ require͞ΕΔ • itamae-handler-<type> gemΛͭͬͯ͘Gemfileʹॻ͍͓ͯ ͚ͩ͘ͰOK
Handler Gem # lib/itamae/handler/mail.rb module Itamae module Handler class Mail
< Base def event(type, payload = {}) super send_mail(subject: type.to_s, body: payload.inspect) end end end end
Handler Gem • ৄ͘͠ h$ps:/ /github.com/itamae-kitchen/itamae/tree/ master/lib/itamae/handler Λ
CookpadͱItamae
CookpadͰͷϫʔΫϑϩʔ • Jenkins͕Git্ͷϨγϐΛtar.gzʹ͔ͨΊͯS3ʹΞοϓϩʔυ • ֤ϗετͰS3͔Βμϯϩʔυ͠ItamaeΛ࣮ߦ͢Δckpd- itamaeίϚϯυΛ༻ҙ͍ͯ͠Δ • itamae sshւΛ͑Δͱॏ͍ͷͰϩʔΧϧ࣮ߦΛ͍ͬͯ Δ
• omnibus-itamaeͷdebύοέʔδΛར༻͍ͯ͠Δ
omnibus-itamae • Chef͕ࣾ։ൃ͍ͯ͠ΔOmnibusͱ͍͏ύοέʔδϯάπʔϧΛ ͬͯdeb, rpmύοέʔδΛ࡞ • /opt/itamaeҎԼʹRubyຊମؚΊͯΠϯετʔϧ͞ΕΔ • fat͚ͩͲɺsystem rubyͷόʔδϣϯʹࠨӈ͞Εͳ͍
• Fluentdʹ͓͚Δtd-agentͷΑ͏ͳͷ
omnibus-itamae • ϏϧυࡁΈύοέʔδˏBintray • Ubuntu 14.04, CentOS 7༻ • खݩͰϏϧυՄೳ
$ echo 'deb https://dl.bintray.com/itamae/itamae trusty contrib' | sudo tee /etc/apt/sources.list.d/itamae.list $ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv D401AB61 $ sudo apt-get update $ sudo apt-get install itamae
՝ • ϨγϐΛมߋͨ͠ࡍʹશʹө͢ΔΘ͚Ͱͳ͍ • Ϩγϐͱϗετͷݱঢ়͕Εͯɺ͕ࠩେ͖͘ͳΔ • applyͨ͠ΒࢥΘ͵มߋͰোʹͳͬͨΓ • ಛఆͷϗετ͚ͩઃఆ͕ҟͳ͍ͬͯͯো͕ىͬͨ͜Γ •
ϦεΫ͕େ͖͘ͳΔ
Itamae Server • ݱࡏ։ൃதʢҰԠΦʔϓϯιʔεʹͳ͍ͬͯΔʣ • Itamaeͷ࣮ߦͱϩάͷӾཡ͕Ͱ͖Δαʔό • Itamae࣮ߦ෦ʢBackendʣࠩ͠ସ͑Մೳ • HandlerΛ͔ͭͬͯϩάૹ৴
• itamae-handler-itamae_server
None
ߏྫ
Itamae Server • ItamaeΛ࣮ߦ͢ΔBackendࠩ͠ସ͑Մೳ • ྫ͑ɺConsulɺSSHɺStretcherͳͲ • ඇಉظͰitamae-handler-itamae_server͕ϩάΛItamae Serverʹ ૹ৴͢Δ
Itamaeͷࠓޙ • όάϑΟοΫεɺػೳՃ • ֶशίετΛ্͛ͣεϞʔϧελʔτͰ͖ΔΑ͏ʹҡ࣋ • Itamae v2ʢ༧ఆʣ • ϦϑΝΫλɺॻ͖͠ʢಛʹResource::BaseΛࣺ͍ͯͨʣ
• ϨγϐɺϓϥάΠϯͷޙํޓੑҡ࣋ • όοΫΤϯυΛinfra_operatorҠߦ͢Δ͔
ϑΟʔυόοΫΛٻΊ͍ͯ·͢ • Twi%erͰ@ryot_a_rai • Slack: h%ps:/ /itamae-slackin.herokuapp.com/ • Issue: h%ps:/
/github.com/itamae-kitchen/itamae/issues • PR: h%ps:/ /github.com/itamae-kitchen/itamae/pulls