安装ansible后创建ansible.cfg
[defaults]
forks = 60
inventory = ~/ansible/inventory
remote_user = test
host_key_checking = False
[privilege_escalation]
become=True
become_method=sudo
become_user=root
become_ask_pass=False
inventory文件添加
[test]
192.168.10.[10:100]
[test:vars]
ansible_ssh_user = test
ansible_ssh_port = 2030
ansible_ssh_pass = test
ansible_become_pass = test
ssh免密登录
ssh-keygen
ssh-copy-id root@192.168.135.102