junipernetworks.junos.junos_ntp_global 模块 – 管理 Junos 设备上的 NTP 配置。

注意

此模块是 junipernetworks.junos 集合 (版本 9.1.0) 的一部分。

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

要安装它,请使用:ansible-galaxy collection install junipernetworks.junos。您需要进一步的要求才能使用此模块,请参阅 要求 了解详细信息。

要在 Playbook 中使用它,请指定:junipernetworks.junos.junos_ntp_global

junipernetworks.junos 2.6.0 中的新增功能

概要

  • 此模块管理运行 Junos 的设备上的 NTP 配置。

要求

执行此模块的主机需要满足以下要求。

  • ncclient (>=v0.6.4)

  • xmltodict (>=0.12.0)

参数

参数

注释

config

字典

NTP 配置的字典。

authentication_keys

列表 / 元素=字典

NTP 身份验证密钥。

algorithm

字符串

身份验证密钥类型。

选择

  • "md5"

  • "sha1"

  • "sha256"

id

整数

身份验证密钥编号。

key

字符串

身份验证密钥值。

boot_server

字符串

在启动序列期间查询的服务器。

broadcast_client

布尔值

侦听广播 NTP。

选择

  • false

  • true

broadcasts

列表 / 元素=字典

广播参数。

address

字符串

要使用的广播或多播地址。

key

字符串

身份验证密钥。

routing_instance_name

字符串

接口在广播子网中具有地址的路由实例名称。

ttl

整数

要传输的 TTL 值。

version

整数

要使用的 NTP 版本。

interval_range

整数

设置 minpoll 和 maxpoll 间隔范围。

multicast_client

字符串

侦听多播 NTP 地址。

peers

列表 / 元素=字典

NTP 对等点。

key_id

整数

通信时要使用的 Key-id。

peer

字符串

NTP 对等点的主机名/IP 地址。

prefer

布尔值

首选此对等点。

选择

  • false

  • true

version

整数

要使用的 NTP 版本。

servers

列表 / 元素=字典

NTP 服务器。

key_id

整数

通信时要使用的 Key-id。

prefer

布尔值

首选此 peer_serv。

选择

  • false

  • true

routing_instance

字符串

服务器可通过其访问的路由实例。

server

字符串

服务器的 IP 地址或主机名。

version

整数

要使用的 NTP 版本。

source_addresses

列表 / 元素=字典

源地址参数。

routing_instance

字符串

在其中定义源地址的路由实例名称。

source_address

字符串

使用指定的地址作为源地址。

threshold

字典

设置 NTP 调整允许的最大阈值(秒)。

action

字符串

选择 NTP 异常调整的操作。

选择

  • "accept"

  • "reject"

value

整数

NTP 调整允许的最大值(秒)。

trusted_keys

列表 / 元素=字典

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

key_id

整数

受信任的密钥编号。

running_config

字符串

此选项仅与状态 parsed 一起使用。

此选项的值应该是通过执行命令 show system syslog 从 Junos 设备接收的输出。

状态 parsedrunning_config 选项读取配置,并根据资源模块的参数规范将其转换为 Ansible 结构化数据,然后该值将返回到结果中的 parsed 键中。

state

字符串

配置应保留的状态。

对于此模块,状态 replacedoverridden 具有相同的行为。

有关更多详细信息,请参阅示例。

选择

  • "merged" ← (默认)

  • "replaced"

  • "deleted"

  • "overridden"

  • "parsed"

  • "gathered"

  • "rendered"

注释

注意

  • 此模块要求在被管理的设备上启用 netconf 系统服务。

  • 此模块使用连接 netconf

  • 请参阅 Junos OS 平台选项

  • 已针对 JunOS v18.4R1 进行测试

示例

# Using merged
#
# Before state
# ------------
#
# vagrant@vsrx# show system ntp
#
# [edit]
# vagrant@vsrx# show routing-instances
# rt1 {
#     description rt1;
# }
# rt2 {
- name: Merge provided NTP configuration into running configuration.
  junipernetworks.junos.junos_ntp_global:
    config:
      boot_server: '78.46.194.186'
      broadcasts:
        - address: '172.16.255.255'
          key: '50'
          ttl: 200
          version: 3
          routing_instance_name: 'rt1'
        - address: '192.16.255.255'
          key: '50'
          ttl: 200
          version: 3
          routing_instance_name: 'rt2'
      broadcast_client: true
      interval_range: 2
      multicast_client: "224.0.0.1"
      peers:
        - peer: "78.44.194.186"
        - peer: "172.44.194.186"
          key_id: 10000
          prefer: true
          version: 3
      servers:
        - server: "48.46.194.186"
          key_id: 34
          prefer: true
          version: 2
          routing_instance: 'rt1'
        - server: "48.45.194.186"
          key_id: 34
          prefer: true
          version: 2
      source_addresses:
        - source_address: "172.45.194.186"
          routing_instance: 'rt1'
        - source_address: "171.45.194.186"
          routing_instance: 'rt2'
      threshold:
        value: 300
        action: "accept"
      trusted_keys:
        - key_id: 3000
        - key_id: 2000
    state: merged
#
# -------------------------
# Module Execution Result
# -------------------------
#     "after": {
#         "boot_server": "78.46.194.186",
#         "broadcast_client": true,
#         "broadcasts": [
#             {
#                 "address": "172.16.255.255",
#                 "key": "50",
#                 "routing_instance_name": "rt1",
#                 "ttl": 200,
#                 "version": 3
#             },
#             {
#                 "address": "192.16.255.255",
#                 "key": "50",
#                 "routing_instance_name": "rt2",
#                 "ttl": 200,
#                 "version": 3
#             }
#         ],
#         "interval_range": 2,
#         "multicast_client": "224.0.0.1",
#         "peers": [
#             {
#                 "peer": "78.44.194.186"
#             },
#             {
#                 "key_id": 10000,
#                 "peer": "172.44.194.186",
#                 "prefer": true,
#                 "version": 3
#             }
#         ],
#         "servers": [
#             {
#                 "key_id": 34,
#                 "prefer": true,
#                 "routing_instance": "rt1",
#                 "server": "48.46.194.186",
#                 "version": 2
#             },
#             {
#                 "key_id": 34,
#                 "prefer": true,
#                 "server": "48.45.194.186",
#                 "version": 2
#             }
#         ],
#         "source_addresses": [
#             {
#                 "routing_instance": "rt1",
#                 "source_address": "172.45.194.186"
#             },
#             {
#                 "routing_instance": "rt2",
#                 "source_address": "171.45.194.186"
#             }
#         ],
#         "threshold": {
#             "action": "accept",
#             "value": 300
#         },
#         "trusted_keys": [
#             {"key_id": 2000},
#             {"key_id": 3000}
#         ]
#     },
#     "before": {},
#     "changed": true,
#     "commands": [
#           "<nc:system xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">"
#           "<nc:ntp><nc:boot-server>78.46.194.186</nc:boot-server><nc:broadcast>"
#           "<nc:name>172.16.255.255</nc:name><nc:key>50</nc:key><nc:routing-instance-name>rt1</nc:routing-instance-name>"
#           "<nc:ttl>200</nc:ttl><nc:version>3</nc:version></nc:broadcast><nc:broadcast><nc:name>192.16.255.255</nc:name>"
#           "<nc:key>50</nc:key><nc:routing-instance-name>rt2</nc:routing-instance-name><nc:ttl>200</nc:ttl>"
#           "<nc:version>3</nc:version></nc:broadcast><nc:broadcast-client/><nc:interval-range>2</nc:interval-range>"
#           "<nc:multicast-client>224.0.0.1</nc:multicast-client><nc:peer><nc:name>78.44.194.186</nc:name></nc:peer>"
#           "<nc:peer><nc:name>172.44.194.186</nc:name><nc:key>10000</nc:key><nc:prefer/><nc:version>3</nc:version>"
#           "</nc:peer><nc:server><nc:name>48.46.194.186</nc:name><nc:key>34</nc:key><nc:routing-instance>rt1</nc:routing-instance>"
#           "<nc:prefer/><nc:version>2</nc:version></nc:server><nc:server><nc:name>48.45.194.186</nc:name><nc:key>34</nc:key>"
#           "<nc:prefer/><nc:version>2</nc:version></nc:server><nc:source-address><nc:name>172.45.194.186</nc:name>"
#           "<nc:routing-instance>rt1</nc:routing-instance></nc:source-address><nc:source-address>"
#           "<nc:name>171.45.194.186</nc:name><nc:routing-instance>rt2</nc:routing-instance></nc:source-address>"
#           "<nc:threshold><nc:value>300</nc:value><nc:action>accept</nc:action></nc:threshold>"
#           "<nc:trusted-key>3000</nc:trusted-key><nc:trusted-key>2000</nc:trusted-key></nc:ntp></nc:system>"
#     ]
# After state
# -----------
#
# vagrant@vsrx# show system ntp
# boot-server 78.46.194.186;
# interval-range 2;
# peer 78.44.194.186;
# peer 172.44.194.186 key 10000 version 3 prefer; ## SECRET-DATA
# server 48.46.194.186 key 34 version 2 prefer routing-instance rt1; ## SECRET-DATA
# server 48.45.194.186 key 34 version 2 prefer; ## SECRET-DATA
# broadcast 172.16.255.255 routing-instance-name rt1 key 50 version 3 ttl 200;
# broadcast 192.16.255.255 routing-instance-name rt2 key 50 version 3 ttl 200;
# broadcast-client;
# multicast-client 224.0.0.1;
# trusted-key [ 3000 2000 ];
# threshold 300 action accept;
# source-address 172.45.194.186 routing-instance rt1;
# source-address 171.45.194.186 routing-instance rt2;
#
#
# Using Replaced
# Before state
# ------------
#
# vagrant@vsrx# show system ntp
# boot-server 78.46.194.186;
# interval-range 2;
# peer 78.44.194.186;
# peer 172.44.194.186 key 10000 version 3 prefer; ## SECRET-DATA
# server 48.46.194.186 key 34 version 2 prefer routing-instance rt1; ## SECRET-DATA
# server 48.45.194.186 key 34 version 2 prefer; ## SECRET-DATA
# broadcast 172.16.255.255 routing-instance-name rt1 key 50 version 3 ttl 200;
# broadcast 192.16.255.255 routing-instance-name rt2 key 50 version 3 ttl 200;
# broadcast-client;
# multicast-client 224.0.0.1;
# trusted-key [ 3000 2000 ];
# threshold 300 action accept;
# source-address 172.45.194.186 routing-instance rt1;
# source-address 171.45.194.186 routing-instance rt2;

- name: Replaced running ntp global configuration with provided configuration
  junipernetworks.junos.junos_ntp_global:
    config:
      authentication_keys:
        - id: 2
          algorithm: 'md5'
          key: 'asdfghd'
        - id: 5
          algorithm: 'sha1'
          key: 'aasdad'
      servers:
        - server: "48.46.194.186"
          key_id: 34
          prefer: true
          version: 2
          routing_instance: 'rt1'
        - server: "48.45.194.186"
          key_id: 34
          prefer: true
          version: 2
    state: replaced
#
# -------------------------
# Module Execution Result
# -------------------------
#     "after": {
#         "authentication_keys": [
#             {
#                 "algorithm": "md5",
#                 "id": 2,
#                 "key": "$9$03aAB1hreW7NbO1rvMLVbgoJ"
#             },
#             {
#                 "algorithm": "sha1",
#                 "id": 5,
#                 "key": "$9$DXiHmf5F/A0ZUjq.P3n"
#             }
#         ],
#         "servers": [
#             {
#                 "key_id": 34,
#                 "prefer": true,
#                 "routing_instance": "rt1",
#                 "server": "48.46.194.186",
#                 "version": 2
#             },
#             {
#                 "key_id": 34,
#                 "prefer": true,
#                 "server": "48.45.194.186",
#                 "version": 2
#             }
#         ]
#     },
#     "before": {
#         "boot_server": "78.46.194.186",
#         "broadcast_client": true,
#         "broadcasts": [
#             {
#                 "address": "172.16.255.255",
#                 "key": "50",
#                 "routing_instance_name": "rt1",
#                 "ttl": 200,
#                 "version": 3
#             },
#             {
#                 "address": "192.16.255.255",
#                 "key": "50",
#                 "routing_instance_name": "rt2",
#                 "ttl": 200,
#                 "version": 3
#             }
#         ],
#         "interval_range": 2,
#         "multicast_client": "224.0.0.1",
#         "peers": [
#             {
#                 "peer": "78.44.194.186"
#             },
#             {
#                 "key_id": 10000,
#                 "peer": "172.44.194.186",
#                 "prefer": true,
#                 "version": 3
#             }
#         ],
#         "servers": [
#             {
#                 "key_id": 34,
#                 "prefer": true,
#                 "routing_instance": "rt1",
#                 "server": "48.46.194.186",
#                 "version": 2
#             },
#             {
#                 "key_id": 34,
#                 "prefer": true,
#                 "server": "48.45.194.186",
#                 "version": 2
#             }
#         ],
#         "source_addresses": [
#             {
#                 "routing_instance": "rt1",
#                 "source_address": "172.45.194.186"
#             },
#             {
#                 "routing_instance": "rt2",
#                 "source_address": "171.45.194.186"
#             }
#         ],
#         "threshold": {
#             "action": "accept",
#             "value": 300
#         },
#         "trusted_keys": [
#             {"key_id": 2000},
#             {"key_id": 3000}
#         ]
#     },
#     "changed": true,
#     "commands": [
#             "<nc:system xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
#             "<nc:ntp delete="delete"/><nc:ntp><nc:authentication-key><nc:name>2</nc:name><nc:type>md5</nc:type>
#             "<nc:value>asdfghd</nc:value></nc:authentication-key><nc:authentication-key><nc:name>5</nc:name>
#             "<nc:type>sha1</nc:type><nc:value>aasdad</nc:value></nc:authentication-key><nc:server>
#             "<nc:name>48.46.194.186</nc:name><nc:key>34</nc:key><nc:routing-instance>rt1</nc:routing-instance>
#             "<nc:prefer/><nc:version>2</nc:version></nc:server><nc:server><nc:name>48.45.194.186</nc:name>
#             "<nc:key>34</nc:key><nc:prefer/><nc:version>2</nc:version></nc:server></nc:ntp></nc:system>"
#     ]
# After state
# -----------
#
# vagrant@vsrx# show system ntp
# authentication-key 2 type md5 value "$9$03aAB1hreW7NbO1rvMLVbgoJ"; ## SECRET-DATA
# authentication-key 5 type sha1 value "$9$DXiHmf5F/A0ZUjq.P3n"; ## SECRET-DATA
# server 48.46.194.186 key 34 version 2 prefer routing-instance rt1; ## SECRET-DATA
# server 48.45.194.186 key 34 version 2 prefer; ## SECRET-DATA

# Using overridden
#
# Before state
# ------------
#
# vagrant@vsrx# show system ntp
# boot-server 78.46.194.186;
# interval-range 2;
# peer 78.44.194.186;
# peer 172.44.194.186 key 10000 version 3 prefer; ## SECRET-DATA
# server 48.46.194.186 key 34 version 2 prefer routing-instance rt1; ## SECRET-DATA
# server 48.45.194.186 key 34 version 2 prefer; ## SECRET-DATA
# broadcast 172.16.255.255 routing-instance-name rt1 key 50 version 3 ttl 200;
# broadcast 192.16.255.255 routing-instance-name rt2 key 50 version 3 ttl 200;
# broadcast-client;
# multicast-client 224.0.0.1;
# trusted-key [ 3000 2000 ];
# threshold 300 action accept;
# source-address 172.45.194.186 routing-instance rt1;
# source-address 171.45.194.186 routing-instance rt2;

- name: Override running ntp global configuration with provided configuration
  junipernetworks.junos.junos_ntp_global:
    config:
      authentication_keys:
        - id: 2
          algorithm: 'md5'
          key: 'asdfghd'
        - id: 5
          algorithm: 'sha1'
          key: 'aasdad'
      servers:
        - server: "48.46.194.186"
          key_id: 34
          prefer: true
          version: 2
          routing_instance: 'rt1'
        - server: "48.45.194.186"
          key_id: 34
          prefer: true
          version: 2
    state: overridden
#
# -------------------------
# Module Execution Result
# -------------------------
#     "after": {
#         "authentication_keys": [
#             {
#                 "algorithm": "md5",
#                 "id": 2,
#                 "key": "$9$03aAB1hreW7NbO1rvMLVbgoJ"
#             },
#             {
#                 "algorithm": "sha1",
#                 "id": 5,
#                 "key": "$9$DXiHmf5F/A0ZUjq.P3n"
#             }
#         ],
#         "servers": [
#             {
#                 "key_id": 34,
#                 "prefer": true,
#                 "routing_instance": "rt1",
#                 "server": "48.46.194.186",
#                 "version": 2
#             },
#             {
#                 "key_id": 34,
#                 "prefer": true,
#                 "server": "48.45.194.186",
#                 "version": 2
#             }
#         ]
#     },
#     "before": {
#         "boot_server": "78.46.194.186",
#         "broadcast_client": true,
#         "broadcasts": [
#             {
#                 "address": "172.16.255.255",
#                 "key": "50",
#                 "routing_instance_name": "rt1",
#                 "ttl": 200,
#                 "version": 3
#             },
#             {
#                 "address": "192.16.255.255",
#                 "key": "50",
#                 "routing_instance_name": "rt2",
#                 "ttl": 200,
#                 "version": 3
#             }
#         ],
#         "interval_range": 2,
#         "multicast_client": "224.0.0.1",
#         "peers": [
#             {
#                 "peer": "78.44.194.186"
#             },
#             {
#                 "key_id": 10000,
#                 "peer": "172.44.194.186",
#                 "prefer": true,
#                 "version": 3
#             }
#         ],
#         "servers": [
#             {
#                 "key_id": 34,
#                 "prefer": true,
#                 "routing_instance": "rt1",
#                 "server": "48.46.194.186",
#                 "version": 2
#             },
#             {
#                 "key_id": 34,
#                 "prefer": true,
#                 "server": "48.45.194.186",
#                 "version": 2
#             }
#         ],
#         "source_addresses": [
#             {
#                 "routing_instance": "rt1",
#                 "source_address": "172.45.194.186"
#             },
#             {
#                 "routing_instance": "rt2",
#                 "source_address": "171.45.194.186"
#             }
#         ],
#         "threshold": {
#             "action": "accept",
#             "value": 300
#         },
#         "trusted_keys": [
#             {"key_id": 2000},
#             {"key_id": 3000}
#         ]
#     },
#     "changed": true,
#     "commands": [
#             "<nc:system xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
#             "<nc:ntp delete="delete"/><nc:ntp><nc:authentication-key><nc:name>2</nc:name><nc:type>md5</nc:type>
#             "<nc:value>asdfghd</nc:value></nc:authentication-key><nc:authentication-key><nc:name>5</nc:name>
#             "<nc:type>sha1</nc:type><nc:value>aasdad</nc:value></nc:authentication-key><nc:server>
#             "<nc:name>48.46.194.186</nc:name><nc:key>34</nc:key><nc:routing-instance>rt1</nc:routing-instance>
#             "<nc:prefer/><nc:version>2</nc:version></nc:server><nc:server><nc:name>48.45.194.186</nc:name>
#             "<nc:key>34</nc:key><nc:prefer/><nc:version>2</nc:version></nc:server></nc:ntp></nc:system>"
#     ]
# After state
# -----------
#
# vagrant@vsrx# show system ntp
# authentication-key 2 type md5 value "$9$03aAB1hreW7NbO1rvMLVbgoJ"; ## SECRET-DATA
# authentication-key 5 type sha1 value "$9$DXiHmf5F/A0ZUjq.P3n"; ## SECRET-DATA
# server 48.46.194.186 key 34 version 2 prefer routing-instance rt1; ## SECRET-DATA
# server 48.45.194.186 key 34 version 2 prefer; ## SECRET-DATA
#
# Using deleted
#
# Before state
# ------------
#
# vagrant@vsrx# show system ntp
# authentication-key 2 type md5 value "$9$03aAB1hreW7NbO1rvMLVbgoJ"; ## SECRET-DATA
# authentication-key 5 type sha1 value "$9$DXiHmf5F/A0ZUjq.P3n"; ## SECRET-DATA
# server 48.46.194.186 key 34 version 2 prefer routing-instance rt1; ## SECRET-DATA
# server 48.45.194.186 key 34 version 2 prefer; ## SECRET-DATA
#
- name: Delete running NTP global configuration
  junipernetworks.junos.junos_ntp_global:
    config:
    state: deleted
#
# -------------------------
# Module Execution Result
# -------------------------
#     "after": {},
#     "before": {
#         "authentication_keys": [
#             {
#                 "algorithm": "md5",
#                 "id": 2,
#                 "key": "$9$03aAB1hreW7NbO1rvMLVbgoJ"
#             },
#             {
#                 "algorithm": "sha1",
#                 "id": 5,
#                 "key": "$9$DXiHmf5F/A0ZUjq.P3n"
#             }
#         ],
#         "servers": [
#             {
#                 "key_id": 34,
#                 "prefer": true,
#                 "routing_instance": "rt1",
#                 "server": "48.46.194.186",
#                 "version": 2
#             },
#             {
#                 "key_id": 34,
#                 "prefer": true,
#                 "server": "48.45.194.186",
#                 "version": 2
#             }
#         ]
#     },
#     "changed": true,
#     "commands": [
#               "<nc:system xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">"
#               "<nc:ntp delete="delete"/></nc:system>"
#     ]
# After state
# -----------
#
# vagrant@vsrx# show system ntp
#
# [edit]
# Using gathered
#
# Before state
# ------------
#
# vagrant@vsrx# show system ntp
# boot-server 78.46.194.186;
# interval-range 2;
# peer 78.44.194.186;
# peer 172.44.194.186 key 10000 version 3 prefer; ## SECRET-DATA
# server 48.46.194.186 key 34 version 2 prefer routing-instance rt1; ## SECRET-DATA
# server 48.45.194.186 key 34 version 2 prefer; ## SECRET-DATA
# broadcast 172.16.255.255 routing-instance-name rt1 key 50 version 3 ttl 200;
# broadcast 192.16.255.255 routing-instance-name rt2 key 50 version 3 ttl 200;
# broadcast-client;
# multicast-client 224.0.0.1;
# trusted-key [ 3000 2000 ];
# threshold 300 action accept;
# source-address 172.45.194.186 routing-instance rt1;
# source-address 171.45.194.186 routing-instance rt2;
- name: Gather running NTP global configuration
  junipernetworks.junos.junos_ntp_global:
    state: gathered
#
# -------------------------
# Module Execution Result
# -------------------------
#     "gathered": {
#         "boot_server": "78.46.194.186",
#         "broadcast_client": true,
#         "broadcasts": [
#             {
#                 "address": "172.16.255.255",
#                 "key": "50",
#                 "routing_instance_name": "rt1",
#                 "ttl": 200,
#                 "version": 3
#             },
#             {
#                 "address": "192.16.255.255",
#                 "key": "50",
#                 "routing_instance_name": "rt2",
#                 "ttl": 200,
#                 "version": 3
#             }
#         ],
#         "interval_range": 2,
#         "multicast_client": "224.0.0.1",
#         "peers": [
#             {
#                 "peer": "78.44.194.186"
#             },
#             {
#                 "key_id": 10000,
#                 "peer": "172.44.194.186",
#                 "prefer": true,
#                 "version": 3
#             }
#         ],
#         "servers": [
#             {
#                 "key_id": 34,
#                 "prefer": true,
#                 "routing_instance": "rt1",
#                 "server": "48.46.194.186",
#                 "version": 2
#             },
#             {
#                 "key_id": 34,
#                 "prefer": true,
#                 "server": "48.45.194.186",
#                 "version": 2
#             }
#         ],
#         "source_addresses": [
#             {
#                 "routing_instance": "rt1",
#                 "source_address": "172.45.194.186"
#             },
#             {
#                 "routing_instance": "rt2",
#                 "source_address": "171.45.194.186"
#             }
#         ],
#         "threshold": {
#             "action": "accept",
#             "value": 300
#         },
#         "trusted_keys": [
#             {"key_id": 2000},
#             {"key_id": 3000}
#         ]
#     },
#     "changed": false,
# Using rendered
#
# Before state
# ------------
#
- name: Render xml for provided facts.
  junipernetworks.junos.junos_ntp_global:
    config:
      boot_server: '78.46.194.186'
      broadcasts:
        - address: '172.16.255.255'
          key: '50'
          ttl: 200
          version: 3
          routing_instance_name: 'rt1'
        - address: '192.16.255.255'
          key: '50'
          ttl: 200
          version: 3
          routing_instance_name: 'rt2'
      broadcast_client: true
      interval_range: 2
      multicast_client: "224.0.0.1"
      peers:
        - peer: "78.44.194.186"
        - peer: "172.44.194.186"
          key_id: 10000
          prefer: true
          version: 3
      servers:
        - server: "48.46.194.186"
          key_id: 34
          prefer: true
          version: 2
          routing_instance: 'rt1'
        - server: "48.45.194.186"
          key_id: 34
          prefer: true
          version: 2
      source_addresses:
        - source_address: "172.45.194.186"
          routing_instance: 'rt1'
        - source_address: "171.45.194.186"
          routing_instance: 'rt2'
      threshold:
        value: 300
        action: "accept"
      trusted_keys:
        - 3000
        - 2000
    state: rendered
#
# -------------------------
# Module Execution Result
# -------------------------
#     "rendered": [
#           "<nc:system xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">"
#           "<nc:ntp><nc:boot-server>78.46.194.186</nc:boot-server><nc:broadcast><nc:name>172.16.255.255</nc:name>"
#           "<nc:key>50</nc:key><nc:routing-instance-name>rt1</nc:routing-instance-name><nc:ttl>200</nc:ttl>"
#           "<nc:version>3</nc:version></nc:broadcast><nc:broadcast><nc:name>192.16.255.255</nc:name>"
#           "<nc:key>50</nc:key><nc:routing-instance-name>rt2</nc:routing-instance-name>"
#           "<nc:ttl>200</nc:ttl><nc:version>3</nc:version></nc:broadcast><nc:broadcast-client/>"
#           "<nc:interval-range>2</nc:interval-range><nc:multicast-client>224.0.0.1</nc:multicast-client><nc:peer>"
#           "<nc:name>78.44.194.186</nc:name></nc:peer><nc:peer><nc:name>172.44.194.186</nc:name>"
#           "<nc:key>10000</nc:key><nc:prefer/><nc:version>3</nc:version></nc:peer><nc:server>"
#           "<nc:name>48.46.194.186</nc:name><nc:key>34</nc:key><nc:routing-instance>rt1</nc:routing-instance>"
#           "<nc:prefer/><nc:version>2</nc:version></nc:server><nc:server><nc:name>48.45.194.186</nc:name>"
#           "<nc:key>34</nc:key><nc:prefer/><nc:version>2</nc:version></nc:server><nc:source-address>"
#           "<nc:name>172.45.194.186</nc:name><nc:routing-instance>rt1</nc:routing-instance></nc:source-address>"
#           "<nc:source-address><nc:name>171.45.194.186</nc:name><nc:routing-instance>rt2</nc:routing-instance>"
#           "</nc:source-address><nc:threshold><nc:value>300</nc:value><nc:action>accept</nc:action></nc:threshold>"
#           "<nc:trusted-key>3000</nc:trusted-key><nc:trusted-key>2000</nc:trusted-key></nc:ntp></nc:system>"
#     ]
#
# Using parsed
# parsed.cfg
# ------------
# <?xml version="1.0" encoding="UTF-8"?>
# <rpc-reply message-id="urn:uuid:0cadb4e8-5bba-47f4-986e-72906227007f">
#     <configuration changed-seconds="1590139550" changed-localtime="2020-05-22 09:25:50 UTC">
#         <version>18.4R1-S2.4</version>
#         <system xmlns="http://yang.juniper.net/junos-es/conf/system">
#            <ntp>
#               <authentication-key>
#                  <name>2</name>
#                  <type>md5</type>
#                  <value>$9$GxDjqfT3CA0UjfzF6u0RhS</value>
#               </authentication-key>
#               <authentication-key>
#                  <name>5</name>
#                  <type>sha1</type>
#                  <value>$9$ZsUDk.mT3/toJGiHqQz</value>
#               </authentication-key>
#           </ntp>
#     </system>
#     </configuration>
# </rpc-reply>
#
- name: Parse NTP global running config
  junipernetworks.junos.junos_ntp_global:
    running_config: "{{ lookup('file', './parsed.cfg') }}"
    state: parsed
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#
# "parsed":  {
#         "authentication_keys": [
#             {
#                 "algorithm": "md5",
#                 "id": 2,
#                 "key": "$9$GxDjqfT3CA0UjfzF6u0RhS"
#             },
#             {
#                 "algorithm": "sha1",
#                 "id": 5,
#                 "key": "$9$ZsUDk.mT3/toJGiHqQz"
#             }
#         ]
#     }
#
#

返回值

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

描述

after

字典

生成的配置模型调用。

返回:当更改时

示例: "返回的配置将始终采用与上述参数相同的格式。\n"

before

字典

模型调用之前的配置。

返回:始终

示例: "返回的配置将始终采用与上述参数相同的格式。\n"

commands

列表 / 元素=字符串

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

返回:始终

示例: ["<nc:name>78.44.194.186</nc:name></nc:peer><nc:peer><nc:name>172.44.194.186</nc:name>", "xml 2", "xml 3"]

作者

  • Rohit Thakur (@rohitthakur2590)