17 lines
437 B
YAML
17 lines
437 B
YAML
---
|
|
- name: Ensure hostname set
|
|
hostname:
|
|
name: "{{ inventory_hostname }}"
|
|
when: not inventory_hostname|trim is match('(\d{1,3}\.){3}\d{1,3}')
|
|
become: yes
|
|
register: hostname_set
|
|
|
|
- name: Reboot host and wait for it to restart
|
|
reboot:
|
|
msg: "Reboot initiated by Ansible"
|
|
connect_timeout: 5
|
|
reboot_timeout: 600
|
|
pre_reboot_delay: 0
|
|
post_reboot_delay: 30
|
|
test_command: whoami
|
|
when: hostname_set.changed |