From 337977e8686ed7db1c95b4a2f2fe63483a9fbee9 Mon Sep 17 00:00:00 2001 From: Smaine Kahlouch Date: Thu, 21 Jan 2016 10:51:13 +0100 Subject: [PATCH] script which gives info about the deployment state fix script location --- roles/kubernetes/preinstall/gen-gitinfos.sh | 73 +++++++++++++++++++ .../kubernetes/preinstall/tasks/gitinfos.yml | 25 +++++++ roles/kubernetes/preinstall/tasks/main.yml | 2 + .../preinstall/templates/ansible_git.j2 | 3 + 4 files changed, 103 insertions(+) create mode 100755 roles/kubernetes/preinstall/gen-gitinfos.sh create mode 100644 roles/kubernetes/preinstall/tasks/gitinfos.yml create mode 100644 roles/kubernetes/preinstall/templates/ansible_git.j2 diff --git a/roles/kubernetes/preinstall/gen-gitinfos.sh b/roles/kubernetes/preinstall/gen-gitinfos.sh new file mode 100755 index 000000000..34b977f7e --- /dev/null +++ b/roles/kubernetes/preinstall/gen-gitinfos.sh @@ -0,0 +1,73 @@ +#!/bin/sh +set -e + +# Text color variables +txtbld=$(tput bold) # Bold +bldred=${txtbld}$(tput setaf 1) # red +bldgre=${txtbld}$(tput setaf 2) # green +bldylw=${txtbld}$(tput setaf 3) # yellow +txtrst=$(tput sgr0) # Reset +err=${bldred}ERROR${txtrst} +info=${bldgre}INFO${txtrst} +warn=${bldylw}WARNING${txtrst} + +usage() +{ + cat << EOF +Generates a file which contains useful git informations + +Usage : $(basename $0) [global|diff] + ex : + Generate git information + $(basename $0) global + Generate diff from latest tag + $(basename $0) diff +EOF +} + +if [ $# != 1 ]; then + printf "\n$err : Needs 1 argument\n" + usage + exit 2 +fi; + +current_commit=$(git rev-parse HEAD) +latest_tag=$(git describe --abbrev=0 --tags) +latest_tag_commit=$(git show-ref -s ${latest_tag}) +tags_list=$(git tag --points-at "${latest_tag}") + +case ${1} in + "global") +cat<