ansible.fftdf.supernode/roles/00-system-set-hostname/tasks/main.yml

17 lines
437 B
YAML
Raw Normal View History

2022-05-05 18:03:54 +00:00
---
- 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