改ansible的hosts文件
# vim /etc/ansible/hosts
[test]
192.168.213.12
192.168.213.13
[test:vars]
ansible_ssh_user="root"
ansible_ssh_pass="88888888"
改ansible.cfg的host_key_checking = False
创建push-ssh.yaml
---
- hosts:test
remote_user: root
tasks:
- authorized_key:
user: root
key: "{{ lookup('file', '/root/.ssh/id_rsa.pub') }}"
完毕!