ansible / ansible.builtin / v2.16.0 / module / hostname Manage hostname | "added in version" 1.4 of ansible.builtin" Authors: Adrian Likins (@alikins), Hideki Saito (@saito-hideki)ansible.builtin.hostname (v2.16.0) — module
pip
Install with pip install ansible-core==2.16.0
Set system's hostname. Supports most OSs/Distributions including those using C(systemd).
Windows, HP-UX, and AIX are not currently supported.
- name: Set a hostname ansible.builtin.hostname: name: web01
- name: Set a hostname specifying strategy ansible.builtin.hostname: name: web01 use: systemd
use: choices: - alpine - debian - freebsd - generic - macos - macosx - darwin - openbsd - openrc - redhat - sles - solaris - systemd description: - Which strategy to use to update the hostname. - If not set we try to autodetect, but this can be problematic, particularly with containers as they can present misleading information. - Note that 'systemd' should be specified for RHEL/EL/CentOS 7+. Older distributions should use 'redhat'. type: str version_added: '2.9' version_added_collection: ansible.builtin name: description: - Name of the host. - If the value is a fully qualified domain name that does not resolve from the given host, this will cause the module to hang for a few seconds while waiting for the name resolution attempt to timeout. required: true type: str