win_ansible_role_base_setup/tasks/hostname.yml

22 lines
581 B
YAML
Raw Normal View History

2021-12-20 19:10:07 +01:00
---
- name: "Change the hostname to {{ inventory_hostname }}"
ansible.windows.win_hostname:
name: "{{ inventory_hostname }}"
register: res
2022-12-28 17:28:38 +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
when:
- res.reboot_required | bool
- win_base_init__allow_reboot | bool
2022-12-28 17:28:38 +01:00
- name: Host is rebooting in 15 sec!!
ansible.builtin.fail:
msg: "Hostname changed. Please reboot to apply changes!"
ignore_errors: true
2022-12-28 17:28:38 +01:00
tags: skip_ansible_lint
when:
- res.reboot_required | bool
- not win_base_init__allow_reboot | bool