Skip to content

Instantly share code, notes, and snippets.

@aguimaraes
Last active April 6, 2017 10:29
Show Gist options
  • Save aguimaraes/226a9e97c92465953e6905110600a175 to your computer and use it in GitHub Desktop.
Save aguimaraes/226a9e97c92465953e6905110600a175 to your computer and use it in GitHub Desktop.
export AUTOMATION_REPO_PATH="$HOME/Code/automation"
hf-deploy() {
env=$1
app=$2
ver=$3
if [ -z $1 -o -z $2 -o -z $3 ]
then
echo "Missing parameters."
echo "hf-deploy <environment> <application> <version>"
return 1
fi
environment_file="$AUTOMATION_REPO_PATH/$env.ini"
if [ ! -f $environment_file ]
then
echo "Could not find that environment file: $environment_file"
return 1
fi
application_file="$AUTOMATION_REPO_PATH/plays/$app.yml"
if [ ! -f $application_file ]
then
echo "Could not find application file: $application_file"
return 1
fi
vault_password_file="$AUTOMATION_REPO_PATH/.vpass"
if [ ! -f $vault_password_file ]
then
echo "Could not find your automation vpass file: $vault_password_file"
return 1
fi
if [ ! -d $AUTOMATION_REPO_PATH/.git/index.lock ]
then
echo "Updating your repo!"
git -C $AUTOMATION_REPO_PATH pull
fi;
echo "Deployment coming!"
ansible-playbook -i $environment_file $application_file --vault-password-file=$vault_password_file -t deployment -e deployment_force=true -e deployment_version=$ver
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment