k8s 之ansible (十)

1.hdss7-200创建密钥

[root@hdss7-200 ~]# ssh-keygen -t dsa 一路回车

分发脚本

#!/bin/bash
. /etc/rc.d/init.d/functions

m ~/.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

2.安装ansible 

[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'

 本来要搞ansible-Tower的,由于物理内存不足,已经给了1.3G还是不足 不搞了不搞了 机器都快卡死了

原文地址:https://www.cnblogs.com/sseban/p/13061237.html