-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvm-setup.sh
executable file
·51 lines (37 loc) · 1.28 KB
/
vm-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
#!/bin/bash
# A relatively simple script to setup your VM if not using the Vagrant stuff.
TOP_DIR=$(readlink -f $(dirname $0) )
set -o nounset
set -o errexit
# Must be root, and not using 'sudo ./vm-setup.sh'
if [[ "${1:-}" != "--force" ]]; then
if [[ $EUID -ne 0 ]] || [[ -n ${SUDO_COMMAND:-} ]]; then
echo "Must be root to run this script"
echo "Please don't use 'sudo ./vm-setup.sh' as things can go wrong :("
echo ""
echo "Recommend to do: sudo su -"
exit 1
fi
fi
set -o xtrace
export LANG=en_US.utf8
echo "Update apt-get database..."
apt-get update
# Ansible needed packages
PACKAGES="python-dev python3-dev libffi-dev libssl-dev"
PACKAGES="nfs-kernel-server ${PACKAGES}"
PACKAGES="git python python3 gcc ${PACKAGES}"
echo "Install required packages..."
apt-get install --assume-yes ${PACKAGES}
echo "Install pip..."
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
python3 get-pip.py
echo "Install ansible, at least 2.0 ..."
pip install ansible
echo "Create ansible hosts file to run ansible in the local VM..."
cd $TOP_DIR/ansible
echo "localhost ansible_connection=local" > hosts
echo "Run ansible..."
ansible-playbook -vvv -i hosts playbook.yml
echo "You might want to make a snapshot of this VM for future use"