Skip to content

Latest commit

 

History

History
392 lines (350 loc) · 15.2 KB

arista.eos.eos_hostname_module.rst

File metadata and controls

392 lines (350 loc) · 15.2 KB

arista.eos.eos_hostname

Manages hostname resource module

Version added: 4.1.0

  • This module configures and manages the attribute of hostname on Arista EOS platforms.
Parameter Choices/Defaults Comments
config
dictionary
A dictionary of hostname options
hostname
string
The system's hostname
running_config
string
This option is used only with state parsed.
The value of this option should be the output received from the EOS device by executing the command show running-config | section hostname.
The state parsed reads the configuration from running_config option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the parsed key within the result.
state
string
    Choices:
  • deleted
  • merged ←
  • overridden
  • replaced
  • gathered
  • rendered
  • parsed
The state the configuration should be left in.
The states rendered, gathered and parsed does not perform any change on the device.
The state rendered will transform the configuration in config option to platform specific CLI commands which will be returned in the rendered key within the result. For state rendered active connection to remote host is not required.
The states merged, replaced and overridden have identical behaviour for this module.
The state gathered will fetch the running configuration from device and transform it into structured data in the format as per the resource module argspec and the value is returned in the gathered key within the result.
The state parsed reads the configuration from running_config option and transforms it into JSON format as per the resource module parameters and the value is returned in the parsed key within the result. The value of running_config option should be the same format as the output of command show running-config | section ^hostname executed on device. For state parsed active connection to remote host is not required.

Note

  • Tested against Arista EOS 4.24.60M
  • This module works with connection network_cli. See the EOS Platform Options.
# Using state: merged
# Before state:
# -------------
# test#show running-config | section ^hostname
# hostname eos
# Merged play:
# ------------
- name: Apply the provided configuration
  arista.eos.eos_hostname:
    config:
      hostname: eos
    state: merged
# Commands Fired:
# ---------------
# "commands": [
#         "hostname eos",
# ],
# After state:
# ------------
# test#show running-config | section ^hostname
# hostname eos


# Using state: deleted
# Before state:
# -------------
# test#show running-config | section ^hostname
# hostname eosTest
# Deleted play:
# -------------
- name: Remove all existing configuration
  arista.eos.eos_hostname:
    state: deleted
# Commands Fired:
# ---------------
# "commands": [
#     "no hostname eosTest",
# ],
# After state:
# ------------
# test#show running-config | section ^hostname
# hostname eos


# Using state: overridden
# Before state:
# -------------
# test#show running-config | section ^hostname
# hostname eos
# Overridden play:
# ----------------
- name: Override commands with provided configuration
  arista.eos.eos_hostname:
    config:
      hostname: eosTest
    state: overridden
# Commands Fired:
# ---------------
# "commands": [
#       "hostname eosTest",
#     ],
# After state:
# ------------
# test#show running-config | section ^hostname
# hostname eosTest


# Using state: replaced
# Before state:
# -------------
# test#show running-config | section ^hostname
# hostname eosTest
# Replaced play:
# --------------
- name: Replace commands with provided configuration
  arista.eos.eos_hostname:
    config:
      hostname: eosTest
    state: replaced
# Commands Fired:
# ---------------
# "commands": [],
# After state:
# ------------
# test#show running-config | section ^hostname
# hostname eosTest

# Using state: gathered
# Before state:
# -------------
# test#show running-config | section ^hostname
# hostname eosTest
# Gathered play:
# --------------
- name: Gather listed hostname config
  arista.eos.eos_hostname:
    state: gathered
# Module Execution Result:
# ------------------------
#   "gathered": {
#      "hostname": "eosTest"
#     },

# Using state: rendered
# Rendered play:
# --------------
- name: Render the commands for provided configuration
  arista.eos.eos_hostname:
    config:
      hostname: eosTest
    state: rendered
# Module Execution Result:
# ------------------------
# "rendered": [
#     "hostname eosTest",
# ]

# Using state: parsed
# File: parsed.cfg
# ----------------
# hostname eosTest
# Parsed play:
# ------------
- name: Parse the provided configuration with the existing running configuration
  arista.eos.eos_hostname:
    running_config: "{{ lookup('file', 'parsed.cfg') }}"
    state: parsed
# Module Execution Result:
# ------------------------
#  "parsed": {
#     "hostname": "eosTest"
# }

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
after
dictionary
when changed
The resulting configuration after module execution.

Sample:
This output will always be in the same format as the module argspec.
before
dictionary
when state is merged, replaced, overridden, deleted or purged
The configuration prior to the module execution.

Sample:
This output will always be in the same format as the module argspec.
commands
list
when state is merged, replaced, overridden, deleted or purged
The set of commands pushed to the remote device.

Sample:
['hostname eost_test']
gathered
list
when state is gathered
Facts about the network resource gathered from the remote device as structured data.

Sample:
This output will always be in the same format as the module argspec.
parsed
list
when state is parsed
The device native config provided in running_config option parsed into structured data as per module argspec.

Sample:
This output will always be in the same format as the module argspec.
rendered
list
when state is rendered
The provided configuration in the task rendered in device-native format (offline).

Sample:
['hostname eost_test']


Authors

  • Gomathi Selvi Srinivasan (@GomathiselviS)