1、服务端安装server
yum install ansible -y yum install tree
2、修改/etc/ansible/hosts
[tomcat] 192.168.1.8 ansible_user=root ansible_ssh_pass="123456"
3、修改/etc/ansible/ansible.cfg
host_key_checking = False
4、创建push.ssh.yaml
# Using alternate directory locations: - hosts: tomcat user: root tasks: - name: ssh-copy authorized_key: user=root key="{{ lookup(‘file‘, ‘/root/.ssh/id_rsa.pub‘) }}" tags: - sshkey
5、执行
ansible-playbook push.ssh.ymal
6、基本操作
批量执行shell ansible all -m shell -a "echo 345678|passwd --stdin" 批量copy ansible all -m copy -a "src=/etc/ansible/soft/111.tar.gz dest=/root/"
原文:https://www.cnblogs.com/allen-GC/p/11312642.html