Did you know that you can navigate the posts by swiping left and right?

How to install Hubot Control on Ubuntu Linux

19 Jun 2017 . category: devops . Comments
#sysadmin #devops #hubot #slack #hubot-control #linux #ubuntu #chatops #chatbot

What is Hubot and why should I want it? Hubot is an awesome chat bot open sourced by Github. It’s easily extendable using CoffeeScript, and you can run it on pretty much every popular messaging service using a variety of adapters. However, Hubot can be quite tricky configure and operate, and that’s where Hubot control comes in - it allows you to configure and manage multiple Hubot instances using a web interface.

Prepare your system We will be doing the setup on Ubuntu 16.04 where installed node and npm.


##Installing nodejs
$ sudo curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
$ sudo apt-get install -y nodejs

$ node -v
$ v8.1.2

$ npm -v
$ 5.0.3

##Updating npm
$ sudo npm install npm@latest -g

Install system dependencies


## Unzip package
$ sudo apt-get install unzip
## Ruby bundler
$ sudo apt-get install ruby-bundler

Prepare Hubot Control source Hubot Control is a plain and simple Ruby on Rails webapp, there is no native packaging available, so we will get the source code to our /opt directory:


$ cd /opt
$ sudo wget https://github.com/spajus/hubot-control/archive/master.zip

## Unzip source code
$ sudo unzip master.zip

## Change name of folder master
$ sudo mv hubot-control-master/ hubot-control/

## Required node packages
$ npm install -g coffee-script
$ npm install -g hubot
$ npm install -g yo generator-hubot

Add “hubot” user Running things as root is a very dangerous practice, so let’s set up a fresh user just for Hubot, pointing it’s home directory to /opt/hubot-control. I am using current user as hubot user


$sudo chown -R hangnt:hangnt /opt/hubot-control

Install RVM and Ruby 2.0.0 We will install RVM to get desired version of Ruby without messing up the system As current user


$ \curl -sSL https://get.rvm.io 

# Will load RVM for the first time.
$ source ~/.rvm/scripts/rvm 

# Install Ruby
$ sudo apt-get install ruby
$ ruby -v
$ ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]

configure the database You can configure Hubot Control to use any database you want. In this guide, we will be using SQLite in development mode, so it will work out of the box. However, to avoid installing PostgreSQL gem, which requires development libraries, we will remove gem ‘pg’ line from /opt/hubot-control/Gemfile, like so:


$ sed -i "/gem 'pg'/d" /opt/hubot-control/Gemfile

Install Ruby Gems To be able to start Hubot Control, you have to install the dependencies.


$ cd /opt/hubot-control
$ bundle install

You may need to edit Ruby version to 2.3.1 (the latest version that you installed) on Gemfile and install ruby 2.3.1 or bundle


$ rvm install ruby-2.3.1
$ gem install bundler

Prepare the database A final step before starting Hubot Control for the first time is to create your database. If it’s properly configured, this will succeed, and you will be good to go:


$ rake db:migrate

Run Hubot Control Now it’s time to run Hubot Control for the first time. We will do it in a straghtforward way, by running:


$ cd /opt/hubot-control
$ rails server --port=3000

Rails will boot and you will see all the output right in your console. Now point your browser to http://your-server-ip:3000/status, login with “admin@hubot-control.org / hubot”, and if you see a green heading saying “You can run Hubot” - you’re almost there. If something is missing, you will see the cause along with instructions what to do.

Hubot Control

When you will get everything running, you can start Hubot Control as a deamon using:


$ unicorn_rails -p portnumber -D

Create a Hubot To create a new Hubot, click “Add Hubot” and fill out the form.

Hubot Control

Now wait patiently for a while until you see a congratulatory screen with log output. Click “Control hubot” button to proceed with further configuration. Hubot Control

Start your bot and make awesome script Hubot Control Bug You may need to add read permisson for file ~/.config/configstore/insight-yo.json.

Enjoying!


Me

Harry Nguyen is an awesome person. Abosolutely true!.