-v #显示过程 vvv详细 vvvv开启debug模式 -i #指定主机清单的路径,默认是在/etc/ansible/hosts -m #指定模块,默认command模块 -a #指定模块的参数,动作 -k #输入ssh的密码,首次使用可以使用 -C #模拟测试,但不会真的去执行 -T #执行命令超时时间,超过这个时间就断开 -f #并发数高 vim /etc/ansible/ansible.cfg #这个是ansible配置文件 # host_key_checking = False #把这行注释去掉,就是跳过指纹验证 ansible -i hosts all -m shell -a "ls" -i hosts 指定主机ip -m 指定模块 -a 指定命令 #####ansible hosts文件 [web] #指定主机组 10.0.0.103 #指定组内IP 10.0.0.104 [all:vars] #指定密码变量 ansible_ssh_user=root #指定榕湖 ansible_ssh_pass=1 #指定密码 ansible_ssh_port=22 #指定端口 单台指定密码 [web] 10.0.0.103 ansible_ssh_user=root ansible_ssh_pass=1 ansible_ssh_port=22



