init
This commit is contained in:
20
ansible/roles/node/change_hostname/main.yml
Normal file
20
ansible/roles/node/change_hostname/main.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
- name: Set hostname
|
||||
ansible.builtin.hostname:
|
||||
name: "{{ hostname }}"
|
||||
|
||||
- name: Ensure /etc/hosts has proper hostname entry
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/hosts
|
||||
regexp: "^127\\.0\\.1\\.1"
|
||||
line: "127.0.1.1 {{ hostname }}"
|
||||
create: yes
|
||||
backup: yes
|
||||
|
||||
- name: Reboot system
|
||||
ansible.builtin.reboot:
|
||||
msg: "Rebooting after hostname change"
|
||||
connect_timeout: 5
|
||||
reboot_timeout: 300
|
||||
pre_reboot_delay: 0
|
||||
post_reboot_delay: 10
|
||||
Reference in New Issue
Block a user