-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
84 lines (71 loc) · 1.66 KB
/
setup.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
#!/bin/bash
if [ "$0" != "-bash" -a "$0" != "-/bin/bash" ]
then
echo "this script must be sourced from a bash shell" >&2
exit 1
fi
if ! grep -qi '^ubuntu 12.04' /etc/issue.net
then
echo "this script must be run on an Ubuntu 12.04 system" >&2
return 1
fi
BASENAME="$( basename ${BASH_SOURCE[0]} )"
DIRNAME="$( cd $( dirname ${BASH_SOURCE[0]} ); pwd )"
ANSIBLE_REPO="git://github.com/ansible/ansible.git"
ANSIBLE_HOME="/var/tmp/ansible"
ANSIBLE_VERSION_TAG="v1.3.2"
for PKG in \
git python python-jinja2 python-paramiko python-yaml sudo
do
if ! dpkg -l $PKG >/dev/null 2>&1
then
sudo aptitude -y install $PKG
if [ $? -ne 0 ]
then
echo "an error occurred while installing package $PKG: $?" >&2
return 1
fi
fi
done
sudo -k
sudo -n /bin/true 2>/dev/null
RC=$?
if [ $RC -ne 0 ]
then
echo "password-less sudo is not enabled: $RC" >&2
return 1
fi
if [ ! -d $ANSIBLE_HOME ]
then
git clone $ANSIBLE_REPO $ANSIBLE_HOME
cd $ANSIBLE_HOME
git checkout $ANSIBLE_VERSION_TAG
cd $DIRNAME
if [ $? -ne 0 ]
then
echo "clone of ansible repository failed: $?" >&2
rm -rf $ANSIBLE_HOME
return 1
fi
fi
if ! echo $MANPATH | grep -q "$ANSIBLE_HOME/docs/man"
then
export MANPATH=$ANSIBLE_HOME/docs/man:$MANPATH
fi
if [ -d "$DIRNAME/library" ]
then
export ANSIBLE_LIBRARY="$DIRNAME/library:$ANSIBLE_HOME/library"
else
export ANSIBLE_LIBRARY=$ANSIBLE_HOME/library
fi
if ! echo $PATH | grep -q "$ANSIBLE_HOME/bin"
then
export PATH=$ANSIBLE_HOME/bin:$PATH
fi
if ! echo $PYTHONPATH | grep -q "$ANSIBLE_HOME/lib"
then
export PYTHONPATH=$ANSIBLE_HOME/lib:$PYTHONPATH
fi
export ANSIBLE_HOSTS="$DIRNAME/hosts"
cd $DIRNAME
./fetch-templates.sh