#!/usr/bin/env bash # Copyright 2014, Rackspace US, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -e -u -v -x REPO_URL=${REPO_URL:-"https://github.com/rcbops/ansible-lxc-rpc.git"} REPO_BRANCH=${REPO_BRANCH:-"master"} FROZEN_REPO_URL=${FROZEN_REPO_URL:-"http://rpc-slushee.rackspace.com"} MAX_RETRIES=${MAX_RETRIES:-5} apt-get update apt-get install -y python-dev \ python2.7 \ build-essential \ curl \ git-core \ ipython \ tmux \ vim \ vlan \ bridge-utils \ lvm2 \ linux-image-extra-$(uname -r) function key_create(){ ssh-keygen -t rsa -f /root/.ssh/id_rsa -N '' } # Used to retry process that may fail due to random issues. function successerator() { set +e RETRY=0 # Set the initial return value to failure false while [ $? -ne 0 -a ${RETRY} -lt ${MAX_RETRIES} ];do RETRY=$((${RETRY}+1)) $@ done if [ ${RETRY} -eq ${MAX_RETRIES} ];then echo "Hit maximum number of retries, giving up..." exit 1 fi set -e } function install_bits() { successerator ansible-playbook -e @/etc/rpc_deploy/user_variables.yml \ playbooks/$@ } if [ ! -d "/opt" ];then mkdir /opt fi if [ ! "$(swapon -s | grep -v Filename)" ];then cat > /opt/swap.sh < /etc/rpc_deploy/user_variables.yml < /etc/rpc_deploy/rpc_user_config.yml < /etc/network/interfaces.d/aio-bridges.cfg < /etc/update-motd.d/00-rpc-notice<< EOF #!/usr/bin/env bash echo "" echo "############ RPC DEPLOYMENT #############" echo "A new kernel was installed on this system. you will" echo "need to re-bootstrap Galera to get the cluster operataional." echo "from the /opt/ansible-lxc-rpc/rpc_deployment directory execute:" echo "" echo "ansible-playbook -e @/etc/rpc_deploy/user_variables.yml playbooks/infrastructure/galera-startup.yml" EOF chmod +x /etc/update-motd.d/00-rpc-notice shutdown -r now fi