1. Find the slides here: http://tiny.cc/spark-chatops-workshop
Follow me on Twitter and/or tweet at me. @tessamero
By Tessa Mero
Revolutionize Your
Workflow With… ChatOps
Workshop!
2. SUMMARY
• Who Am I?
• What is DevOps?
• What is ChatOps?
• Chat Tools
• Bot Frameworks for ChatOps
• Case Studies
• Using Cisco Spark for ChatOps
• Run a Python Script
13. Reasons for DevOps
• 1 week of work will only take seconds
• Use of Agile and other development processes
• Demand for increased production releases
• Wide availability of virtualized and cloud infrastructure
• Increased usage of data center automation
• More focus on test automation
• DevOps being more known as the “best practice”
22. HuBot
• Written by GitHub
• Open Source
• Written in CoffeeScript on Node.js
• Many core scripts to automate basic tasks
• Huge package of scripts to add for ChatOps
• Easily deploy to heroku
https://hubot.github.com/
23. Lita
• Written in Ruby
• Free and Open Source
• Works with all Chat Services
• Many plugins to install
https://www.lita.io/
24. Errbot
• Easy to write plugins
• Built in admin/security
• Big Community
• Written in Python
https://errbot.io/
27. Example Usage of ChatOps
• Incident Resolution
• Automating Routine Tasks (Anything!)
• Multiple Team collaboration
• Onboarding new employees
• Create new Virtual Machine with command
• Notifications
• Combining all tools used into your collaboration tool
30. “We use Hipchat to allow Jr
Devs to Label PRs in Github
for Review”
- @philwinkle, designer at
SomethingDigitl
31. “We spin up new VM with
simple Bot commads”
- @snair123
32. “I wrote a Chat bot that lets us
look up customer information.
ChatOps created a tool to allow
re-assigning/re-creating Dev VM”
- @halkeye, coder at SauceLabs
33. “Over the past few days, I’ve
written a serverless based thing
that will let you merge your own
PRs from Slack”
- @edyesed, DevOps Manager at
RealSelf
34. “We get information from our
ticketing system using a Cisco
Spark bot”
- @josebogarin, Chief Innovation
Officer at Altuscr
45. Got an error? Good!
• Need to pass parameters
• -r: the target Cisco Spark room identifier
• -m: the text to be posted to Cisco Spark
• -t: the access token used when invoking the Cisco Spark
REST API
• To Fix Error, type command:
49. Debug chatops.py
• Runs the currently selected file in VS Code’s editor
• Does not halt execution at first line of code
• Passes in r and m paramters and sets the
SPARK_ACCESS_TOKEN
• Environment variable value on line 17 and 25
• Select line 30 and create a breakpoint
• Hit F5 to run the debugger!!!
Welcome!
What I did this week.
Solution Partner Program at Cisco Innovation Center in Rio de Janeiro
Attempted to translate slides in Portugeuse but ended up doing a bad job and changed it back.
I will introduce myself first and tell you a little bit about me.
* What is a Developer Evangelist or Developer Advocate?
Consulting in development tools. Not a lawyer. Advocate in English means to go out and tell others about your company or tools and teach others. We demo code and help developers improve their work flow by showing them the Dev tools we have.
* I do not sell anything. I only teach and help developers.
What is Cisco DevNet? Founded 3 years ago. Developer Community 450,000+ devs using our APIs.
Over 200 APIs. Cisco is now a software applications company.
I work specifically on the Cisco Spark team
What is Cisco Spark? Chat/Calls/Video/ Chat bots which us to discussing ChatOps
I taught college before I got a job at Cisco. I was teaching web development including frontend and backend web.
During this time I took on a volunteer role to mentor students and people who are new to the web development field.
I assist others with resumes, cover letters, job interview processes, and job searches. I have helped countless people find jobs and get hired.
Board of Director member of Joomla
Production Leadership Team member
Organizer of Meetup for Joomla
Meetup and Conference for PHP in my city
Meetup and Conference for APIs in my city
My city is one of the major tech cities in the USA, Seattle, WA.
How many of you are familiar with the term DevOps?
To understand where ChatOps got its name, let’s first go over what DevOps is.
DevOps helps remove barriers between teams making coding more effective.
It advocates automation and monitoring from integration, testing, releasing to deployment as well as infrastructure management.
It allows more dependable releases in close alignment with business objectives.
DevOps is the process of getting multiple teams who are involved in the software process to talk to each other.
This is why GitHub is so valuable to development teams. It allows people to collaborate and work together.
DevOps is...
A Software engineering practice that aims at unifying software development (Dev)
and software operation (Ops). Which is how DevOps got its name.
This is the DevOps adoption in the last few years. Which means this is how many percentage of companies are using DevOps.
Maybe this year will be 95%?
* There are many reasons to using DevOps. One week of work will take only seconds of time.
* DevOps uses a better development process.
You will have faster production releases
It is more availability especially in cloud infrastructures
More used in data center automation
More automated testing
DevOps is becoming known as the BEST PRACTICE
For the past year, developers have been calling it “The Year of the ChatBots”
So, what is ChatOps?
The term “ChatOps” was created by Github back in 2013 by Jesse Newland.
The easiest way to understand chatops is as a marriage between established devops practices and workplace instant messaging platforms.
This combination increases DevOps flows enhancing communication and transparency and combining all the tools into one tool that you use.
With Chatbots, you can set different rooms to have notifications from different tools/APIs that you use.
ChatOps allow a developer to do all their work in a collaboration tool
With ChatOps, you can control the whole DevOps process using a chat tool and using chat commands.
For example /git commands or create your own commands that connect to other APIs
To begin with ChatOps, you first need to choose your Chat Tool.
Select a communication channel. There are dozens of options and these are some common tools.
Each tool has it’s own app store, or plugin store where you can install add-ons and extend your platform. There is even premade chat bots you can install.
Of course I’d recommend Cisco Spark!
There are several premade ChatOps bot frameworks out there that are preinstalled and easily configured with all the basic DevOps tools. Here are the 3 most popular ones.
You have Chef, Puppet, and Ansible for Infrastructure Automation
Jenkins for Continuous Integration (CI) and Continuous Delivery (CD)
Docker for deploying application inside a software container
And git for code revisioning.
You can connect your chatbot to anything!
GitHub, Pagerduty, Asana, Trello, Heroku, CircleCI
Infrastructure automation, configuration management, deployment automation, infrastructure monitoring and log management
Cisco even made their own verson of ChatOps for DevOps. One of the most popular ones is a Help Desk bot.
The Cisco Spark Help Desk Bot is intended to give IT Teams an active, real-time look into their own network. Help Desk Bot is able to provide accurate information about a user on the network.
So how do others use ChatOps? I asked on Twitter and had a few good responses.
I wrote a slack bot that lets us look up customer information. Ops created a tool to allow re-assigning/re-creating of dev vms
well, I know my graybeard is showing here, but trust me when I say that POSIX is why unix and linux won the operating systems wars
I think chatops are doing the same thing for API based work
So, let’s create a chatops bot!
Create a new app by going to developer.ciscospark.com and click on Bot.
Create your Display name that shows up in a room. Create a unique bot username. Select an Icon. Add a short description about the bot, and Save!
Start a conversation by going to web.ciscospark.com and click on the PLUS sign and type in your bot username that you created that ends with @sparkbot.io and click on “Go Chat!”
Go to developer.ciscospark.com, click on Docs, and click on Rooms on the left side where it says API Reference
Turn on Test Mode and add your bot token from the page where you created a bot.
Click on Run to create your API request
If you see the information that is displayed in JSON format on the right, then your request was a success. Copy the numerical value within the quotes for “id”.
If you are using Visual Studio Code (VS Code), you can run the python file in terminal.
If you are new to VS Code, make sure you open the whole folder of files, and not the file itself, so you can get that option to run the python file.
So you’ll need to pass in a couple parameters to make your script work.
Your Room ID. Your Bot Token. And a message to post into the Spark room.
If you’re getting an error, double check your token, your room ID, and try python3 instead of python.
For the spark_it() function, a POST request is forged and sent to Cisco Spark.
Then the Python main loop simply loads the command line arguments and passes it through this function and checks the returned HTTP status code for any errors.
Previously, we ran a code sample that passed command line variables, including the bot access token.
You can use a script to accept the access token either command line parameters or by checking the SPARK_ACCESS_TOKEN environment variable.
It’s best practice to use secret keys, such as an API token, to not be hard-coded but rather via environment variables.
On the explorer in VS Code, click on .vscode folder and change the ”PASTE YOUR BOT ACCESS TOKEN HERE” to your bot access token in line 17 and 25.
Highlights of the VSCode launch config file:
* Runs the currently selected file in VS Code's editor
* Does not halt execution at the first line of code
Automatically passes in r and m parameters and sets the SPARK_ACCESS_TOKEN
environment variable value on lines 17 to 25
You could leverage this script to send alerts from a monitoring tool, such as Nagios, to get real-time insights when issues are detected, for example, if your server is running out of space, you’ll be sent an alert to Cisco Spark.
For more information about ChatOps, this is a complete list of information and resources.
List out all the tasks and processes your team does, and figure out how you can integrate it into your chat tool.
But what if you only like to create memes and nothing else? Then you can add that with the meme Bot in your chat tool!