-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·84 lines (72 loc) · 1.79 KB
/
Copy pathinstall
File metadata and controls
executable file
·84 lines (72 loc) · 1.79 KB
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
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
set -euo pipefail
root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
pull=true
target=""
usage() {
cat <<'EOF'
Usage: ./install [-n|--no-pull] [local|final|MACHINE]
./install Configure all inventory hosts
./install local Configure this machine only
./install MACHINE Bootstrap one inventory host
./install final Run the interactive final setup
Options:
-n, --no-pull Skip all dotfiles repository updates
-h, --help Show this help
EOF
}
while (($#)); do
case "$1" in
-n | --no-pull)
pull=false
;;
-h | --help)
usage
exit 0
;;
-*)
printf 'Unknown option: %s\n\n' "$1" >&2
usage >&2
exit 2
;;
*)
if [[ -n "$target" ]]; then
printf 'Only one target may be specified\n\n' >&2
usage >&2
exit 2
fi
target=$1
;;
esac
shift
done
if [[ "$target" == final ]]; then
exec "$root/scripts/install/finalize-setup.sh"
fi
if [[ "$pull" == true ]]; then
git -C "$root" pull
fi
cd "$root/ansible"
ansible_args=()
if [[ "$pull" == false ]]; then
ansible_args+=(--extra-vars update_dotfiles=false)
fi
case "$target" in
"")
exec ansible-playbook main.yml "${ansible_args[@]}"
;;
local)
exec ansible-playbook main.yml \
--limit "$(hostname -s)" \
"${ansible_args[@]}"
--extra-vars prompt_for_machine_password=true
;;
*)
exec ansible-playbook main.yml \
--limit "$target" \
"${ansible_args[@]}" \
--extra-vars prompt_for_machine_password=true
;;
esac
# Note: As of right now this only prompts for missing ssh/sudo password on single-machine/local runs.
# If you do a simple `./install` and a machine is missing its password in .env Ansible will hard-fail.