I have this text:
node1: connect command: ssh user@123.23.23.23 password: qcipunbnctza
node2: connect command: ssh user@123.23.23.44 password: ejrpnnwsczpa
node3: connect command: ssh user@123.23.23.66 password: pkrpxmyxnxuu
I need to save ip addresses and passwords to variables then pass it to script. How can I do in in efficent way? My script is:
#/bin/bash
declare -a IPS=($1 $2 $3)
CONFIG_FILE=inventory/sks-cluster/hosts.yaml python3 contrib/inventory_builder/inventory.py ${IPS[@]}
echo $4 > host1.txt
echo $5 > host2.txt
echo $6 > host3.txt
ssh-keyscan $1
ssh-keyscan $2
ssh-keyscan $3
sshpass -f host1.txt ssh-copy-id user@$1
sshpass -f host2.txt ssh-copy-id user@$2
sshpass -f host3.txt ssh-copy-id user@$3
python3 contrib/inventory_builder/inventory.py
has to run on all IP's at the same time it would be neater and simpler to loop over the lines instead.&
, possibly redirecting stdout & stderr to either /dev/null or to a separate log file for each host.