forked from GetValkyrie/ansible-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-ansible.sh
executable file
·89 lines (78 loc) · 2.04 KB
/
install-ansible.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh
ANSIBLE_STABLE_BRANCH=stable-1.9
if [ "$(id -u)" != "0" ]; then
echo "Sorry, this script must be run as root."
exit 1
fi
while getopts ":b:c:d" opt; do
case $opt in
b)
branch=$OPTARG
;;
c)
checkout=$OPTARG
;;
d)
ANSIBLE_DEBUG=1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
which ansible > /dev/null 2>&1
if [ $? -eq 1 ]; then
echo "Installing Ansible build dependencies."
if [ -z $ANSIBLE_DEBUG ]; then
apt-get -qq --force-yes update > /dev/null 2>&1
apt-get -qq --force-yes install git python-setuptools python-dev > /dev/null 2>&1
else
apt-get --force-yes update
apt-get --force-yes install git python-setuptools python-dev
fi
if [ -z $branch ] && [ ! -z $ANSIBLE_BRANCH ]; then
echo "Setting branch from environment."
branch=$ANSIBLE_BRANCH
fi
if [ -z $branch ]; then
echo "Using default stable branch: $ANSIBLE_STABLE_BRANCH."
branch="--branch $ANSIBLE_STABLE_BRANCH"
else
echo "Using $branch branch."
branch="--branch $branch"
fi
ansible_dir=/usr/local/lib/ansible/
if [ ! -d $ansible_dir ]; then
echo "Cloning Ansible."
if [ -z $ANSIBLE_DEBUG ]; then
git clone --quiet --recursive git://github.com/ansible/ansible.git $branch $ansible_dir > /dev/null 2>&1
else
git clone --recursive git://github.com/ansible/ansible.git $branch $ansible_dir
fi
fi
if [ -z $checkout ] && [ ! -z $ANSIBLE_CHECKOUT ]; then
echo "Setting checkout target from environment."
checkout=$ANSIBLE_CHECKOUT
fi
if [ ! -z $checkout ]; then
echo "Checking out '$checkout'."
cd $ansible_dir
if [ -z $ANSIBLE_DEBUG ]; then
git checkout $checkout --quiet
else
git checkout $checkout
fi
fi
echo "Running setups tasks for Ansible."
cd $ansible_dir
if [ -z $ANSIBLE_DEBUG ]; then
python ./setup.py install > /dev/null 2>&1
else
python ./setup.py install
fi
fi