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

Manages local Windows computer name

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

Authors: Ripon Banik (@riponbanik)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.27

Description

Manages local Windows computer name.

A reboot is required for the computer name to take effect.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Change the hostname to sample-hostname
  win_hostname:
    name: sample-hostname
  register: res
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Reboot
  win_reboot:
  when: res.reboot_required

Inputs

    
name:
    description:
    - The hostname to set for the computer.
    required: true
    type: str

Outputs

old_name:
  description: The original hostname that was set before it was changed.
  returned: always
  sample: old_hostname
  type: str
reboot_required:
  description: Whether a reboot is required to complete the hostname change.
  returned: always
  sample: true
  type: bool

See also