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
Ansible とStackStorm でつくる ChatOps 環境
Search
katsuhisa_
PRO
April 26, 2018
Technology
1
7.7k
Ansible とStackStorm でつくる ChatOps 環境
Ansible Night in Tokyo 2018.04 (
https://ansible-users.connpass.com/event/84907/
) で話した資料です。
katsuhisa_
PRO
April 26, 2018
Tweet
Share
More Decks by katsuhisa_
See All by katsuhisa_
Inside Studist Lightning Talks
katsuhisa91
PRO
0
620
SRE NEXT で過去に紹介されたAWS 知見速習
katsuhisa91
PRO
1
690
インフラエンジニアの多様性と評価、またはキャリアへのつなげ方
katsuhisa91
PRO
0
930
Job Crafting
katsuhisa91
PRO
0
2.7k
Self-Serviceとサイロ化と組織構造
katsuhisa91
PRO
0
870
チームで取り組む障害対応
katsuhisa91
PRO
4
2.1k
スタディスト開発部が面接で大切にしている 3つのこと
katsuhisa91
PRO
2
2.1k
プロダクト開発における暗黙知との向き合い方
katsuhisa91
PRO
6
2.7k
NoOpsを実現するSREの存在意義と役割
katsuhisa91
PRO
23
21k
Other Decks in Technology
See All in Technology
Google Cloud の AI を支える裏側のインフラを垣間見る!
maroon1st
0
330
「スニダン」開発組織の構造に込めた意図 ~組織作りはパッションや政治ではない!~
rinchsan
3
520
KubeConにproposalを送りたい人へのアドバイス
sat
PRO
3
220
On Your Data を超えていく!
hirotomotaguchi
2
650
ChatGPT for IT Service Management (IT Pro)
dahatake
7
1.5k
オーナーシップを持つ領域を明確にする
konifar
13
3.1k
ここが嬉しいABAC ここが辛いよABAC #再解説+補足編
masahirokawahara
1
270
Compose Compiler Metricsを使った実践的なコードレビュー
tomorrowkey
1
210
〜小さく始めて大きく育てる〜データ分析基盤の開発から活用まで
kniino
0
2.1k
自己改善からチームを動かす! 「セルフエンジニアリングマネージャー」のすゝめ
shoota
5
180
エンジニアのキャリアをちょっと楽しくする3本の軸/Three Pillars to Make an Engineer's Career More Enjoyable
kwappa
0
2.6k
どうするコスト最適化のトレードオフ
tetsuyaooooo
1
480
Featured
See All Featured
Web Components: a chance to create the future
zenorocha
305
41k
Stop Working from a Prison Cell
hatefulcrawdad
266
19k
Automating Front-end Workflow
addyosmani
1356
200k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
34
8.9k
A better future with KSS
kneath
231
16k
From Idea to $5000 a Month in 5 Months
shpigford
377
45k
For a Future-Friendly Web
brad_frost
172
9k
The Illustrated Children's Guide to Kubernetes
chrisshort
31
46k
Learning to Love Humans: Emotional Interface Design
aarron
267
39k
StorybookのUI Testing Handbookを読んだ
zakiyama
13
4.6k
In The Pink: A Labor of Love
frogandcode
138
21k
Building Applications with DynamoDB
mza
88
5.6k
Transcript
Ansible とStackStorm でつくる ChatOps 環境 Ansible Night in Tokyo 2018.04
株式会社スタディスト 北野 勝久
すきなAnsible モジュール lineinfile : @katsuhisa__
突然ですが、 こんなことありませんか?
監視ツール 「<ALERT> SERVER001 !!」 ぼく 「アラートきた」 Aさん 「なんだなんだ」 ある日のSlack でのコミュニケーション
ぼく 「なんだこのアラートか」 Aさん 「なんだこのアラートか」 ぼく 「対応やっときますね」 Aさん 「よろしく」 ある日のSlack でのコミュニケーション
ぼく がちゃがちゃ(対応作業) ぼく 「こんな感じでした〜」(実行結果共有) --- 数分後 --- 監視ツール 「【Resolved】<ALERT> SERVER001
!!」 ぼく 「おつかれさまでした〜」 Aさん 「おつかれ〜」 ある日のSlack でのコミュニケーション
すぐに状況確認して、すぐに実行結果を共有したい ➔実行結果を共有するために ➔Slack と作業環境を行き来するの面倒 なんなら初動対応と結果共有すべて自動化したい ※うちのSRE チームの名誉のために書いておくと、 ※こういう類のものは、現時点でも自動復旧できるようになっている箇所も多いです
それ、StackStorm でできます
StackStorm? Event-Driven Automation StackStorm is a powerful open-source automation platform
that wires together all of your apps, services and workflows. It’s extendable, flexible, and built with love for DevOps and ChatOps
StackStorm? Event-Driven Automation StackStorm is a powerful open-source automation platform
that wires together all of your apps, services and workflows. It’s extendable, flexible, and built with love for DevOps and ChatOps ➔ IFTTT for Ops
IFTTT ? めっちゃかんたん。 「もし、this なら、that する。」以上。
IFTTT for Ops ? 例えば、こんな感じの世界になる IF THIS : もし、◦◦のアラートがきたら、 THEN
THAT : Nginx を再起動して、PagerDuty にポスト
自動化できて幸せ
人の欲望には限りがない
そこまでできるんだったら・・・ アドホックなコマンド以外も実行したくなる Ansible に実装されているあれこれが使いたいとか なんならそもそもPlaybook を実行したいとか
それ、StackStorm でできます
検証してみた https://github.com/StackStorm/showcase-ansible-chatops
Ansible の 実行結果が表示
--- name: chatops.ansible_server_status action_ref: st2_chatops_aliases.server_status description: Show status for hosts
(ansible ping module) formats: - display: "status <hosts>" representation: - "status {{ hosts }}" - "ping {{ hosts }}" result: format: | Here is your status for `{{ execution.parameters.hosts }}` host(s): {~} ```{{ execution.result.stdout }}``` extra: slack: color: "{% if execution.result.succeeded %}good{% else %}danger{% endif %}" fields: - title: Alive value: "{{ execution.result.stdout|regex_replace('(?!SUCCESS).', '')|wordcount }}" short: true - title: Dead value: "{{ execution.result.stdout|regex_replace('(?!UNREACHABLE).', '')|wordcount }}" short: true footer: "{{ execution.id }}" footer_icon: "https://stackstorm.com/wp/wp-content/uploads/2015/01/favicon.png" aliases/server_status.yaml エイリアス定義
--- name: http_status_codes description: Show sorted http status codes from
nginx logs runner_type: local-shell-cmd entry_point: "" enabled: true parameters: sudo: immutable: true default: true kwarg_op: immutable: true cmd: description: "Command to run" type: string immutable: true default: "/opt/stackstorm/virtualenvs/ansible/bin/ansible {{hosts|replace('http://','')}} --become -m shell -a \"awk '{print \\$9}' /var/log/nginx/access.log |sort |uniq -c |sort -k1,1nr 2>/dev/null|column -t\"" hosts: description: "Ansible hosts" type: string required: true actions/http_status_codes.yaml 実行の内容
--- name: http_status_codes description: Show sorted http status codes from
nginx logs runner_type: local-shell-cmd entry_point: "" enabled: true parameters: sudo: immutable: true default: true kwarg_op: immutable: true cmd: description: "Command to run" type: string immutable: true default: "/opt/stackstorm/virtualenvs/ansible/bin/ansible {{hosts|replace('http://','')}} --become -m shell -a \"awk '{print \\$9}' /var/log/nginx/access.log |sort |uniq -c |sort -k1,1nr 2>/dev/null|column -t\"" hosts: description: "Ansible hosts" type: string required: true actions/http_status_codes.yaml 実行の内容 "/opt/stackstorm/virtualenvs/ansible/bin/ansible {{hosts|replace('http://','')}} --become -m shell -a \ "awk '{print \\$9}' /var/log/nginx/access.log |sort |uniq -c |sort -k1,1nr 2>/dev/null|column -t\""
\Ansible でたのしいChatOps ライフを/