- name: Execute command on Windows host using WinRM
hosts: windows.host.com
gather_facts: no
vars:
ansible_connection: winrm
ansible_user: your_windows_username
ansible_password: your_windows_password
tasks:
- name: Run command on Windows host
win_command: command_to_execute
注意:WinRM 协议需要 Windows 主机的防火墙开放端口 5985(HTTP)和 5986(HTTPS)。