Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Embracing ChatOps @ Servers.com

Embracing ChatOps @ Servers.com

#Development #Workflow #Bot #Lita

exAspArk

March 17, 2017
Tweet

More Decks by exAspArk

Other Decks in Technology

Transcript

  1. • Dedicated servers • Cloud servers • Cloud storage •

    Free global private network in Amsterdam, Dallas, Luxembourg, Moscow, Singapore, Washington, Hong Kong Servers.com
  2. Why use ChatOps • Automate manual tasks • Increase speed

    of actions • Increase visibility and transparency • Collaborate, share knowledge and learn • Use the same instrument – just your chat • Automate logging of conversations and commands • Use from mobiles
  3. How to start https://github.com/exAspArk/awesome-chatops • Choose a framework to build

    a bot. The most popular ones are: • Hubot (CoffeeScript) • Lita (Ruby) • Errbot (Python) • Find adapters for your messenger. E.g. Slack, HipChat • Install useful Hubot scripts, Lita plugins, Errbot plugins • Write custom message handlers
  4. Lita bot sample # Gemfile source 'http://rubygems.org' gem "lita" gem

    "lita-hipchat" # lita_config.rb require 'lita-hipchat' require 'handlers/exchange' Lita.register_handler(Handlers::Exchange) Lita.configure do |c| c.robot.name = 'bot' if ENV['CONSOLE'] c.robot.adapter = :shell else c.robot.adapter = :hipchat c.adapters.hipchat.jid = ENV['HIPCHAT_JID'] ... end end # handlers/exchange.rb module Handlers class Exchange < Lita::Handler route /exchange\s+(\w+)\s+to\s+(\w+)/i, :perform, command: true, help: { "exchange USD to EUR" => "Shows exchange rates" } def perform(response) from = response.matches[0][0] to = response.matches[0][1] rate = fetch_rate(from: from, to: to) response.reply("#{from} to #{to}: #{rate}") end end end
  5. Lita bot sample $ CONSOLE=true bundle exec lita start bot

    > bot help help - Lists help information for terms and command the robot will respond to. help COMMAND - Lists help information for terms or commands that begin with COMMAND. info - Replies with the current version of Lita. users find SEARCH_TERM - Find a Lita user by ID, name, or mention name. exchange USD to EUR - Shows exchange rates bot > bot exchange USD to EUR USD to EUR: 0.94144
  6. Major concerns There are some issues you have to pay

    attention to before starting to use ChatOps!
  7. Security • We use self-hosted messenger • Bot is not

    reachable from the Internet • Added authorization checks for commands
  8. Old habits die hard • Some people don’t know how

    to use bots • Create useful “help” commands with descriptions • Invite and show them how to use it by example • Some people don’t trust robots and prefer to do everything manually • Let them learn from their mistakes. Bots are more reliable in performing repetitive tasks • Colleagues will like transparency of using bots
  9. Avoid information overload • Split channels in your messenger. For

    example: staging deploys, production deploys, working with repositories, builds, troubleshooting, monitoring, etc. • Mute or leave some unimportant channels. Fight your fear of missing out
  10. Prepare to write a lot of code • Start small,

    iterate quickly, think big • Make it easy to run your bot. E.g. “make run” • Allow everyone to contribute, do code reviews • Write documentation, style guides, tests, useful utils • Prepare infrastructure: access, database, deployment, logs, monitoring, error handling, CI / CD, etc.
  11. Always have a plan B • Be ready when your

    messenger / bot is unavailable • Describe how to perform the most important actions manually