kolla-mesos-ansible script

Script for running Ansible playbooks for Mesos deployment.

Change-Id: Icf247b2fe277fca02918624d4fb6c439302120ab
Partially-Implements: blueprint vagrant
This commit is contained in:
Michal Rostecki 2016-01-05 22:01:15 +01:00
parent 5ab80223eb
commit bc9b94f158
2 changed files with 84 additions and 0 deletions

View File

@ -23,8 +23,11 @@ classifier =
packages =
kolla_mesos
data_files =
share/kolla-mesos/ansible = ansible/*
share/kolla-mesos/config = config/*
share/kolla-mesos/deployment_files = deployment_files/*
scripts =
tools/kolla-mesos-ansible
[entry_points]
console_scripts =

81
tools/kolla-mesos-ansible Executable file
View File

@ -0,0 +1,81 @@
#!/bin/bash
function find_base_dir {
local real_path=$(python -c "import os,sys;print os.path.realpath('$0')")
local dir_name="$(dirname "$real_path")"
if [[ ${dir_name} == "/usr/bin" ]]; then
BASEDIR=/usr/share/kolla-mesos
elif [[ ${dir_name} == "/usr/local/bin" ]]; then
BASEDIR=/usr/local/share/kolla-mesos
else
BASEDIR="${dir_name}/.."
fi
}
function process_cmd {
echo "$ACTION : $CMD"
$CMD
if [[ $? -ne 0 ]]; then
echo "Command failed $CMD"
exit 1
fi
}
function usage {
cat <<EOF
Usage: $0 COMMAND [options]
Options:
--inventory, -i <inventory_path> Specify path to Ansible inventory file
--help, -h Show this usage information
Commands:
deploy Deploy and start all Mesos containers
EOF
}
ARGS=$(getopt -o hi: -l help,inventory: --name "$0" -- "$@") || { usage >&2; exit 2; }
eval set -- "$ARGS"
find_base_dir
INVENTORY="${BASEDIR}/ansible/inventory/all-in-one"
PLAYBOOK="${BASEDIR}/ansible/site.yml"
while [ "$#" -gt 0 ]; do
case "$1" in
(--inventory|-i)
INVENTORY="$2"
shift 2
;;
(--help|-h)
usage
shift
exit 0
;;
(--)
shift
break
;;
(*)
echo "error"
exit 3
;;
esac
done
case "$1" in
(deploy)
CMD="ansible-playbook -i $INVENTORY -e @/etc/kolla-mesos/globals.yml -e @/etc/kolla-mesos/passwords.yml $PLAYBOOK"
;;
(*)
usage
exit 0
;;
esac
process_cmd