PabloL007 / Maya

A bot for simple operations center automation.
Other
0 stars 2 forks source link
automation operations ssh

Maya v0.1.0

Welcome to the Maya project!

Working in the operations department of a company I've noticed how much time is spent connecting to remote machines to obtain answers for simple questions. Things that eventually make it into the alert system or a grafana dashboard after a Jira ticket is created and someone has the time to do it. But what if, as a developer, you could just automate the execution of those commands sitting in a text file on your pc using regex and your company's messaging app?

This is where Maya comes in with it's Skill Definition Language (MSDL for short). Just define the regex it should look for, the process it should follow and then start using it by sending messages.

Currently, it can only receive messages through a rest API but integration with messaging apps like hipchat will come shortly.

Maya SDL

When Maya is started for the first time it only has one skill, learning. This skill is triggered by sending it a message that matches the following pattern:

learn {{ Maya SDL }}

As you can see it's just a wrapper for something called MSDL (Maya Skill Definition Language). This language is inspired by the akka streams dsl in the sense that elements that resemble sources, flows and sinks are present, all of which are represented by method calls separated by arrows. So let's analyse the MSDL for the learn skill:

core.in(learn \\{\\{(.+)\\}\\}) -> core.learn($0)

Here we can distinguish a few different elements:

Modules

Currently, the following modules and methods are available when defining new skills:

You might be wondering why the in method for the core module is missing. This was done intentionally as it isn't an actual module method, it is just a consequence of how MSDL is parsed and can be substituted by any other string. In the future this will be replaced but for now it seems like a good way to call that imaginary method whose argument is very important.

Templating variables

In MSDL there are several variables that can be included in arguments:

Examples

Usage

Configuration

Some modules can be initialized with external configuration files, currently the ssh module is the only one. To provide a list of ssh servers to be used with Maya, place a file named ssh.json in the root of the project dir (or map it to be placed inside /opt/docker if using the container) with the servers defined like so:

[
  {
    "alias": "heartOfGold",
    "host": "192.168.1.2",
    "user": "guest"
  },
  {
    "alias": "bbbb",
    "host": "orders.bigbangburgerbar.com",
    "user": "Arthur"
  }
]

The password for these servers will have to be inputted upon initialization of the ssh module through the console.

API

As this is still a work in progress there are currently no integrations implemented for chat apps, so to interact with maya you will need a tool like postman or curl. Just send a POST request to the /api/operations endpoint with the message in the body.

Docker

This application can be run as a docker, to create the container simply use the following command:

sbt docker:publishLocal

And for executing it, this will do:

docker run -it --rm -p 8080:8080 -e "HOST=0.0.0.0" maya:0.1.0

Dependencies

Maya makes use of the following open source projects:

Contribution policy

Contributions via GitHub pull requests are gladly accepted from their original author. Along with any pull requests, please state that the contribution is your original work and that you license the work to the project under the project's open source license. Whether or not you state this explicitly, by submitting any copyrighted material via pull request, email, or other means you agree to license the material under the project's open source license and warrant that you have the legal authority to do so.