在線上的環境中,服務端的ssh會有進行變更的情況
例如:有些服務器的ssh端口號是 34567 等情況,那么該如何配置呢?
編輯 /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命令即可,示例如下:
ansible servers -m shell -a "df -h | grep dev"