.. _vyos.rest.vyos_hostname_module: *********************** vyos.rest.vyos_hostname *********************** **Manage the system hostname on a VyOS device via the REST API.** Version added: 1.0.0 .. contents:: :local: :depth: 1 Synopsis -------- - Manages the ``set system host-name`` configuration on a VyOS device using the HTTPS REST API. - Mirrors the behaviour of ``vyos.vyos.vyos_hostname`` but uses the HTTP API instead of SSH/network_cli. - The states ``replaced``, ``overridden`` behave identically to ``merged`` for this single-value resource. Requirements ------------ The below requirements are needed on the host that executes this module. - VyOS 1.3+ Parameters ---------- .. raw:: html
Parameter Choices/Defaults Comments
api_key
string
API key configured on the device.
config
dictionary
Hostname configuration.
hostname
string / required
System hostname (max 63 characters, no underscores).
hostname
string
IP address or FQDN of the VyOS device (not needed with httpapi inventory).
port
integer
Default:
443
HTTPS port for the REST API.
running_config
string
Used only with state parsed.
The value should be the output of show configuration commands | grep host-name from the device.
state
string
    Choices:
  • merged ←
  • replaced
  • overridden
  • deleted
  • gathered
  • rendered
  • parsed
merged - Ensure the hostname is set to the value in config.
replaced - Identical to merged for this single-value resource.
overridden - Identical to merged for this single-value resource.
deleted - Remove the configured hostname (resets to default).
gathered - Read the current hostname from the device and return it in gathered without making changes.
rendered - Return the CLI commands for the given config without connecting to the device.
parsed - Parse the running_config string and return structured data without connecting to the device.
timeout
integer
Default:
30
Request timeout in seconds.
verify_ssl
boolean
    Choices:
  • no ←
  • yes
Validate the device's TLS certificate.

See Also -------- .. seealso:: :ref:`vyos.vyos.vyos_hostname_module` The official documentation on the **vyos.vyos.vyos_hostname** module. Examples -------- .. code-block:: yaml - name: Set hostname vyos.rest.vyos_hostname: config: hostname: vyos-core-01 state: merged - name: Replace hostname vyos.rest.vyos_hostname: config: hostname: vyos-core-02 state: replaced - name: Gather current hostname vyos.rest.vyos_hostname: state: gathered register: result - name: Delete hostname configuration vyos.rest.vyos_hostname: state: deleted - name: Render commands without connecting vyos.rest.vyos_hostname: config: hostname: vyos-core-01 state: rendered - name: Parse running config vyos.rest.vyos_hostname: running_config: "set system host-name 'vyos'" state: parsed Return Values ------------- Common return values are documented `here `_, the following are the fields unique to this module: .. raw:: html
Key Returned Description
after
dictionary
when changed
Configuration on the device after the module ran.

before
dictionary
always
Configuration on the device before the module ran.

commands
list
always
REST API commands dispatched.

gathered
dictionary
when state is gathered
Hostname read from the device (state=gathered only).

parsed
dictionary
when state is parsed
Structured data parsed from running_config (state=parsed only).

rendered
list
when state is rendered
CLI commands for the provided config (state=rendered only).



Status ------ Authors ~~~~~~~ - VyOS Community (@vyos)