forked from KSid/windows-vagrant-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision.sh
31 lines (26 loc) · 820 Bytes
/
provision.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
#!/bin/bash
ANSIBLE_DIR=$1
ANSIBLE_PLAYBOOK=$2
ANSIBLE_HOSTS=$3
TEMP_HOSTS="/tmp/ansible_hosts"
if [ ! -f /vagrant/$ANSIBLE_PLAYBOOK ]; then
echo "Cannot find Ansible playbook"
exit 1
fi
if [ ! -f /vagrant/$ANSIBLE_HOSTS ]; then
echo "Cannot find Ansible hosts"
exit 2
fi
if [ ! -d $ANSIBLE_DIR ]; then
echo "Updating apt cache"
apt-get update
echo "Installing Ansible dependencies and Git"
apt-get install -y git python-yaml python-paramiko python-jinja2
echo "Cloning Ansible"
git clone git://github.com/ansible/ansible.git ${ANSIBLE_DIR}
fi
cd ${ANSIBLE_DIR}
cp /vagrant/${ANSIBLE_HOSTS} ${TEMP_HOSTS} && chmod -x ${TEMP_HOSTS}
echo "Running Ansible"
bash -c "source hacking/env-setup && ansible-playbook /vagrant/${ANSIBLE_PLAYBOOK} --inventory-file=${TEMP_HOSTS} --connection=local"
rm ${TEMP_HOSTS}