New repo for final 481 project - ChatOps
- Alex Enaceanu
- Erik Blomquist
Make sure that you have downloaded your private-key-file.pem before starting. Follow instructions below carefully.
-
Clone Project
git clone https://github.com/ErikBlomquist/CIT-481-BOT cd CIT-481-BOT/terraform
-
Initialize Terraform
terraform init
-
Pass Environment Variables
export TF_VAR_aws_access_key='ACCESS-KEY-GOES-HERE' export TF_VAR_aws_secret_key='SECRET-KEY-GOES-HERE' export TF_VAR_aws_region='us-west-2' export TF_VAR_aws_key_pair='test' export TF_VAR_aws_private_key_pem='~/ChatOps/test.pem' export TF_VAR_stackstorm_password="testp"
-
Terraform Plan & Apply
terraform plan terraform apply
-
SSH into your instance
ssh -i ~/path-to-your-key/test.pem ubuntu@YOUR-PUBLIC-IP
- Head over to https://api.slack.com/
- Click
Start Building
- Fill out
App Name
(I picked Fat-Lou) and then select your workspace underDevelopment Slack Workspace
and thenCreate App
. - Click
Bots
. - Click
Add a Bot User
. - Click
OAuth & Permissions
and thenInstall App to Workspace
. - Select your workspace and click
Authorize
. - Copy the
Bot User OAuth Access Token
, we'll need it later.
- Go to your Slack workspace where you want to implement the bot and click
Apps
in the bottom left corner. - In the search field, type
hubot
and click on the only showing result. - You should be re-directed to a slack wegpage. Click
Install
. - Add a Username and then click
Add Hubot Integration
. - Scroll down to
Integration Settings
and save theAPI Token
securely.
Go to your Slack workspace and type /invite @name-of-your-bot:
/invite @fat-lou
-
Once you have logged into your instance, you need to create a Stackstorm API key, once created copy it.
st2 apikey create -k
-
We need to configure Stackstorm.
sudo vi /opt/stackstorm/chatops/st2chatops.env
-
Uncomment the following variables and make sure to replace them with your own values.
export HUBOT_NAME=fat-lou export HUBOT_ALIAS='!' export ST2_API_KEY="INSERT-YOUR-API-KEY-GENERATED-IN-STEP-1" export ST2_AUTH_USERNAME="st2admin" export ST2_AUTH_PASSWORD="testp" export HUBOT_ADAPTER="slack" export HUBOT_SLACK_TOKEN="xoxb-YOUR-HUBOT_SLACK_TOKEN"
-
From your cmd, install the Ansible plugin for StackStorm.
st2 pack install ansible
-
Start/Stop/Restart service
sudo systemctl start st2chatops sudo systemctl restart st2chatops sudo st2ctl start sudo st2ctl reload sudo st2ctl reload --register-aliases
-
You should be able to see your bot online on Slack once your StackStorm service has restarted.
-
Install pack !pack install https://github.com/armab/st2_chatops_aliases
!ansible ansible-playbook /path/of/file.yaml
etc.
!ansible ansible-playbook /home/ubuntu/test.yaml
https://your-public-dns
A good practice is to destroy the resources while they are not being used to avoid charges.
terraform destroy
- t2.micro instances do not meet the minimal requirements. t2.medium instances are recommended for testing.
- StackStorm Web UI blocked, need to open ports for it.
- Invalid permissions (IAM, Roles, Policy, StackStorm)