Top Banner
© Copyright 2015 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. ChatOps Les humains parlent aux robots Olivier Jacques / @ojacques2 / #devops #meetup
12

ChatOps meetup: les humains parlent aux robots

Aug 18, 2015

Download

Software

ojacques38
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ChatOps meetup: les humains parlent aux robots

© Copyright 2015 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.

ChatOps

Les humains parlent aux robots

Olivier Jacques / @ojacques2 / #devops #meetup

Page 2: ChatOps meetup: les humains parlent aux robots

© Copyright 2015 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.2

Pour vous servir…

Olivier Jacques – HP Grenoble

• Distinguished Technologist / HP IT - DevOps

@ojacques2

Page 3: ChatOps meetup: les humains parlent aux robots

© Copyright 2015 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.3

Des salles de Chat et des Bots

ChatOps

• Dev: plus d’Ops. Ops: plus de Dev.• Conversations entre robots et humains• Archives, recherches, audit• Les robots publient des événements, répondent à

des questions• Une base de connaissance commune dans

l’équipe DevOps• C’est drôle !• Nous, on aime http://flowdock.com

– Il y a aussi IRC, Hipchat, campfire, …• Un bot populaire: HUBOT -

https://hubot.github.com/

Page 4: ChatOps meetup: les humains parlent aux robots

© Copyright 2015 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.4

Page 5: ChatOps meetup: les humains parlent aux robots

© Copyright 2015 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.

Travaux Pratiques

Page 6: ChatOps meetup: les humains parlent aux robots

© Copyright 2015 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.6

Travaux pratiques

1

2

3

Créer son bot

Le connecter à IRC

Créer deux scripts: ligne de commande, webhook

Page 7: ChatOps meetup: les humains parlent aux robots

© Copyright 2015 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.7

Sur un Ubuntu 14.04 LTS

Installer Hubot

$ curl -sL https://deb.nodesource.com/setup | sudo bash -

$ sudo apt-get install nodejs build-essential libexpat1-dev libexpat1 libicu-dev

$ sudo npm install npm –g

$ npm install -g yo generator-Hubot

$ mkdir mytestbot

$ cd mytestbot

$ yo hubot

OU…

Page 8: ChatOps meetup: les humains parlent aux robots

© Copyright 2015 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.8

start.sh

#!/bin/bash#

HUBOT_HOME_DIR=/home/ubuntu/testbot/HUBOT_BIN='bin/hubot'HUBOT_LOGS_DIR=~/logs

cd ${HUBOT_HOME_DIR}mkdir -p ${HUBOT_LOGS_DIR}

if [ ! -f ./hubot.env ]; then echo "hubot.env file not found!" exit 1fi

source ./hubot.env

${HUBOT_HOME_DIR}${HUBOT_BIN} --name ${HUBOT_NAME} --adapter ${ADAPTER}

Page 9: ChatOps meetup: les humains parlent aux robots

© Copyright 2015 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.9

hubot.env

export HUBOT_LOG_LEVEL=debugexport PORT=‘8080' # http listeners for web hooksexport HUBOT='bin/hubot'export ADAPTER='irc'export HUBOT_IRC_ROOMS='#meetup-devops-gre'export HUBOT_IRC_SERVER='irc.freenode.net'export HUBOT_NAME='Nono1981' # what hubot listens to

Page 10: ChatOps meetup: les humains parlent aux robots

© Copyright 2015 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.10

cal.coffee

# Commands:# hubot calendar <month>: prints out a calendar

child_process = require 'child_process'

module.exports = (robot) -> robot.respond /calendar (.*)/i, (msg) -> month = msg.match[1] if month child_process.exec 'cal -h -m ' + month, (error, stdout, stderr) -> msg.send(stdout) msg.send(stderr)

Page 11: ChatOps meetup: les humains parlent aux robots

© Copyright 2015 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.11

+ Webhook

cal.coffee

# Commands:# hubot calendar <month>: prints out a calendar

child_process = require 'child_process'

module.exports = (robot) -> robot.respond /calendar (.*)/i, (msg) -> month = msg.match[1] if month child_process.exec 'cal -h -m ' + month, (error, stdout, stderr) -> msg.send(stdout) msg.send(stderr)

robot.router.get "/hubot/test", (req, res) -> res.end "Thanks!" robot.messageRoom "#meetup-devops-gre", "Got a request..."

Page 12: ChatOps meetup: les humains parlent aux robots

© Copyright 2015 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.

Merci

@ojacques2