-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
executable file
·74 lines (58 loc) · 1.89 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
73
74
#!/usr/bin/env bash
set -Eeuo pipefail
TRACE=${TRACE:-}
[[ "$TRACE" ]] && set -x
function install_homebrew() {
if [[ -x "$(command -v /opt/homebrew/bin/brew)" ]]
then
echo Homebrew already installed
else
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Configure homebrew in this shell to allow the installation to proceed
# shellcheck disable=SC2016
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "${HOME}"/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
# Turn off analytics
brew analytics off
fi
}
function install_ansible() {
if brew ls --versions ansible > /dev/null 2>&1
then
echo Homebrew ansible formula already installed
else
brew install ansible
fi
}
#
# Create a macOS keychain entry and password lookup file for the Ansible Vault password
#
function install_ansible_vault_password() {
local ACCOUNT_NAME="macos-infra"
local SERVICE="Ansible Vault"
if /usr/bin/security find-generic-password -a "$ACCOUNT_NAME" -s "$SERVICE" > /dev/null 2>&1
then
echo Keychain entry for Ansible Vault password already installed
else
/usr/bin/security add-generic-password -a "$ACCOUNT_NAME" -s "$SERVICE" -w
fi
local VAULT_PASSWORD_FILE="./vault_password_file"
if [[ ! -e "$VAULT_PASSWORD_FILE" ]]
then
cat << EOF > "$VAULT_PASSWORD_FILE"
#!/usr/bin/env bash
/usr/bin/security find-generic-password -a "$ACCOUNT_NAME" -s "$SERVICE" -w
EOF
chmod +x "$VAULT_PASSWORD_FILE"
fi
}
function main() {
install_homebrew
install_ansible
git clone https://github.com/andrewdavidbell/macos-infra.git
cd ./macos-infra
# install_ansible_vault_password
echo "Run the following command to provision the infrastructure:"
echo "ansible-playbook -i <home|work> site.yml -v"
}
main