1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-12 19:22:24 +00:00

like iiab-network: if [[ command -v ansible ]]; then

This commit is contained in:
A Holt 2017-12-13 06:39:29 -05:00 committed by GitHub
parent 8f361d4c51
commit 076135db1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,7 +54,13 @@ fi
# Verify that a recent enough version of Ansible is installed. See #449. The # Verify that a recent enough version of Ansible is installed. See #449. The
# "include:" command was inconsistently implemented prior to Ansible 2.4.x.x # "include:" command was inconsistently implemented prior to Ansible 2.4.x.x
CURR_ANSIBLE_VER=0 CURR_ANSIBLE_VER=0
if type -P ansible ; then #if [ $(grep ubuntu /etc/apt/sources.list) ]; then # FAILS when multiple lines returned, due to single square brackets
#if grep -q ubuntu /etc/apt/sources.list ; then # Works: bypasses need for "> /dev/null" thanks to "grep -q" (quiet)
#if command -v ansible > /dev/null ; then # Works But Wordy!
#if [[ $(command -v ansible) ]]; then # Also Works! $(...) nests more easily than backticks
#if [[ `which ansible` ]]; then # "which" misses built-in commands like cd, and is RISKY per https://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script
#if [[ `type -P ansible` ]]; then # "type -P" isn't POSIX compliant; it misses built-in commands like "cd"
if [[ `command -v ansible` ]]; then # "command -v" is POSIX compliant; it catches built-in commands like "cd"
#CURR_ANSIBLE_VER=`ansible --version | head -1 | sed -e 's/.* //'` #CURR_ANSIBLE_VER=`ansible --version | head -1 | sed -e 's/.* //'`
#CURR_ANSIBLE_VER=`ansible --version | head -1 | cut -f 2 -d " "` #CURR_ANSIBLE_VER=`ansible --version | head -1 | cut -f 2 -d " "`
CURR_ANSIBLE_VER=`ansible --version | head -1 | awk '{print $2}'` CURR_ANSIBLE_VER=`ansible --version | head -1 | awk '{print $2}'`