Потратил пару часов, чтобы найти ответ на тот же вопрос :) Надеюсь, что ниже поможет:
- name: Set up static IP address
win_shell: "Get-NetIpAddress -InterfaceAlias 'Ethernet' | New-NetIpAddress -IpAddress 192.168.1.120 -PrefixLength 24 -DefaultGateway 192.168.1.1"
async: 100 # Using "fire-and-forget" asynchronous execution for this task, otherwise it will always fail and timeout
poll: 0
- name: Change ansible's ip address for each host
set_fact:
ansible_host: "192.168.1.120"
- name: Wait for the hosts network interface to come back up
local_action:
module: wait_for
host: "{{ ansible_host }}"
port: 5985
delay: 10
state: started
register: wait_result
- name: Create a test folder to celebrate success
win_file:
path: C:\itworks
state: directory