--- - name: "Change the hostname to {{ inventory_hostname }}" ansible.windows.win_hostname: name: "{{ inventory_hostname }}" register: res - name: host is rebooting in 15 sec!! ansible.windows.win_reboot: re_reboot_delay: 15 when: res.reboot_required