-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
72 lines (58 loc) · 2.03 KB
/
install.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
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
# This script bootstraps a OSX laptop for development
# to a point where we can run Ansible on localhost. It:
# 1. Installs:
# - xcode
# - homebrew
# - ansible (via brew)
# - a few ansible galaxy playbooks (zsh, homebrew, cask etc)
# 2. Kicks off the ansible playbook:
# - main.yml
#
# It begins by asking for your sudo password:
fancy_echo() {
local fmt="$1"; shift
# shellcheck disable=SC2059
printf "\n$fmt\n" "$@"
}
fancy_echo "Boostrapping ..."
trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT
set -e
# Here we go.. ask for the administrator password upfront and run a
# keep-alive to update existing `sudo` time stamp until script has finished
# sudo -v
# while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Ensure Apple's command line tools are installed
if ! command -v cc >/dev/null; then
fancy_echo "Installing xcode ..."
xcode-select --install
else
fancy_echo "Xcode already installed. Skipping."
fi
if ! command -v brew >/dev/null; then
fancy_echo "Installing Homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" </dev/null
else
fancy_echo "Homebrew already installed. Skipping."
fi
# [Install Ansible](http://docs.ansible.com/intro_installation.html).
if ! command -v ansible >/dev/null; then
fancy_echo "Installing Ansible ..."
brew install ansible
else
fancy_echo "Ansible already installed. Skipping."
fi
# Clone the repository to your local drive.
if [ -d "./mac-dev-playbook" ]; then
fancy_echo "Mac dev playbook repo dir exists. Removing ..."
rm -rf ./mac-dev-playbook/
fi
fancy_echo "Cloning mac dev playbook repo ..."
git clone https://github.com/rattrap/mac-dev-playbook.git
fancy_echo "Changing to mac dev playbook repo dir ..."
cd mac-dev-playbook
fancy_echo "Installing ansible modules ..."
ansible-galaxy install -r requirements.yml
# Run this from the same directory as this README file.
fancy_echo "Running ansible playbook ..."
ansible-playbook main.yml -i inventory -K