例如:有些服务器的ssh端口号是 34567 等状况,那么该如何配置呢?shell
编辑 /etc/ansible/hosts
服务器
[servers] 192.168.0.11 ansible_ssh_user=root ansible_ssh_port=34567 192.168.0.12 ansible_ssh_user=root ansible_ssh_port=34567
配置完毕后,照常执行ansible命令便可,示例以下:ssh
ansible servers -m shell -a "df -h | grep dev"