.. _vyos.vyos.vyos_ntp_global_module: ************************* vyos.vyos.vyos_ntp_global ************************* **Manages ntp modules of Vyos network devices** Version added: 2.4.0 .. contents:: :local: :depth: 1 Synopsis -------- - This module manages ntp configuration on devices running Vyos Parameters ---------- .. raw:: html
Parameter Choices/Defaults Comments
config
dictionary
List of configurations for ntp module
allow_clients
list / elements=string
Network Time Protocol (NTP) server options
listen_addresses
list / elements=string
local IP addresses for service to listen on
servers
list / elements=dictionary
Network Time Protocol (NTP) server
options
list / elements=string
    Choices:
  • noselect
  • dynamic
  • preempt
  • prefer
server options for NTP
server
string
server name for NTP
running_config
string
This option is used only with state parsed.
The value of this option should be the output received from the VYOS device by executing the command show configuration commands | grep ntp.
The states replaced and overridden have identical behaviour for this module.
The state parsed reads the configuration from show configuration commands | grep ntp 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.

Notes ----- .. note:: - Tested against vyos 1.3 - This module works with connection ``network_cli``. Examples -------- .. code-block:: yaml # # ------------------- # # 1. Using merged # # ------------------- # # Before state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp # set system ntp server time1.vyos.net # set system ntp server time2.vyos.net # set system ntp server time3.vyos.net # vyos@vyos:~$ # # Task # # ------------- - name: Replace the existing ntp config with the new config vyos.vyos.vyos_ntp_global: config: allow_clients: - 10.6.6.0/24 listen_addresses: - 10.1.3.1 servers: - server: 203.0.113.0 options: - prefer # # Task output: # # ------------- # "after": { # "allow_clients": [ # "10.6.6.0/24" # ], # "listen_addresses": [ # "10.1.3.1" # ], # "servers": [ # { # "server": "ser", # "options": [ # "prefer" # ] # }, # { # "server": "time1.vyos.net" # }, # { # "server": "time2.vyos.net" # }, # { # "server": "time3.vyos.net" # } # ] # }, # "before": { # }, # "changed": true, # "commands": [ # "set system ntp allow-clients address 10.6.6.0/24", # "set system ntp listen-address 10.1.3.1", # "set system ntp server 203.0.113.0 prefer" # ] # After state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp # set system ntp allow-clients address '10.6.6.0/24' # set system ntp listen-address '10.1.3.1' # set system ntp server 203.0.113.0 prefer, # set system ntp server time1.vyos.net # set system ntp server time2.vyos.net # set system ntp server time3.vyos.net # vyos@vyos:~$ # # ------------------- # # 2. Using replaced # # ------------------- # # Before state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp # set system ntp allow-clients address '10.4.9.0/24' # set system ntp allow-clients address '10.4.7.0/24' # set system ntp allow-clients address '10.1.2.0/24' # set system ntp allow-clients address '10.2.3.0/24' # set system ntp listen-address '10.1.9.16' # set system ntp listen-address '10.5.3.2' # set system ntp listen-address '10.7.9.21' # set system ntp listen-address '10.8.9.4' # set system ntp listen-address '10.4.5.1' # set system ntp server 10.3.6.5 noselect # set system ntp server 10.3.6.5 dynamic # set system ntp server 10.3.6.5 preempt # set system ntp server 10.3.6.5 prefer # set system ntp server server4 noselect # set system ntp server server4 dynamic # set system ntp server server5 # set system ntp server time1.vyos.net # set system ntp server time2.vyos.net # set system ntp server time3.vyos.net # vyos@vyos:~$ # # Task # # ------------- - name: Replace the existing ntp config with the new config vyos.vyos.vyos_ntp_global: config: allow_clients: - 10.6.6.0/24 listen_addresses: - 10.1.3.1 servers: - server: 203.0.113.0 options: - prefer state: replaced # # Task output: # # ------------- # "after": { # "allow_clients": [ # "10.6.6.0/24" # ], # "listen_addresses": [ # "10.1.3.1" # ], # "servers": [ # { # "server": "ser", # "options": [ # "prefer" # ] # }, # { # "server": "time1.vyos.net" # }, # { # "server": "time2.vyos.net" # }, # { # "server": "time3.vyos.net" # } # ] # }, # "before": { # "allow_clients": [ # "10.4.7.0/24", # "10.2.3.0/24", # "10.1.2.0/24", # "10.4.9.0/24" # ], # "listen_addresses": [ # "10.7.9.21", # "10.4.5.1", # "10.5.3.2", # "10.8.9.4", # "10.1.9.16" # ], # "servers": [ # { # "server": "10.3.6.5", # "options": [ # "noselect", # "dynamic", # "preempt", # "prefer" # ] # }, # { # "server": "server4", # "options": [ # "noselect", # "dynamic" # ] # }, # { # "server": "server5" # }, # { # "server": "time1.vyos.net" # }, # { # "server": "time2.vyos.net" # }, # { # "server": "time3.vyos.net" # } # ] # }, # "changed": true, # "commands": [ # "delete system ntp allow-clients address 10.4.7.0/24", # "delete system ntp allow-clients address 10.2.3.0/24", # "delete system ntp allow-clients address 10.1.2.0/24", # "delete system ntp allow-clients address 10.4.9.0/24", # "delete system ntp listen-address 10.7.9.21", # "delete system ntp listen-address 10.4.5.1", # "delete system ntp listen-address 10.5.3.2", # "delete system ntp listen-address 10.8.9.4", # "delete system ntp listen-address 10.1.9.16", # "delete system ntp server 10.3.6.5", # "delete system ntp server server4", # "delete system ntp server server5", # "set system ntp allow-clients address 10.6.6.0/24", # "set system ntp listen-address 10.1.3.1", # "set system ntp server 203.0.113.0 prefer" # ] # After state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp # set system ntp allow-clients address '10.6.6.0/24' # set system ntp listen-address '10.1.3.1' # set system ntp server 203.0.113.0 prefer, # set system ntp server time1.vyos.net # set system ntp server time2.vyos.net # set system ntp server time3.vyos.net # vyos@vyos:~$ # # ------------------- # # 3. Using overridden # # ------------------- # # Before state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp # set system ntp allow-clients address '10.6.6.0/24' # set system ntp listen-address '10.1.3.1' # set system ntp server 203.0.113.0 prefer, # set system ntp server time1.vyos.net # set system ntp server time2.vyos.net # set system ntp server time3.vyos.net # vyos@vyos:~$ # # Task # # ------------- - name: Override ntp config vyos.vyos.vyos_ntp_global: config: allow_clients: - 10.3.3.0/24 listen_addresses: - 10.7.8.1 servers: - server: server1 options: - dynamic - prefer - server: server2 options: - noselect - preempt - server: serv state: overridden # # Task output: # # ------------- # "after": { # "allow_clients": [ # "10.3.3.0/24" # ], # "listen_addresses": [ # "10.7.8.1" # ], # "servers": [ # { # "server": "serv" # }, # { # "server": "server1", # "options": [ # "dynamic", # "prefer" # ] # }, # { # "server": "server2", # "options": [ # "noselect", # "preempt" # ] # }, # { # "server": "time1.vyos.net" # }, # { # "server": "time2.vyos.net" # }, # { # "server": "time3.vyos.net" # } # ] # }, # "before": { # "allow_clients": [ # "10.6.6.0/24" # ], # "listen_addresses": [ # "10.1.3.1" # ], # "servers": [ # { # "server": "ser", # "options": [ # "prefer" # ] # }, # { # "server": "time1.vyos.net" # }, # { # "server": "time2.vyos.net" # }, # { # "server": "time3.vyos.net" # } # ] # }, # "changed": true, # "commands": [ # "delete system ntp allow-clients address 10.6.6.0/24", # "delete system ntp listen-address 10.1.3.1", # "delete system ntp server ser", # "set system ntp allow-clients address 10.3.3.0/24", # "set system ntp listen-address 10.7.8.1", # "set system ntp server server1 dynamic", # "set system ntp server server1 prefer", # "set system ntp server server2 noselect", # "set system ntp server server2 preempt", # "set system ntp server serv" # ] # After state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp # set system ntp allow-clients address '10.3.3.0/24' # set system ntp listen-address '10.7.8.1' # set system ntp server serv # set system ntp server server1 dynamic # set system ntp server server1 prefer # set system ntp server server2 noselect # set system ntp server server2 preempt # set system ntp server time1.vyos.net # set system ntp server time2.vyos.net # set system ntp server time3.vyos.net # vyos@vyos:~$ # # ------------------- # # 4. Using gathered # # ------------------- # # Before state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp # set system ntp allow-clients address '10.3.3.0/24' # set system ntp listen-address '10.7.8.1' # set system ntp server serv # set system ntp server server1 dynamic # set system ntp server server1 prefer # set system ntp server server2 noselect # set system ntp server server2 preempt # set system ntp server time1.vyos.net # set system ntp server time2.vyos.net # set system ntp server time3.vyos.net # vyos@vyos:~$ # # Task # # ------------- - name: Gather ntp config vyos.vyos.vyos_ntp_global: state: gathered # # Task output: # # ------------- # "gathered": { # "allow_clients": [ # "10.3.3.0/24" # ], # "listen_addresses": [ # "10.7.8.1" # ], # "servers": [ # { # "server": "serv" # }, # { # "server": "server1", # "options": [ # "dynamic", # "prefer" # ] # }, # { # "server": "server2", # "options": [ # "noselect", # "preempt" # ] # }, # { # "server": "time1.vyos.net" # }, # { # "server": "time2.vyos.net" # }, # { # "server": "time3.vyos.net" # } # ] # } # After state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp # set system ntp allow-clients address '10.3.3.0/24' # set system ntp listen-address '10.7.8.1' # set system ntp server serv # set system ntp server server1 dynamic # set system ntp server server1 prefer # set system ntp server server2 noselect # set system ntp server server2 preempt # set system ntp server time1.vyos.net # set system ntp server time2.vyos.net # set system ntp server time3.vyos.net # vyos@vyos:~$ # # ------------------- # # 5. Using deleted # # ------------------- # # Before state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp # set system ntp allow-clients address '10.3.3.0/24' # set system ntp listen-address '10.7.8.1' # set system ntp server serv # set system ntp server server1 dynamic # set system ntp server server1 prefer # set system ntp server server2 noselect # set system ntp server server2 preempt # set system ntp server time1.vyos.net # set system ntp server time2.vyos.net # set system ntp server time3.vyos.net # vyos@vyos:~$ # # Task # # ------------- - name: Delete ntp config vyos.vyos.vyos_ntp_global: state: deleted # # Task output: # # ------------- # "after": { # "servers": [ # { # "server": "time1.vyos.net" # }, # { # "server": "time2.vyos.net" # }, # { # "server": "time3.vyos.net" # } # ] # }, # "before": { # "allow_clients": [ # "10.3.3.0/24" # ], # "listen_addresses": [ # "10.7.8.1" # ], # "servers": [ # { # "server": "serv" # }, # { # "server": "server1", # "options": [ # "dynamic", # "prefer" # ] # }, # { # "server": "server2", # "options": [ # "noselect", # "preempt" # ] # }, # { # "server": "time1.vyos.net" # }, # { # "server": "time2.vyos.net" # }, # { # "server": "time3.vyos.net" # } # ] # }, # "changed": true, # "commands": [ # "delete system ntp allow-clients", # "delete system ntp listen-address", # "delete system ntp server serv", # "delete system ntp server server1", # "delete system ntp server server2" # # ] # After state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp # set system ntp server time1.vyos.net # set system ntp server time2.vyos.net # set system ntp server time3.vyos.net # vyos@vyos:~$ # # ------------------- # # 6. Using rendered # # ------------------- # # Before state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp # set system ntp server time1.vyos.net # set system ntp server time2.vyos.net # set system ntp server time3.vyos.net # vyos@vyos:~$ # # Task # # ------------- - name: Gather ntp config vyos.vyos.vyos_ntp_global: config: allow_clients: - 10.7.7.0/24 - 10.8.8.0/24 listen_addresses: - 10.7.9.1 servers: - server: server7 - server: server45 options: - noselect - prefer - server: time1.vyos.net - server: time2.vyos.net - server: time3.vyos.net state: rendered # # Task output: # # ------------- # "rendered": [ # "set system ntp allow-clients address 10.7.7.0/24", # "set system ntp allow-clients address 10.8.8.0/24", # "set system ntp listen-address 10.7.9.1", # "set system ntp server server7", # "set system ntp server server45 noselect", # "set system ntp server server45 prefer", # "set system ntp server time1.vyos.net", # "set system ntp server time2.vyos.net", # "set system ntp server time3.vyos.net" # ] # # ------------------- # # 7. Using parsed # # ------------------- # # sample_config.cfg: # # ------------- # "set system ntp allow-clients address 10.7.7.0/24", # "set system ntp listen-address 10.7.9.1", # "set system ntp server server45 noselect", # "set system ntp allow-clients addres 10.8.6.0/24", # "set system ntp listen-address 10.5.4.1", # "set system ntp server server45 dynamic", # "set system ntp server time1.vyos.net", # "set system ntp server time2.vyos.net", # "set system ntp server time3.vyos.net" # # Task: # # ------------- - name: Parse externally provided ntp configuration vyos.vyos.vyos_ntp_global: running_config: "{{ lookup('file', './sample_config.cfg') }}" state: parsed # # Task output: # # ------------- # parsed = { # "allow_clients": [ # "10.7.7.0/24", # "10.8.6.0/24 # ], # "listen_addresses": [ # "10.5.4.1", # "10.7.9.1" # ], # "servers": [ # { # "server": "server45", # "options": [ # "noselect", # "dynamic" # # ] # }, # { # "server": "time1.vyos.net" # }, # { # "server": "time2.vyos.net" # }, # { # "server": "time3.vyos.net" # } # # ] # } Return Values ------------- Common return values are documented `here `_, the following are the fields unique to this module: .. raw:: html
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:
['set system ntp server server1 dynamic', 'set system ntp server server1 prefer', 'set system ntp server server2 noselect', 'set system ntp server server2 preempt', 'set system ntp server server_add preempt']
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:
['set system ntp server server1 dynamic', 'set system ntp server server1 prefer', 'set system ntp server server2 noselect', 'set system ntp server server2 preempt', 'set system ntp server server_add preempt']


Status ------ Authors ~~~~~~~ - Varshitha Yataluru (@YVarshitha)