win_ansible_role_base_setup/tasks/hostname.yml
2022-12-28 17:28:38 +01:00

21 lines
581 B
YAML

---
- 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:
pre_reboot_delay: 15
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
tags: skip_ansible_lint
when:
- res.reboot_required | bool
- not win_base_init__allow_reboot | bool