-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathansible_slave_d.bash
57 lines (48 loc) · 2.38 KB
/
ansible_slave_d.bash
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
#!/bin/bash
ID=$(cat /etc/os-release | grep ID_LIKE | awk -F'=' '{gsub(/"/, "", $2); print $2}')
if [[ $ID == "debian" ]]; then
echo "#########################################"
echo "installing for debian - anisble slave"
echo "#########################################"
sudo apt update
sudo apt-get update -y
sudo apt-get install python3 -y
sudo apt install software-properties-common
# Create Ansible User
sudo adduser --quiet --disabled-password --gecos "" ansible && \echo "ansible:ansible" | sudo chpasswd
# file: etc/ssh/sshd_config
echo "" | sudo tee /etc/ssh/sshd_config
echo "KbdInteractiveAuthentication no" | sudo tee -a /etc/ssh/sshd_config
echo "UsePAM yes" | sudo tee -a /etc/ssh/sshd_config
echo "X11Forwarding yes" | sudo tee -a /etc/ssh/sshd_config
echo "PrintMotd no" | sudo tee -a /etc/ssh/sshd_config
echo "AcceptEnv LANG LC_*" | sudo tee -a /etc/ssh/sshd_config
echo "Subsystem sftp /usr/lib/openssh/sftp-server" | sudo tee -a /etc/ssh/sshd_config
echo "PasswordAuthentication yes" | sudo tee -a /etc/ssh/sshd_config
echo "PermitRootLogin yes" | sudo tee -a /etc/ssh/sshd_config
# file: /etc/sudoers
echo "ansible ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers
sudo systemctl restart ssh
elif [[ $ID == "fedora" ]]; then
echo "#########################################"
echo "installing for fedora - anisble slave"
echo "#########################################"
sudo yum update -y
sudo yum install python3 -y
sudo adduser ansible
echo "ansible:ansible" | sudo chpasswd
# file: etc/ssh/sshd_config
echo "" | sudo tee /etc/ssh/sshd_config
echo "KbdInteractiveAuthentication no" | sudo tee -a /etc/ssh/sshd_config
echo "UsePAM yes" | sudo tee -a /etc/ssh/sshd_config
echo "X11Forwarding yes" | sudo tee -a /etc/ssh/sshd_config
echo "PrintMotd no" | sudo tee -a /etc/ssh/sshd_config
echo "AcceptEnv LANG LC_*" | sudo tee -a /etc/ssh/sshd_config
echo "Subsystem sftp /usr/lib/openssh/sftp-server" | sudo tee -a /etc/ssh/sshd_config
echo "PasswordAuthentication yes" | sudo tee -a /etc/ssh/sshd_config
echo "PermitRootLogin yes" | sudo tee -a /etc/ssh/sshd_config
# file: /etc/sudoers
echo "ansible ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers
# Restart SSH service to apply changes
sudo systemctl restart sshd
fi