Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ansible + hubot + slack integration
settings = {
'test': {
'path': '/home/shirou/ansible/test/',
'inventory': 'inventory'
module.exports = (robot) ->
robot.respond /ansible (.*) (.*)$/i, (msg) ->
target="test" # should be comes from channel
playbook = msg.match[1]
limit = msg.match[2]
@exec = require('child_process').exec
msg.send "doing: #{target} #{playbook} to #{limit}"
cwd = settings[target]['path']
invfile = settings[target]['inventory']
command = "/usr/local/bin/ansible-playbook -i #{invfile} #{playbook} -l #{limit}"
@exec command, {cwd: cwd}, (error, stdout, stderr) ->
msg.send stdout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment