-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.sh
executable file
·76 lines (65 loc) · 1.72 KB
/
run.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
75
76
#!/usr/bin/env bash
set -o pipefail
#--- Handle errors ---#
error() {
local name="$1"
echo "Dependency "$name" not found."
if [[ "${name}" == "ansible" ]];
then
echo "Retry to run with --ansible option if you want an automatic install,"
echo "or install ansible by yourself first."
fi
exit 1
}
install-ansible() {
echo "---> Install ansible - start"
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
echo "---> Install ansible - done"
}
install-ansible-dev() {
# We use the snap module with will be available in 2.8
sudo apt install python-pip
pip install git+https://github.com/ansible/ansible.git@devel
}
install-dependencies() {
local ansiblegalaxy="$(which ansible-galaxy)"
local ansibleplaybook="$(which ansible-playbook)"
if [[ -n "${ansiblegalaxy}" ]] && [[ -n "${ansibleplaybook}" ]]; then
echo "---> Get dependencies"
# Download galaxy roles
${ansiblegalaxy} install -r requirements.yml --force
else
error ansible
fi
}
install-tools () {
local ansiblegalaxy="$(which ansible-galaxy)"
local ansibleplaybook="$(which ansible-playbook)"
if [[ -n "${ansiblegalaxy}" ]] && [[ -n "${ansibleplaybook}" ]]; then
echo "---> Install or Update computer - start"
# Provisionning
${ansibleplaybook} playbook.yml -i hosts --user=$(whoami) -e my_user=$(whoami) --ask-become-pass -vvvv
echo "---> Install or Update computer - done"
else
error ansible
fi
}
main() {
while [[ "$#" -gt 0 ]]
do
case $1 in
--ansible)
install-ansible
;;
--ansible-dev)
install-ansible-dev
;;
esac
shift
done
install-dependencies
install-tools
}
main "$@"