ansible ---- 批量部署证书文件

批量部署证书文件,给所有主机部署密钥

1)创建密钥

[root@ansible aaa]# cd /root/.ssh/
[root@ansible .ssh]# vi /etc/ansible/hosts
[web]
web1
web2
[db]
db[1:2]
[other]
cache

[root@ansible .ssh]# ansible all -m ping  //直接ping会报错

[root@ansible .ssh]# ssh-keygen -t rsa -b 2048 -N ''  //创建密钥

2)给所有主机部署密钥

[root@ansible .ssh]# ansible all -m authorized_key -a "user=root exclusive=true manage_dir=true key='$(< /root/.ssh/id_rsa.pub)'" -k
SSH password:        //输入密码


[root@ansible .ssh]# ansible all -m ping  //成功

你可能感兴趣的:(云计算)