asnible.builtin.hostname kinda misleading
Author: ShahriarKhCreated Sep 28, 2026Updated Sep 28, 2026
Labelsmoduleneeds_triagedocsaffects_2.21
Summary
This note in hostname module docs is kinda misleading:
This module does NOT modify /etc/hosts. You need to modify it yourself using other modules such as ansible.builtin.template or ansible.builtin.replace.
I used the module for an alpine vm, and after restarting the machine, I noticed that /etc/hosts is actually changed and includes the new hostname (which is desired behavior).
Issue Type
Documentation Report
Component Name
ansible.builtin.hostname
Ansible Version
$ ansible --version
ansible [core 2.21.0]
config file = /opt/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.14/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.14.5 (main, Jun 9 2026, 08:17:28) [GCC 15.2.0] (/usr/bin/python3)
jinja version = 3.1.6
pyyaml version = 6.0.3 (with libyaml v0.2.5)Configuration
CONFIG_FILE() = /opt/ansible/ansible.cfg
DEFAULT_HOST_LIST(/opt/ansible/ansible.cfg) = ['/opt/ansible/inventory/hosts.yml']
DEFAULT_PRIVATE_KEY_FILE(/opt/ansible/ansible.cfg) = /root/.ssh/ansible
DEFAULT_ROLES_PATH(/opt/ansible/ansible.cfg) = ['/opt/ansible/roles']
INJECT_INVOCATION(/opt/ansible/ansible.cfg) = False
INTERPRETER_PYTHON(/opt/ansible/ansible.cfg) = auto_silent
GALAXY_SERVERS:
CONNECTION:
==========
ssh:
___
private_key_file(/opt/ansible/ansible.cfg) = /root/.ssh/ansible
~
~
~
~
~
~
~
~
~
~
~
~
~OS / Environment
Windows 10 (running ansible on docker)
Additional Information
Maybe add more details?
Code of Conduct
- I agree to follow the Ansible Code of Conduct
Source: ansible/ansible