Utilizing the brilliant botkit framework, the nutanix_prism package written by Wade Perrigo, and the Nutanix APIs, you are now able to control your Nutanix cluster from a slack channel.
This is a work in progress and will have bugs. It currently does not function in any capacity worth running.
This is open sourced code, not a Nutanix supported product.
There is essentially no security built into the bot at this moment. It is a priority feature that will begin development soon. Currently any person that can DM the slackbot has the ability to run commands as an admin against your cluster.
I have only tested the deployment of docker-machine
from a Mac to an Ubuntu 16.04 server. If you're running Windows, please let me know how it goes.
FEATS and BUGS are maintained on Trello. Feel free to comment and make requests.
An up to date walkthrough of the capabilities of the bot are here
The @sprocket is currently being developed using Nutanix CE and Nutanix AHV. Some commands may work with ESXi or Hyper-V, but there has been no testing with those hypervisors.
- docker-machine installed on your local machine
- Nutanix CE, Nutanix AHV (ESXi planned)
- Admin access to said cluster
- Admin access to Slack Team
- Install
docker-machine
on your local machine - Clone this repository
- Create API token in Slack for your bot
- Create
.env
file - Create a docker host machine
- Build the docker image
- Deploy the docker image to your docker host
Install by following These Docs
git clone THIS REPO
1. Click on Team Name in your Slack application
2. Click Apps & Integrations
3. Search for bots
4. Click Add Configuration
5. Name your bot and Add bot integration
6. Grab API Token
7. Give your bot some love - a profile image, a name, etc
Create a file named .env
in the root of the repository.
Insert your API Token in the file like shown below:
token=xoxb-THISISMYFAKETOKEN
You need a few things to make sure everything works in the docker-machine create
command below:
- The user must have
ALL=(ALL) NOPASSWD:ALL
attritube assigned to it (Put at the bottom ofsudo visudo
) - Your public key must be available on the remote docker host to enable the automated installation of docker
ssh-copy-id user@ipaddress
On your local machine's terminal issue the following command (substitute the username you want to connect as and substitute the name of the docker host machine at the end after the ssh-port
):
docker-machine create -d generic --generic-ip-address 10.68.69.11 --generic-ssh-key $HOME/.ssh/id_rsa --generic-ssh-user sprocket --generic-ssh-port 22 sprocket
Set your new docker host as the default deployment location
eval $(docker-machine env sprocket)
Note: in the above command, sprocket
is the name you gave your docker host machine.
cd
into the repository folder from step #2.
This command will compile your docker container on the docker host.
docker build -d sprocket .
Assuming all of the above commands have completed successfully, you should now be able to deploy the docker container and the bot will connect to slack.
I have put a couple of different options for running @sprocket down below:
Option 1 - Debugging This should be used to test your bot for debugging purposes. It will output all of the debug info from the slackbot into your console.
docker run --name sprocket01 sprocket
Option 2 - Production (kinda)
This should be used in production only if you want the bot to die if there's an error. The only difference here is adding the -d
parameter, which means detach
in the docker world.
docker run -d --name sprocket01 sprocket
Option 3 - Production The command below is targeted for production use. It will restart the Docker container if there is an error and it will also restart the container if the host spontaneously reboots.
docker run -d --restart always --name sprocket01 sprocket