• 服务器:
    • 192.168.80.1 node1
    • 192.168.80.2 node2
    • 192.168.80.3 node3

修改/etc/hosts

 

192.168.80.1 node1
192.168.80.2 node2
192.168.80.3 node3

修改ansible hosts

 

vim /etc/ansible/hosts
[k8s]
k8smaster ansible_ssh_user=root ansible_ssh_port=22 ansible_ssh_pass=james
k8snode1 ansible_ssh_user=root ansible_ssh_port=22 ansible_ssh_pass=james
k8snode2 ansible_ssh_user=root ansible_ssh_port=22 ansible_ssh_pass=james

修改/etc/ansible/ansible.cfg

 

sed -i 's/.*\(host_key_checking\)/\1/' /etc/ansible/ansible.cfg
# 去掉配置文件中的注释
#host_key_checking = False
host_key_checking = False

最后结果

 

# ansible  all -m ping 
node1 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
node2 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
node3 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐