ansible.builtin.hostname (v2.9.27) — module

Manage hostname

| "added in version" 1.4 of ansible.builtin"

Authors: Adrian Likins (@alikins), Hideki Saito (@saito-hideki)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.27

Description

Set system's hostname, supports most OSs/Distributions, including those using systemd.

Note, this module does *NOT* modify C(/etc/hosts). You need to modify it yourself using other modules like template or replace.

Windows, HP-UX and AIX are not currently supported.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- hostname:
    name: web01

Inputs

    
use:
    choices:
    - generic
    - debian
    - sles
    - redhat
    - alpine
    - systemd
    - openrc
    - openbsd
    - solaris
    - freebsd
    description:
    - Which strategy to use to update the hostname.
    - If not set we try to autodetect, but this can be problematic, specially with containers
      as they can present misleading information.
    version_added: '2.9'
    version_added_collection: ansible.builtin

name:
    description:
    - Name of the host
    required: true