Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Ansible とStackStorm でつくる ChatOps 環境
katsuhisa_
April 26, 2018
Technology
1
6.9k
Ansible とStackStorm でつくる ChatOps 環境
Ansible Night in Tokyo 2018.04 (
https://ansible-users.connpass.com/event/84907/
) で話した資料です。
katsuhisa_
April 26, 2018
Tweet
Share
More Decks by katsuhisa_
See All by katsuhisa_
インフラエンジニアの多様性と評価、またはキャリアへのつなげ方 / Careers as infrastructure engineers
katsuhisa91
0
650
Job Crafting
katsuhisa91
0
690
Self-Serviceとサイロ化と組織構造 / Self-Service, Siloing and Organizational Structure
katsuhisa91
0
580
チームで取り組む障害対応 / Incident response as a team
katsuhisa91
4
1.7k
スタディスト開発部が面接で大切にしている 3つのこと / 3 values in interviews at Studist
katsuhisa91
2
1.7k
プロダクト開発における暗黙知との向き合い方 / Strategies For Tacit Knowledge Transfer At Software Development
katsuhisa91
6
2.1k
NoOpsを実現するSREの存在意義と役割 / class SRE implements NoOps
katsuhisa91
23
19k
AWS サーバーレスアーキテクチャでつくる Slack ChatOps / Use Slack ChatOps to Deploy Your Code
katsuhisa91
1
1.2k
SRE Lounge主催者が見てきた各社のSRE的取り組み / SRE in Japan
katsuhisa91
2
1.3k
Other Decks in Technology
See All in Technology
5分で分かるGoogle Playの新しいサブスクリプション / Google Play new subscription 2022
syarihu
0
180
noteの品質課題に立ち上げ直後のQAチームが挑んだ軌跡
hiroki_tanaka
1
190
会社訪問アプリ「Wantedly Visit」における推薦システム開発事例
hakubishin3
2
490
JSAI 2022チュートリアル講演 AI哲学マップ / JSAI 2022 Tutorial "AI Philosophy Map"
ykiyota
0
390
サーバレスECにおける Step Functions の使い方 〜ステートマシン全部見せます!〜
miu_crescent
0
140
Scrum Fest Osaka 2022 フルリモート下でのチームビルディング
moritamasami
2
900
IoTLT88-NTKanazawa-laundry-dry
yukima0707
0
160
出張スクラムマスターとしての FEARLESS CHANGE な生き方
naitosatoshi
1
1.1k
Camp Digital 2022: tailored advice
kyliehavelock
0
130
ログ基盤をCloudWatchLogからNewRelic Logs + S3に変えたら 利便性も上がってコストも下がった話
onohiroshi1
0
150
Data in Google I/O - IO Extended GDG Seoul
kennethanceyer
0
140
アーキテクチャを明文化して開発に臨んだ話
akihiyo76
0
230
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
415
59k
Reflections from 52 weeks, 52 projects
jeffersonlam
337
17k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
29
4.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
638
52k
Put a Button on it: Removing Barriers to Going Fast.
kastner
56
2.3k
Designing on Purpose - Digital PM Summit 2013
jponch
106
5.6k
Six Lessons from altMBA
skipperchong
14
1.4k
Code Review Best Practice
trishagee
43
8.9k
GraphQLとの向き合い方2022年版
quramy
16
8.2k
How STYLIGHT went responsive
nonsquared
85
3.9k
Teambox: Starting and Learning
jrom
123
7.7k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
226
15k
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 ライフを/