ansible.windows.win_hostname (2.3.0) — module

Manages local Windows computer name

Authors: Ripon Banik (@riponbanik)

Install collection

Install with ansible-galaxy collection install ansible.windows:==2.3.0


Add to requirements.yml

  collections:
    - name: ansible.windows
      version: 2.3.0

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
  ansible.windows.win_hostname:
    name: sample-hostname
  register: res
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Reboot
  ansible.windows.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