deploy/deploy.sh
changeset 12 d9d75b93e132
equal deleted inserted replaced
11:2c9f9128c49b 12:d9d75b93e132
       
     1 #!/usr/bin/env bash
       
     2 
       
     3 SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
       
     4 SCRIPTNAME=`basename "$0"`
       
     5 
       
     6 usage() {
       
     7   echo -n "${SCRIPTNAME} [CONFIG] [VERSION]
       
     8 
       
     9 Deploy the <config> using ansible.
       
    10 config must be in the following list : test, prod
       
    11 "
       
    12 }
       
    13 
       
    14 if [[ "$#" -ne 2 ]]; then
       
    15     usage
       
    16     exit 1
       
    17 fi
       
    18 
       
    19 config=${1}
       
    20 VERSION=${2}
       
    21 
       
    22 case $config in
       
    23     test) configOK=true;;
       
    24     prod) configOK=true;;
       
    25     *)    configOK=false;;
       
    26 esac
       
    27 
       
    28 if [[ "$configOK" = false ]]; then
       
    29     usage
       
    30     exit 1
       
    31 fi
       
    32 
       
    33 pushd "$SCRIPTPATH"
       
    34 
       
    35 ANSIBLE_SSH_PIPELINING=1 ANSIBLE_STDOUT_CALLBACK=debug ansible-playbook -v -i "./hosts/hosts.$config" -l "$config" ./deploy.yml --extra-vars "rc_version=${VERSION}" --ask-vault-pass
       
    36 
       
    37 popd