dellemc.enterprise_sonic.sonic_ntp 模块 – 管理 SONiC 上的 NTP 配置。

注意

此模块是 dellemc.enterprise_sonic 集合(版本 2.5.1)的一部分。

如果您正在使用 ansible 包,您可能已经安装了这个集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install dellemc.enterprise_sonic

要在 playbook 中使用它,请指定:dellemc.enterprise_sonic.sonic_ntp

dellemc.enterprise_sonic 2.0.0 中的新增功能

概要

  • 此模块为运行 SONiC 的设备提供 NTP 的配置管理。

参数

参数

注释

config

字典

指定 NTP 相关配置。

enable_ntp_auth

布尔值

启用或禁用 NTP 身份验证。

选择

  • false

  • true

ntp_keys

列表 / 元素=字典

NTP 身份验证密钥的列表。

encrypted

布尔值

NTP 身份验证 key_value 已加密。

无法删除 encrypted。

当“state”为“merged”时,需要“encrypted”。

选择

  • false

  • true

key_id

整数 / 必需

NTP 身份验证密钥标识符。

key_type

字符串

NTP 身份验证密钥类型。

无法删除 key_type。

当“state”为“merged”时,需要“key_type”。

选择

  • "NTP_AUTH_SHA1"

  • "NTP_AUTH_MD5"

  • "NTP_AUTH_SHA2_256"

key_value

字符串

NTP 身份验证密钥值。

无法删除 key_value。

当“state”为“merged”时,需要“key_value”。

servers

列表 / 元素=字典

NTP 服务器列表。

minpoll 和 maxpoll 需要一起配置。

address

字符串 / 必需

NTP 服务器的 IPv4/IPv6 地址或主机名。

key_id

key_id

整数

服务器使用的 NTP 身份验证密钥。

无法删除 Key_id。

key_id

maxpoll

轮询 NTP 服务器的最大轮询间隔。

无法删除 maxpoll。

key_id

minpoll

轮询 NTP 服务器的最小轮询间隔。

无法删除 minpoll。

布尔值

prefer

指示是否应首选此服务器。

选择

  • false

  • true

无法删除 prefer。

source_interfaces

列表 / 元素=字符串

NTP 源接口名称列表。

trusted_keys

列表 / 元素=整数

受信任的 NTP 身份验证密钥列表。

字符串

vrf

启用 NTP 的 VRF 名称。

字符串

state

选择

  • 模块完成后配置的状态。

  • "merged" ← (默认)

  • "replaced"

  • "overridden"

"deleted"

注意

支持 check_mode

# Using deleted
#
# Before state:
# -------------
#
#sonic# show ntp server
#----------------------------------------------------------------------------
#NTP Servers                     minpoll maxpoll Prefer Authentication key ID
#----------------------------------------------------------------------------
#10.11.0.1                       6       10      False
#10.11.0.2                       5       9       False
#dell.com                        6       9       False
#dell.org                        7       10      True
#
- name: Delete NTP server configuration
  sonic_ntp:
    config:
      servers:
        - address: 10.11.0.2
        - address: dell.org
    state: deleted

# After state:
# ------------
#
#sonic# show ntp server
#----------------------------------------------------------------------------
#NTP Servers                     minpoll maxpoll Prefer Authentication key ID
#----------------------------------------------------------------------------
#10.11.0.1                       6       10      False
#dell.com                        6       9       False
#
#
# Using deleted
#
# Before state:
# -------------
#
#sonic# show ntp global
#----------------------------------------------
#NTP Global Configuration
#----------------------------------------------
#NTP source-interfaces:  Ethernet0, Ethernet4, Ethernet8, Ethernet16
#
- name: Delete NTP source-interface configuration
  sonic_ntp:
    config:
      source_interfaces:
        - Ethernet8
        - Ethernet16
    state: deleted

# After state:
# ------------
#
#sonic# show ntp global
#----------------------------------------------
#NTP Global Configuration
#----------------------------------------------
#NTP source-interfaces:  Ethernet0, Ethernet4
#
#
# Using deleted
#
# Before state:
# -------------
#
#sonic# show running-configuration | grep ntp
#ntp authentication-key 8 sha1 U2FsdGVkX1/NpJrdOeyMeUHEkSohY6azY9VwbAqXRTY= encrypted
#ntp authentication-key 10 md5 U2FsdGVkX1/Gxds/5pscCvIKbVngGaKka4SQineS51Y= encrypted
#ntp authentication-key 20 sha2-256 U2FsdGVkX1/eAzKj1teKhYWD7tnzOsYOijGeFAT0rKM= encrypted
#
- name: Delete NTP key configuration
  sonic_ntp:
    config:
      ntp_keys:
        - key_id: 10
        - key_id: 20
    state: deleted
#
# After state:
# ------------
#
#sonic# show running-configuration | grep ntp
#ntp authentication-key 8 sha1 U2FsdGVkX1/NpJrdOeyMeUHEkSohY6azY9VwbAqXRTY= encrypted
#
#
# Using merged
#
# Before state:
# -------------
#
#sonic# show ntp server
#----------------------------------------------------------------------------
#NTP Servers                     minpoll maxpoll Prefer Authentication key ID
#----------------------------------------------------------------------------
#10.11.0.1                       6       10      False
#dell.com                        6       9       False
#
- name: Merge NTP server configuration
  sonic_ntp:
    config:
      servers:
        - address: 10.11.0.2
          minpoll: 5
        - address: dell.org
          minpoll: 7
          maxpoll: 10
          prefer: true
    state: merged

# After state:
# ------------
#
#sonic# show ntp server
#----------------------------------------------------------------------------
#NTP Servers                     minpoll maxpoll Prefer Authentication key ID
#----------------------------------------------------------------------------
#10.11.0.1                       6       10      Flase
#10.11.0.2                       5       10      Flase
#dell.com                        6       9       Flase
#dell.org                        7       10      True
#
#
# Using merged
#
# Before state:
# -------------
#
#sonic# show ntp global
#----------------------------------------------
#NTP Global Configuration
#----------------------------------------------
#NTP source-interfaces:  Ethernet0, Ethernet4
#
- name: Merge NTP source-interface configuration
  sonic_ntp:
    config:
      source_interfaces:
        - Ethernet8
        - Ethernet16
    state: merged

# After state:
# ------------
#
#sonic# show ntp global
#----------------------------------------------
#NTP Global Configuration
#----------------------------------------------
#NTP source-interfaces:  Ethernet0, Ethernet4, Ethernet8, Ethernet16
#
#
# Using merged
#
# Before state:
# -------------
#
#sonic# show running-configuration | grep ntp
#ntp authentication-key 8 sha1 U2FsdGVkX1/NpJrdOeyMeUHEkSohY6azY9VwbAqXRTY= encrypted
#
- name: Merge NTP key configuration
  sonic_ntp:
    config:
      ntp_keys:
        - key_id: 10
          key_type: NTP_AUTH_MD5
          key_value: dellemc10
          encrypted: false
        - key_id: 20
          key_type: NTP_AUTH_SHA2_256
          key_value: dellemc20
          encrypted: false
    state: merged
#
# After state:
# ------------
#
#sonic# show running-configuration | grep ntp
#ntp authentication-key 8 sha1 U2FsdGVkX1/NpJrdOeyMeUHEkSohY6azY9VwbAqXRTY= encrypted
#ntp authentication-key 10 md5 U2FsdGVkX1/Gxds/5pscCvIKbVngGaKka4SQineS51Y= encrypted
#ntp authentication-key 20 sha2-256 U2FsdGVkX1/eAzKj1teKhYWD7tnzOsYOijGeFAT0rKM= encrypted
#
# Using replaced
#
# Before state:
# -------------
#
#sonic# show ntp server
#----------------------------------------------------------------------------
#NTP Servers                     minpoll maxpoll Prefer Authentication key ID
#----------------------------------------------------------------------------
#10.11.0.1                       6       10      False
#dell.com                        6       9       False
#
- name: Replace NTP server configuration
  sonic_ntp:
    config:
      servers:
        - address: 10.11.0.2
          minpoll: 5
          maxpoll: 9
        - address: dell.com
          minpoll: 7
          maxpoll: 10
          prefer: true
    state: replaced
#
# After state:
# ------------
#
#sonic# show ntp server
#----------------------------------------------------------------------------
#NTP Servers                     minpoll maxpoll Prefer Authentication key ID
#----------------------------------------------------------------------------
#10.11.0.1                       6       10      False
#10.11.0.2                       5       9       False
#dell.com                        7       10      True
#
# Using overridden
#
# Before state:
# -------------
#
#sonic# show ntp server
#----------------------------------------------------------------------------
#NTP Servers                     minpoll maxpoll Prefer Authentication key ID
#----------------------------------------------------------------------------
#10.11.0.1                       6       10      False
#dell.com                        6       9       False
#
#sonic# show ntp global
#----------------------------------------------
#NTP Global Configuration
#----------------------------------------------
#NTP source-interfaces:  Ethernet0, Ethernet4
#
- name: Overridden NTP configuration
  sonic_ntp:
    config:
      servers:
        - address: 10.11.0.2
          minpoll: 5
        - address: dell.com
          minpoll: 7
          maxpoll: 10
          prefer: true
    state: overridden
#
# After state:
# ------------
#
# After state:
# ------------
#
#sonic# show ntp server
#----------------------------------------------------------------------------
#NTP Servers                     minpoll maxpoll Prefer Authentication key ID
#----------------------------------------------------------------------------
#10.11.0.2                       5       10      False
#dell.com                        7       10      True
#
#sonic# show ntp global
#

示例

返回值

常见的返回值记录在此处,以下是此模块独有的字段

描述

source_interfaces

after

生成的配置模块调用。

已返回: 当更改时

示例: ["返回的配置将始终与上面的参数格式相同。\n"]

source_interfaces

after(generated)

生成的配置模块调用。

已返回: 当更改时

已返回:check_mode

source_interfaces

before

模块调用之前的配置。

已返回: 当更改时

已返回: 始终

source_interfaces

commands

模块调用之前的配置。

推送到远程设备的命令集。

示例: ["命令 1", "命令 2", "命令 3"]