[root@hdss7-200 ~]# ssh-keygen -t dsa 一路回车
分发脚本
#!/bin/bash
. /etc/rc.d/init.d/functions
\rm ~/.ssh/id_rsa* -f
ssh-keygen -t rsa -f ~/.ssh/id_rsa -N "" -q
for ip in 11 12 12 22
do
sshpass -p123456 ssh-copy-id -i ~/.ssh/id_rsa.pub " root@192.168.12.$ip -o StrictHostKeyChecking=no " &>/dev/null
if [ $? -eq 0 ];then
action "fenfa 192.168.12.$ip" /bin/true
else
action "fenfa 192.168.12.$ip" /bin/false
fi
echo ""
done
[root@hdss7-200 ~]# yum install ansible -y
[root@hdss7-200 ~]# cat /etc/ansible/hosts
[k8s]
192.168.12.11
192.168.12.12
192.168.12.21
192.168.12.22
[root@hdss7-200 ~]# ansible k8s -a ‘w‘
原文:https://www.cnblogs.com/sseban/p/13061237.html