Skip to content

TinajaLabs/ansible-role-rocket.chat-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Rocket.Chat with Hubot

A simple Ansible role to install Rocket.Chat with a bot, Hubot, on a Raspberry Pi. Yep, a chat-bot system running in your home.

Rocket.Chat

Rocket.Chat is an open source chat system similar to Slack or Hipchat. It can be installed on a Raspberry Pi in your own home network and give you access to a chat system available to family and friends.

Hubot

Hubot is from the folks at GitHub - Hubot The Hubot software can be used to code a bot (software robot). The bot, acting as a user within the chat system, can be programmed to act on your behalf to activate and respond to smart devices in your home.

Basic Installation

This Ansible playbook/role uses snapd to install Rocket.chat and uses a standard set of other commands to install and configure Hubot.

In my system, I've named my bot, Iris, so any references to that is just my preference.

Requirements

Designed and tested with:

  • Raspberry Pi 3 Model B V1.2 running minimal version of Raspbian Stretch.
  • git needs to be installed on the target Raspberry Pi ??

Role Variables

# defaults file for tinajalabs.chatbot

nodejs_version: "8.x"  # or, 10.x

hubot_rocketchat_version: "1.0.12"

bot_name: "bot"
bot_owner: "{{ bot_name }} {{ bot_name }}@{{ domain.com }}"
bot_dir: "/opt/{{ bot_name }}"
bot_desc: "Go ask Iris, when she's ten feet tall "

Dependencies

  • Git on the target machine - It seems that the Rocket.Chat Adapter requires git. I have another ansible playbook that loads a baseline setup for all my Reapberry Pis and it installs git.

Example Playbook

Create playbook, for example, tinaja-chat.yml with this content:

---

  - hosts: tinaja-chat
    become: yes


    #-----------------------------------------------------------
    vars:
      nodejs_version: "8.x" 

      hubot_rocketchat_version: 1.0.12

      bot_name: "iris"
      bot_owner: "iris [email protected]"
      bot_desc: "A bot that represents your home"


    #-----------------------------------------------------------
    roles:

    - {role: tinajalabs.tinaja}

Basic Steps

  • Install Ansible - will assume this is already done...

  • Download the latest version of the Raspbian image from: https://downloads.raspberrypi.org/raspbian_lite_latest

  • Burn the image on a MicroSD card (8G or more) using etcher

  • Add a magic empty file named SSH onto the boot partition (configures default SSH service)

  • Plug in the MicroSD image into the Raspi and boot up.

  • After bootup, copy your public key to the raspberrypi using user:pi, password:raspberry: $ ssh-copy-id -f -i ~/.ssh/id_rsa.pub [email protected]

  • Create a host inventory file with a reference like this: tinaja-chat ansible_host=<raspi ipaddress> ansible_user=pi

  • Run your playbook: $ ansible-playbook tinaja-chat.yml -i hosts/hosts.ini -u pi -b -c ssh

Run these tests after rebooting the Raspberry Pi:

Wait about 2 - 3 minutes for Rocket.Chat and Hubot to connect to each other. It takes a long time and hubot needs Rocket.Chat to be running to make the connection.

  • Find rocket.chat web UI at: http://raspiIp:3000

At first launch:

  • set up an Admin User - follow instructions
  • set up Organization
  • add a User with Role of bot (with the same name as bot_name)

Test that the bot is active by asking for help: iris help

To log into your raspi at a terminal command line: $ ssh [email protected]

Find the hubot software and server at /opt/<bot_name> $ cd /opt/iris

Launch the command line bot: $ bin/hubot

At the iris prompt, type iris help to see the list of default commands. iris> iris help

To see the status of the Hubot service: $ systemctl status hubot.service

To see the status of Rocket.Chat: $ systemctl status snap.rocketchat-server.rocketchat-server.service

Hubot Scripts

Look at the directory, /opt/iris/scripts and see sample coffee scripts. Modify and extend these for your own bot commands.

References

ToDo:

  • find a way to automate the initialization of the admin user, the organization info, and the bot user.
  • At boot up time, Rocket.Chat starts, Hubot starts, but the hubot service needs to be restarted after Rocket.Chat has finished launching.
  • research why it takes rocket.chat so long to start

License

MIT

Author Information

Chris Jefferies - [email protected]

About

Ansible Role: Rocket.Chat and Hubot on Raspberry Pi

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published