-
Notifications
You must be signed in to change notification settings - Fork 2
/
ansible-server.sh
executable file
·133 lines (110 loc) · 3.19 KB
/
ansible-server.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
# SCRIPT:
# REV: Version 1.0
# PLATFORM: Linux
# AUTHOR: Coenraad
#
# PURPOSE: Ansible Tower Quick Script
#
##########################################################
########### DEFINE FILES AND VARIABLES HERE ##############
##########################################################
# Run as root.
# if [[ $EUID -ne 0 ]]; then
# echo -e "\e[1mMust be ROOT to run this script!\e[0m"
# echo -e "\e[1mMust be ROOT to run this script!\e[0m"
# echo -e "\e[1mMust be ROOT to run this script!\e[0m"
# exit
#fi
##########################################################
################ BEGINNING OF MAIN #######################
##########################################################
function sudoUser()
{
clear
echo
echo -e "\e[40;38;5;82m [+] \e[30;48;5;82m Setup Sudo User AND Root SSH For Ansible !!! \e[0m"
echo
echo
echo "Type in the user name that will get sudo role "
echo
read usersudo
echo "$usersudo ALL = (root) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/$usersudo
chmod 0440 /etc/sudoers.d/$usersudo
sleep 2
echo
echo -e "\e[40;38;5;82m [+] \e[30;48;5;82m Enable ROOT Login !!! \e[0m"
echo
sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
sudo systemctl restart ssh
echo
clear
echo
echo -e "\e[32m[-]\e[0m \e[1m Type A ROOT Password for ssh \e[0m"
echo
sudo passwd
}
function systems-ansible-up()
{
clear
echo
echo
sleep 2
clear
echo
echo -e "\e[32m[+]\e[0m Ping ALL Ansible Hosts \e[0m"
echo
ansible all -m ping -u root
echo
read -p "Press [Enter] to continue...or Ctl+C to Exit"
echo
clear
}
function show_menus()
{
clear
echo
echo -e "\e[1;31;42m Ubuntu Ansible - Tower Quick Check \e[0m "
echo
echo -e "\e[32m[-]\e[0m \e[1m Choose : Hit 'a' for - Setup SUDO User for Server \e[0m"
echo -e "\e[32m[-]\e[0m \e[1m Choose : Hit 'b' for - Check Server Uptime And Status \e[0m"
echo -e "\e[32m[-]\e[0m \e[1m Choose : Hit 'c' for - Delete Older Postgresql Vesrions \e[0m"
echo -e "\e[32m[-]\e[0m \e[1m Choose : Hit 'd' for - Install Ansible Packages \e[0m"
echo -e "\e[32m[-]\e[0m \e[1m Choose : Hit 'x' for - Exit \e[0m"
echo
echo "Pick Option:"
}
show_menus
read choice
if [ "$choice" == a ]; then
sudoUser
show_menus
read choice
fi
if [ "$choice" == b ]; then
systems-ansible-up
show_menus
read choice
fi
if [ "$choice" == c ]; then
delete_psql
show_menus
read choice
fi
if [ "$choice" == d ]; then
install_asible
show_menus
read choice
fi
if [ "$choice" == x ]; then
clear
sleep 2
echo -e "\e[40;38;5;82m [*] \e[30;48;5;82m THANK YOU FOR USING ME !!! \e[0m"
echo -e "\e[40;38;5;82m [*] \e[30;48;5;82m Have a nice day! \e[0m"
exit 0
fi
####################################################
################ END OF MAIN #######################
####################################################
exit 0
# End of script