#!/bin/bash

# Prompt the user for their sudo password
sudo -v

# Xcode - Command Line Tools
if type xcode-select >&- && xpath=$( xcode-select --print-path ) &&
test -d "${xpath}" && test -x "${xpath}" ; then
  echo "Command Line Tools are already installed."
else
  xcode-select --install
fi

# Enable passwordless sudo for the macbuild run
sudo sed -i -e "s/^%admin.*/%admin  ALL=(ALL) NOPASSWD: ALL/" /etc/sudoers

# disable required virtualenv
virtualenv_required=$PIP_REQUIRE_VIRTUALENV
export PIP_REQUIRE_VIRTUALENV=false

# Install pip
if ! which pip > /dev/null 2>&1
then
  echo -n "Installing pip"
  sudo easy_install pip
  echo " - Done"
fi

# Install Ansible (using pip is the officially supported way)
if ! pip2 show ansible > /dev/null 2>&1
then
  echo -n "Installing Ansible"
  pip2 install ansible
  echo " - Done"
fi

# Install Ansible roles
echo "Installing Ansible roles";
ansible-galaxy install -r ./requirements.yml;

# Perform the build
# ansible-playbook -i localhost, -e ansible_python_interpreter=/usr/local/bin/python local.yml

# reset PIP_REQUIRE_VIRTUALENV
export PIP_REQUIRE_VIRTUALENV=$virtualenv_required

# Disable passwordless sudo after the macbuild is complete
sudo sed -i -e "s/^%admin.*/%admin  ALL=(ALL) ALL/" /etc/sudoers

echo "All Done!"

Add the main bash script
Add the main bash script
