diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-12-17 09:15:42 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-12-17 09:44:51 +0100 |
commit | a1789ddde42033f1b05cc4929491214ee6e79383 (patch) | |
tree | 63615735c4ddffaaabf2428946bb26f90899f7bf /vendor/ruflin/elastica/ansible/provision.sh | |
parent | 9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff) |
Update to MediaWiki 1.26.0
Diffstat (limited to 'vendor/ruflin/elastica/ansible/provision.sh')
-rw-r--r-- | vendor/ruflin/elastica/ansible/provision.sh | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/ansible/provision.sh b/vendor/ruflin/elastica/ansible/provision.sh new file mode 100644 index 00000000..6ea8e575 --- /dev/null +++ b/vendor/ruflin/elastica/ansible/provision.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +set -o xtrace + +install_ansible() { + sudo apt-get update + sudo apt-get install python python-pip python-dev -y + sudo pip install ansible==1.8.2 + sudo mkdir -p /etc/ansible/ + echo "localhost" | sudo tee /etc/ansible/hosts +} + +run_playbook() { + # Write to stdout directly + export PYTHONUNBUFFERED=1 + + # No cows >_< + export ANSIBLE_NOCOWS=1 + + # Root of git repo + if [ -z "$ES_PROJECT_ROOT" ]; then + export ES_PROJECT_ROOT="$(dirname $(dirname $(readlink -f $0)))" + fi + + if [ ! -x $(which ansible-playbook) ]; then + echo "Ansible is not installed" + return 1 + fi + + ansible-playbook $ES_PROJECT_ROOT/ansible/es-playbook.yml -v | tee /tmp/ansible-playbook-progress + + if grep -q "FATAL\|ERROR" /tmp/ansible-playbook-progress; then + return 1 + fi +} + +check_cluster() { + curl -m 5 -s -o /dev/null "http://localhost:9200" && + curl -m 5 -s -o /dev/null "http://localhost:9201" + return $? +} + +travis_retry() { + # We don't use builtin Travis CI function, because this script is also used for vagrant provision. + # But main idea of restarts is so simple, so lets override it without name change. + + $@ && return 0 + + echo "The command $@ failed. Retrying, 2 of 3" + sleep 60s && $@ && return 0 + + echo "The command $@ failed. Retrying, 3 of 3" + sleep 60s && $@ && return 0 + + echo "The command $@ failed." + return 1 +} + +travis_retry install_ansible || exit 1 + +travis_retry run_playbook || exit 1 + +travis_retry check_cluster || exit 1 |