Skip to content

ChatOps bot for running Ansible one-liners through Slack

License

Notifications You must be signed in to change notification settings

lekum/ansiblebot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChatOps bot for running Ansible one-liners through Slack

Description

Docker image of a Slack bot that enables remote execution of Ansible commands inside a Slack channel

Usage

  1. Enable Bot Users in your Slack team. Create a bot, retrieve its API token and invite the bot to the channels you want to monitor
  2. Build the image or pull the official one
  3. Run a container using the image, setting the appropriate value for the environment variable SLACK_API_TOKEN

In addition, if you want any file to be used by Ansible, you may map that file inside the directory /opt/bot/ of the container. That way, you can pass an inventory, ssh private keys or ansible.cfg file, for example.

In order to launch the commands, just type !ansible in the Slack channel in which the bot has been invited, followed by the rest of the command as you would do locally:

screenshot

Important disclaimer

Using this bot exposes your host to the users of the Slack channel (it may be a good idea to create a private channel for it). In addition, the internal usage of Python's subprocess.check_output with shell=True may pose security threats. Use at your own responsibility.

About

ChatOps bot for running Ansible one-liners through Slack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages