2024-10-26 16:23:45 +02:00
|
|
|
---
|
|
|
|
|
- name: Set the hostname
|
|
|
|
|
ansible.builtin.hostname:
|
|
|
|
|
name: "{{ inventory_hostname }}"
|
|
|
|
|
|
|
|
|
|
- name: Replace double home with hostname (if present)
|
|
|
|
|
ansible.builtin.replace:
|
|
|
|
|
path: /etc/hosts
|
|
|
|
|
regexp: 127\.0\.1\.1
|
|
|
|
|
replace: "{{ ansible_host }} {{ inventory_hostname }}"
|
2025-08-30 21:30:57 +02:00
|
|
|
vars:
|
|
|
|
|
ansible_remote_tmp: /tmp # Prevent warnings for auto-created tmp dir
|
2024-10-26 16:23:45 +02:00
|
|
|
|
|
|
|
|
- name: Ensure at least one full hostname entry is present
|
|
|
|
|
ansible.builtin.lineinfile:
|
|
|
|
|
path: /etc/hosts
|
|
|
|
|
regexp: "{{ ansible_host }}.*{{ inventory_hostname }}"
|
|
|
|
|
line: "{{ ansible_host }} {{ inventory_hostname }}"
|
|
|
|
|
state: present
|
2025-09-01 16:30:14 +02:00
|
|
|
vars:
|
|
|
|
|
ansible_remote_tmp: /tmp # Prevent warnings for auto-created tmp dir
|