24 lines
712 B
YAML
24 lines
712 B
YAML
# 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
|