-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall.sh
executable file
·47 lines (37 loc) · 1.48 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
#/bin/bash
echo -n "SUDO Password: "
stty -echo
read sudopassword
stty echo
echo
if [ ! -x "$(command -v lsb_release)" ]; then
if [ -x "$(command -v apt-get)" ]; then
echo 'installing lsb release'
echo "$sudopassword\n" | sudo -S -p '' apt-get install -y lsb-release
# elif [ -x "$(command -v yum)" ]; then
# echo "$sudopassword\n" | sudo -S -p '' yum install -y redhat-lsb
fi
fi
user=`whoami`
distId=`lsb_release -si`
distRelease=`lsb_release -sr`
distCodename=`lsb_release -sc`
if [ "$distId" = 'Debian' -o "$distId" = 'Ubuntu' ]; then
if [ ! -x "$(command -v pip3)" ]; then
echo "installing Python and build dependencies ..."
echo "$sudopassword" | sudo -S -p '' apt-get install -y -q build-essential libffi-dev libssl-dev python3 python3-dev python3-pip git
fi
if [ ! -x "$(command -v ansible)" ]; then
echo "installing Ansible ..."
echo "$sudopassword" | sudo -S -p '' pip3 install -q -U 'ansible>=3.0' jmespath
fi
fi
echo "installing ansible galaxy roles"
ansible-galaxy role install -r roles.yml -p roles -g
playbook_options="--user $user $@"
if [ -f "vault/secrets.yml" ];then
playbook_options="$playbook_options --ask-vault-pass"
fi
echo "running ansible playbook ..."
echo "command : ansible-playbook main.yml --ask-become-pass --extra-vars \"account_default_user=$user\" $playbook_options"
ansible-playbook main.yml --extra-vars "ansible_become_pass=$sudopassword account_default_user=$user" $playbook_options