forked from geerlingguy/JJG-Ansible-Windows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindows.sh
60 lines (50 loc) · 1.86 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
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
#
# Windows shell provisioner for Ansible playbooks, based on KSid's
# windows-vagrant-ansible: https://github.com/KSid/windows-vagrant-ansible
#
# @see README.md
# @author Jeff Geerling, 2014
# Uncomment if behind a proxy server.
# export {http,https,ftp}_proxy='http://username:password@proxy-host:80'
ANSIBLE_PLAYBOOK=$1
PLAYBOOK_DIR=${ANSIBLE_PLAYBOOK%/*}
ROLE_REQUIREMENTS=$(find /vagrant/$PLAYBOOK_DIR -name "requirements.yml" -o -name "requirements.txt")
# Detect package management system.
YUM=$(which yum)
APT_GET=$(which apt-get)
# Make sure Ansible playbook exists.
if [ ! -f /vagrant/$ANSIBLE_PLAYBOOK ]; then
echo "Cannot find Ansible playbook."
exit 1
fi
# Install Ansible and its dependencies if it's not installed already.
if [ ! -f /usr/bin/ansible ]; then
echo "Installing Ansible dependencies and Git."
if [[ ! -z $YUM ]]; then
yum install -y git python python-devel
elif [[ ! -z $APT_GET ]]; then
apt-get install -y git python python-dev
else
echo "Neither yum nor apt-get are available."
exit 1;
fi
echo "Installing pip via easy_install."
wget https://raw.githubusercontent.com/ActiveState/ez_setup/v0.9/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
# Install Ansible roles from requirements file, if available.
if [ -f "$ROLE_REQUIREMENTS" ]; then
echo "Found Ansible role file at $ROLE_REQUIREMENTS"
sudo ansible-galaxy install -r "${ROLE_REQUIREMENTS}"
fi
# Run the playbook.
echo "Running Ansible provisioner defined in Vagrantfile."
ansible-playbook -i 'localhost,' /vagrant/${ANSIBLE_PLAYBOOK} --extra-vars "is_windows=true" --connection=local