-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathansible-tests.sh
73 lines (58 loc) · 1.74 KB
/
ansible-tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
set -o errexit
set -o nounset
#set -o xtrace
set -o pipefail
__DIR__="$(cd "$(dirname "${0}")"; echo $(pwd))"
__BASE__="$(basename "${0}")"
__FILE__="${__DIR__}/${__BASE__}"
__NAME__="${0##*/}"
##################### function #########################
_report_err() { echo "${__NAME__}: Error: $*" >&2 ; }
if [ -t 1 ]
then
RED="$( echo -e "\e[31m" )"
HL_RED="$( echo -e "\e[31;1m" )"
HL_BLUE="$( echo -e "\e[34;1m" )"
NORMAL="$( echo -e "\e[0m" )"
fi
_hl_red() { echo "$HL_RED""$@""$NORMAL";}
_hl_blue() { echo "$HL_BLUE""$@""$NORMAL";}
_trace() {
echo $(_hl_blue ' ->') "$@" >&2
}
_print_fatal() {
echo $(_hl_red '==>') "$@" >&2
}
if ! command -v ansible-playbook >/dev/null; then
_print_fatal "Please install ansible-playbook first."
exit 1
fi
function lsb_release() {
python << END
import platform;
version = ""
system = platform.system();
release = platform.release();
if system == "Darwin":
ver = platform.mac_ver();
version = "%s %s %s" % (system, ver[0], ver[2])
else:
ver = platform.linux_distribution()
version = ' '.join(ver)
print version
END
}
echo "################################"
echo "Build Information"
echo "Directory: ${__DIR__}"
echo "Filename: ${__FILE__}"
echo "Version Information:"
echo "Ansible Version: $(ansible --version)"
echo "Ansible Playbook Version: $(ansible-playbook --version)"
echo "Operating System: $(lsb_release)"
echo "Kernel: $(uname -a)"
echo "################################"
_trace "### Starting tests"
find ${__DIR__} -maxdepth 1 \( -iname "*.yml" ! -iname ".*" \) | xargs -n1 ansible-playbook --syntax-check --list-tasks -i hosts
#find ${__DIR__} -maxdepth 1 \( -iname "*.yml" ! -iname ".*" \) | xargs -n1 ansible-playbook --check -i hosts