2021-12-20 19:10:07 +01:00
|
|
|
---
|
|
|
|
- name: "Change the hostname to {{ inventory_hostname }}"
|
|
|
|
ansible.windows.win_hostname:
|
|
|
|
name: "{{ inventory_hostname }}"
|
|
|
|
register: res
|
|
|
|
|
2021-12-20 22:55:07 +01:00
|
|
|
- name: host is rebooting in 15 sec!!
|
2021-12-20 19:10:07 +01:00
|
|
|
ansible.windows.win_reboot:
|
2022-01-01 21:19:59 +01:00
|
|
|
pre_reboot_delay: 15
|
2022-01-02 19:04:13 +01:00
|
|
|
when:
|
|
|
|
- res.reboot_required | bool
|
|
|
|
- win_base_init__allow_reboot | bool
|
|
|
|
|
|
|
|
- name: host is rebooting in 15 sec!!
|
|
|
|
ansible.builtin.fail:
|
|
|
|
msg: "Hostname changed. Please reboot to apply changes!"
|
|
|
|
ignore_errors: true
|
|
|
|
when:
|
|
|
|
- res.reboot_required | bool
|
|
|
|
- not win_base_init__allow_reboot | bool
|