arista.eos.eos_hostname 模块 – 管理主机名资源模块
注意
此模块是 arista.eos 集合 (版本 10.0.1) 的一部分。
如果您使用的是 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install arista.eos。
要在 playbook 中使用它,请指定:arista.eos.eos_hostname。
arista.eos 4.1.0 中的新增功能
概要
- 此模块配置和管理 Arista EOS 平台上主机名的属性。 
参数
| 参数 | 注释 | 
|---|---|
| 主机名选项的字典 | |
| 系统的 hostname | |
| 此选项仅在 state 为 *parsed* 时使用。 此选项的值应为通过执行命令 **show running-config | section hostname** 从 EOS 设备接收到的输出。 state 为 *parsed* 时,将从  | |
| 配置应保留的状态。 状态 *rendered*、*gathered* 和 *parsed* 不会对设备进行任何更改。 状态 *rendered* 将  对于此模块,状态 *merged*、*replaced* 和 *overridden* 的行为相同。 状态 *gathered* 将获取设备的运行配置,并根据资源模块 argspec 将其转换为结构化数据,并将该值返回在结果中的 *gathered* 键中。 状态 *parsed* 从  选项 
 | 
备注
注意
- 针对 Arista EOS 4.24.60M 进行测试 
- 此模块适用于连接 - network_cli。请参阅 EOS 平台选项。
示例
# 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"
# }
返回值
公共返回值已在此处记录 此处,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| 模块执行后的结果配置。 返回:已更改时 示例:  | |
| 模块执行之前的配置。 返回:当 *state* 为  示例:  | |
| 推送到远程设备的命令集。 返回:当 *state* 为  示例:  | |
| 从远程设备收集的网络资源事实,作为结构化数据。 返回:当 *state* 为  示例:  | |
| 根据模块 argspec 将 *running_config* 选项中提供的设备原生配置解析为结构化数据。 返回:当 *state* 为  示例:  | |
| 任务中提供的配置以设备原生格式呈现(离线)。 返回:当 *state* 为  示例:  | 
