Skip to content

Instantly share code, notes, and snippets.

@libero18
Last active August 29, 2015 14:05
Show Gist options
  • Save libero18/90ef4217366db6300d6b to your computer and use it in GitHub Desktop.
Save libero18/90ef4217366db6300d6b to your computer and use it in GitHub Desktop.
ansible-playbook xxxxxxxxx.yml 実行時にEXTRA_VARSとして git のリビジョン番号をセットさせたい場合
function ansible-playbook_wrapper() {
if [ $(git log -n 1 >/dev/null 2>&1 ; echo $?) -eq 0 ]; then
\ansible-playbook $@ -e "playbook_version=$(git log -n 1 | head -n 1 | awk -F " " '{print $2}')"
else
\ansible-playbook $@
fi
}
alias ansible-playbook=ansible-playbook_wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment