Hostname Ansible Role¶
An Ansible role to manage the system hostname and a basic /etc/hosts mapping on Debian, Ubuntu, and Fedora systems.
Features¶
- Persist the short hostname to
/etc/hostname - Optionally ensure a dedicated loopback mapping for FQDN and short hostname in
/etc/hosts - Works across Debian, Ubuntu, Fedora, and containerized test environments
Installation¶
roles:
- name: hostname
src: https://gitlab.com/niclas-zone/tools/ansible/roles/hostname.git
version: 1.0.0
scm: git
Role Variables¶
| Variable | Default Value | Type | Description |
|---|---|---|---|
hostname |
{{ inventory_hostname_short }} |
string | Short hostname written to /etc/hostname |
hostname_fqdn |
null |
string | Optional fully qualified domain name used before the short hostname in /etc/hosts |
update_etc_hosts |
true |
boolean | Whether to update /etc/hosts with a loopback mapping |
etc_hosts_ipv4_loopback |
"127.0.1.1" |
string | IPv4 loopback address used for the managed hostname mapping |
Testing¶
Run Molecule against a specific platform:
Supported Molecule platforms in this role:
debian12debian13ubuntu2204ubuntu2404fedora43fedora44