terser hostfile fallback mechanism
This commit is contained in:
parent
5903ef0e7b
commit
3bfd530fda
18
src/_ansible
18
src/_ansible
|
@ -58,20 +58,10 @@ __host_file_location () {
|
|||
# 2. else check /etc/ansible/hosts or /usr/local/etc/...
|
||||
# (depending on platform)
|
||||
#
|
||||
if [ -n "${ANSIBLE_HOSTS}" ]; then # use envvar
|
||||
HOST_FILE=${ANSIBLE_HOSTS}
|
||||
else
|
||||
if [[ "$OSTYPE" == darwin* ]]; then
|
||||
CANDIDATE="/usr/local/etc/ansible/hosts"
|
||||
else
|
||||
CANDIDATE="/etc/ansible/hosts"
|
||||
fi
|
||||
if [ -f "$CANDIDATE" ]; then
|
||||
HOST_FILE=${CANDIDATE}
|
||||
else
|
||||
HOST_FILE=/dev/null
|
||||
fi
|
||||
fi
|
||||
[[ "$OSTYPE" == darwin* ]] && FALLBACK="/usr/local/etc/ansible/hosts"
|
||||
[[ "$OSTYPE" == linux* ]] && FALLBACK="/etc/ansible/hosts"
|
||||
HOST_FILE=${ANSIBLE_HOSTS:=${FALLBACK}}
|
||||
[[ -f ${HOST_FILE} ]] || HOST_FILE=/dev/null
|
||||
|
||||
echo ${HOST_FILE}
|
||||
}
|
||||
|
|
|
@ -56,20 +56,11 @@ __host_file_location () {
|
|||
# 2. else check /etc/ansible/hosts or /usr/local/etc/...
|
||||
# (depending on platform)
|
||||
#
|
||||
if [ -n "${ANSIBLE_HOSTS}" ]; then # use envvar
|
||||
HOST_FILE=${ANSIBLE_HOSTS}
|
||||
else
|
||||
if [[ "$OSTYPE" == darwin* ]]; then
|
||||
CANDIDATE="/usr/local/etc/ansible/hosts"
|
||||
else
|
||||
CANDIDATE="/etc/ansible/hosts"
|
||||
fi
|
||||
if [ -f "$CANDIDATE" ]; then
|
||||
HOST_FILE=${CANDIDATE}
|
||||
else
|
||||
HOST_FILE=/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ "$OSTYPE" == darwin* ]] && FALLBACK="/usr/local/etc/ansible/hosts"
|
||||
[[ "$OSTYPE" == linux* ]] && FALLBACK="/etc/ansible/hosts"
|
||||
HOST_FILE=${ANSIBLE_HOSTS:=${FALLBACK}}
|
||||
[[ -f ${HOST_FILE} ]] || HOST_FILE=/dev/null
|
||||
|
||||
echo ${HOST_FILE}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue