Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Created May 14, 2016 03:41
Show Gist options
  • Save mahemoff/5febd49128dfa5cae24243968f2289c4 to your computer and use it in GitHub Desktop.
Save mahemoff/5febd49128dfa5cae24243968f2289c4 to your computer and use it in GitHub Desktop.
ansible control script
#!/bin/bash
set -e
##############################
# CORE COMMANDS
##############################
function ap { ansible-playbook -i $inventory $* ; }
function flush_cache { ansible-playbook --flush-cache ; }
##############################
# LOAD BALANCERS COMMANDS
##############################
function load_balancers { ap load_balancers.yml ; }
function restart_load_balancers { ap load_balancers.yml --tags restart; }
# etc
# etc
##############################
# CALL IT
##############################
start_time=`date +%s`
echo `date`" Running $command on $renv"
eval ${command_func} $*
end_time=`date +%s`
duration=$(( end_time - start_time ))
echo `date`" Finished Ansible $original_args (duration: $duration secs)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment