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:
parent
8f361d4c51
commit
076135db1a
1 changed files with 7 additions and 1 deletions
|
@ -54,7 +54,13 @@ fi
|
|||
# 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
|
||||
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 | cut -f 2 -d " "`
|
||||
CURR_ANSIBLE_VER=`ansible --version | head -1 | awk '{print $2}'`
|
||||
|
|
Loading…
Reference in a new issue