�
�Udac @ s� i d d 6d g d 6d d 6Z d Z d Z d Z d d
l Z d d l m Z m Z m Z d d l m Z m
Z
d d
l m Z d � Z
d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z e d k r� e � n d
S( s 1.1t metadata_versiont previewt statust networkt supported_bysl
---
module: nxos_ntp_auth
extends_documentation_fragment: nxos
version_added: "2.2"
short_description: Manages NTP authentication.
description:
- Manages NTP authentication.
author:
- Jason Edelman (@jedelman8)
notes:
- Tested against NXOSv 7.3.(0)D1(1) on VIRL
- If C(state=absent), the module will remove the given key configuration if it exists.
- If C(state=absent) and C(authentication=on), authentication will be turned off.
options:
key_id:
description:
- Authentication key identifier (numeric).
md5string:
description:
- MD5 String.
auth_type:
description:
- Whether the given md5string is in cleartext or
has been encrypted. If in cleartext, the device
will encrypt it before storing it.
default: text
choices: ['text', 'encrypt']
trusted_key:
description:
- Whether the given key is required to be supplied by a time source
for the device to synchronize to the time source.
choices: [ 'false', 'true' ]
default: 'false'
authentication:
description:
- Turns NTP authentication on or off.
choices: ['on', 'off']
state:
description:
- Manage the state of the resource.
default: present
choices: ['present','absent']
ss
# Basic NTP authentication configuration
- nxos_ntp_auth:
key_id: 32
md5string: hello
auth_type: text
s�
commands:
description: command sent to the device
returned: always
type: list
sample: ["ntp authentication-key 32 md5 helloWorld 0", "ntp trusted-key 32"]
i����N( t
get_configt load_configt run_commands( t nxos_argument_spect
check_args( t
AnsibleModulec C sG d | k r# i | d 6d d 6} n i | d 6d d 6} t | | g � S( Ns show runt commandt jsont outputt text( R ( R t module( ( sN /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pyt execute_show_command^ s
c C sG g } x: | D]2 } t | t � r2 | j | � q
| j | � q
W| S( N( t
isinstancet listt extendt append( t
command_listst flat_command_listR ( ( sN /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pyt flatten_listm s
c C sB d } t | | � d } | d } d | k r8 t } n t } | S( Ns show ntp authentication-statusi t authenticationt enabled( R t Truet False( R R t bodyt ntp_auth_strt ntp_auth( ( sN /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pyt get_ntp_authw s
c C su g } d } t | | � d } | r4 | j � } n g } x4 | D], } | rA | j t | j � d � � qA qA W| S( Ns show run | inc ntp.trusted-keyi i ( R t
splitlinesR t strt split( R t trusted_key_listR t trusted_key_strt trusted_keyst line( ( sN /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pyt get_ntp_trusted_key� s
$c C s� i } d j | � } d } t | | � d } yk t j | | t j � } | j � } | d | d <| d | d <| d d k r� d | d <n
d
| d <Wn t t f k
r� i } n X| S( Ns) show run | inc ntp.authentication-key.{0}sU .*ntp\sauthentication-key\s(?P<key_id>\d+)\smd5\s(?P<md5string>\S+)\s(?P<atype>\S+).*i t key_idt md5stringt atypet 7t encryptt auth_typeR ( t formatR t ret matcht DOTALLt groupdictt AttributeErrort TypeError( R( R t authentication_keyR t
auth_regexR t match_authenticationt group_authentication( ( sN /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pyt get_ntp_auth_key� s
c C sk t | | � } t | � } t | � } | | k r@ d | d <n
d | d <| r] d | d <n
d | d <| S( Nt truet trusted_keyt falset onR t off( R9 R'