forked from geerlingguy/JJG-Ansible-Windows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindows.sh
49 lines (43 loc) · 1.51 KB
/
windows.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
#!/bin/bash
#
# Windows shell provisioner for Ansible playbooks, based on KSid's
# windows-vagrant-ansible: https://github.com/KSid/windows-vagrant-ansible
#
# @todo - Allow proxy configuration to be passed in via Vagrantfile config.
#
# @see README.md
# @author Jeff Geerling, 2014
# @version 1.0
#
# Uncomment if behind a proxy server.
# export {http,https,ftp}_proxy='http://username:password@proxy-host:80'
ANSIBLE_PLAYBOOK=$1
ANSIBLE_HOSTS=$2
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
# Install Ansible and its dependencies if it's not installed already.
if [ ! -f /usr/bin/ansible ]; then
echo "Installing Ansible dependencies and Git."
yum install -y git python python-devel
echo "Installing pip via easy_install."
wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py && rm -f ez_setup.py
easy_install pip
# Make sure setuptools are installed crrectly.
pip install setuptools --no-use-wheel --upgrade
echo "Installing required python modules."
pip install paramiko pyyaml jinja2 markupsafe
echo "Installing Ansible."
pip install ansible
fi
cp /vagrant/${ANSIBLE_HOSTS} ${TEMP_HOSTS} && chmod -x ${TEMP_HOSTS}
echo "Running Ansible provisioner defined in Vagrantfile."
ansible-playbook /vagrant/${ANSIBLE_PLAYBOOK} --inventory-file=${TEMP_HOSTS} --extra-vars "is_windows=true" --connection=local
rm ${TEMP_HOSTS}