You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

21 lines
717 B

#!/bin/bash
# must run with sudo!!!
sysctl -w net.ipv4.tcp_syncookies=0
apt-get update
apt-get install ansible -y
apt-get install sshpass -y
sed '/\[defaults\]/a host_key_checking = False' /etc/ansible/ansible.cfg > temp && cat temp > /etc/ansible/ansible.cfg
rm temp
network=$(ifconfig | grep 255.255.0.0 | awk '{print $2}' | cut -d '.' -f1-3)
network="$network.*"
echo "[workers]" > inventory
nmap -sP $network | grep worker | awk '{print $6}' | cut -d ')' -f1 | cut -d '(' -f2 >> inventory
master=$(ifconfig | grep 255.255.0.0 | awk '{print $2}')
echo -e "\n[all_hosts]" >> inventory
echo $master >> inventory
nmap -sP $network | grep worker | awk '{print $6}' | cut -d ')' -f1 | cut -d '(' -f2 >> inventory