dellemc.enterprise_sonic.sonic_ntp (2.4.0) — module

Manage NTP configuration on SONiC.

| "added in version" 2.0.0 of dellemc.enterprise_sonic"

Authors: M. Zhang (@mingjunzhang2019)

Install collection

Install with ansible-galaxy collection install dellemc.enterprise_sonic:==2.4.0


Add to requirements.yml

  collections:
    - name: dellemc.enterprise_sonic
      version: 2.4.0

Description

This module provides configuration management of NTP for devices running SONiC.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
#
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
#
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
#
# 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

Inputs

    
state:
    choices:
    - merged
    - replaced
    - overridden
    - deleted
    default: merged
    description:
    - The state of the configuration after module completion.
    type: str

config:
    description:
    - Specifies NTP related configurations.
    suboptions:
      enable_ntp_auth:
        description:
        - Enable or disable NTP authentication.
        type: bool
      ntp_keys:
        description:
        - List of NTP authentication keys.
        elements: dict
        suboptions:
          encrypted:
            description:
            - NTP authentication key_value is encrypted.
            - encrypted can not be deleted.
            - When "state" is "merged", "encrypted" is required.
            type: bool
          key_id:
            description:
            - NTP authentication key identifier.
            required: true
            type: int
          key_type:
            choices:
            - NTP_AUTH_SHA1
            - NTP_AUTH_MD5
            - NTP_AUTH_SHA2_256
            description:
            - NTP authentication key type.
            - key_type can not be deleted.
            - When "state" is "merged", "key_type" is required.
            type: str
          key_value:
            description:
            - NTP authentication key value.
            - key_value can not be deleted.
            - When "state" is "merged", "key_value" is required.
            type: str
        type: list
      servers:
        description:
        - List of NTP servers.
        - minpoll and maxpoll are required to be configured together.
        elements: dict
        suboptions:
          address:
            description:
            - IPv4/IPv6 address or host name of NTP server.
            required: true
            type: str
          key_id:
            description:
            - NTP authentication key used by server.
            - Key_id can not be deleted.
            type: int
          maxpoll:
            description:
            - Maximum poll interval to poll NTP server.
            - maxpoll can not be deleted.
            type: int
          minpoll:
            description:
            - Minimum poll interval to poll NTP server.
            - minpoll can not be deleted.
            type: int
          prefer:
            description:
            - Indicates whether this server should be preferred.
            - prefer can not be deleted.
            type: bool
        type: list
      source_interfaces:
        description:
        - List of names of NTP source interfaces.
        elements: str
        type: list
      trusted_keys:
        description:
        - List of trusted NTP authentication keys.
        elements: int
        type: list
      vrf:
        description:
        - VRF name on which NTP is enabled.
        type: str
    type: dict

Outputs

after:
  description: The resulting configuration model invocation.
  returned: when changed
  sample: "The configuration returned will always be in the same format\n of the parameters\
    \ above.\n"
  type: list
after(generated):
  description: The generated configuration model invocation.
  returned: when C(check_mode)
  sample: "The configuration returned will always be in the same format\n of the parameters\
    \ above.\n"
  type: list
before:
  description: The configuration prior to the model invocation.
  returned: always
  sample: "The configuration returned will always be in the same format\n of the parameters\
    \ above.\n"
  type: list
commands:
  description: The set of commands pushed to the remote device.
  returned: always
  sample:
  - command 1
  - command 2
  - command 3
  type: list