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
8.1k
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_
Reliability Engineering at Studist
katsuhisa91
PRO
0
250
依頼仕事の最適化 〜未完了をいかに完了にするか〜
katsuhisa91
PRO
17
9.7k
障害対応の人間的側面
katsuhisa91
PRO
3
1.1k
Inside Studist Lightning Talks
katsuhisa91
PRO
0
810
SRE NEXT で過去に紹介されたAWS 知見速習
katsuhisa91
PRO
2
850
インフラエンジニアの多様性と評価、またはキャリアへのつなげ方
katsuhisa91
PRO
0
1.1k
Job Crafting
katsuhisa91
PRO
0
3.1k
Self-Serviceとサイロ化と組織構造
katsuhisa91
PRO
0
1.1k
チームで取り組む障害対応
katsuhisa91
PRO
6
2.5k
Other Decks in Technology
See All in Technology
コンテナサプライチェーンセキュリティ
kyohmizu
1
130
RemoveだらけのPHPUnit 12に備えよう
cocoeyes02
0
180
次世代KYC活動報告 / 20250219-BizDay17-KYC-nextgen
oidfj
0
460
あなたが人生で成功するための5つの普遍的法則 #jawsug #jawsdays2025 / 20250301 HEROZ
yoshidashingo
1
130
【内製開発Summit 2025】イオンスマートテクノロジーの内製化組織の作り方/In-house-development-summit-AST
aeonpeople
2
520
Potential EM 制度を始めた理由、そして2年後にやめた理由 - EMConf JP 2025
hoyo
2
1.8k
ディスプレイ広告(Yahoo!広告・LINE広告)におけるバックエンド開発
lycorptech_jp
PRO
0
240
「正しく」失敗できる チームの作り方 〜リアルな事例から紐解く失敗を恐れない組織とは〜 / A team that can fail correctly
i35_267
2
720
EMConf JP 2025 懇親会LT / EMConf JP 2025 social gathering
sugamasao
2
180
エンジニアリング価値を黒字化する バリューベース戦略を用いた 技術戦略策定の道のり
kzkmaeda
6
1.9k
ビジネスモデリング道場 目的と背景
masuda220
PRO
9
700
スキルだけでは満たせない、 “組織全体に”なじむオンボーディング/Onboarding that fits “throughout the organization” and cannot be satisfied by skills alone
bitkey
0
150
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Java REST API Framework Comparison - PWX 2021
mraible
29
8.4k
Making the Leap to Tech Lead
cromwellryan
133
9.1k
The Cult of Friendly URLs
andyhume
78
6.2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
366
25k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3k
Side Projects
sachag
452
42k
How to Ace a Technical Interview
jacobian
276
23k
Done Done
chrislema
182
16k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Agile that works and the tools we love
rasmusluckow
328
21k
RailsConf 2023
tenderlove
29
1k
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 ライフを/