Files

24 lines
712 B
YAML
Raw Permalink Normal View History

2026-09-09 16:50:19 -04:00
# code: language=ansible
- name: Add IPv4 address to /etc/hosts
ansible.builtin.lineinfile:
path: /etc/hosts
line: "{{ ipv4_address }} {{ inventory_hostname }} {{ inventory_hostname_short }}"
- name: Ensure IPv4 loopback exists in /etc/hosts
ansible.builtin.lineinfile:
path: /etc/hosts
line: "127.0.1.1 {{ inventory_hostname }} {{ inventory_hostname_short }}"
- name: Add IPv6 address to /etc/hosts
when:
- not (ipv4_only | default(false))
ansible.builtin.lineinfile:
path: /etc/hosts
line: "{{ ipv6_address }} {{ inventory_hostname }} {{ inventory_hostname_short }}"
- name: Set hostname
ansible.builtin.hostname:
name: "{{ inventory_hostname }}"
use: systemd