�
�Udac @ s i d d 6d g d 6d d 6Z d Z d Z d Z d d
l m Z m Z d d l m Z m Z d d l m Z d d
l
m Z i d d 6d d 6d d 6d d 6Z
d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z e d k re � n d S( s 1.1t metadata_versiont previewt statust networkt supported_bysu
---
module: nxos_hsrp
extends_documentation_fragment: nxos
version_added: "2.2"
short_description: Manages HSRP configuration on NX-OS switches.
description:
- Manages HSRP configuration on NX-OS switches.
author:
- Jason Edelman (@jedelman8)
- Gabriele Gerbino (@GGabriele)
notes:
- Tested against NXOSv 7.3.(0)D1(1) on VIRL
- HSRP feature needs to be enabled first on the system.
- SVIs must exist before using this module.
- Interface must be a L3 port before using this module.
- HSRP cannot be configured on loopback interfaces.
- MD5 authentication is only possible with HSRPv2 while it is ignored if
HSRPv1 is used instead, while it will not raise any error. Here we allow
MD5 authentication only with HSRPv2 in order to enforce better practice.
options:
group:
description:
- HSRP group number.
required: true
interface:
description:
- Full name of interface that is being managed for HSRP.
required: true
version:
description:
- HSRP version.
default: 1
choices: ['1','2']
priority:
description:
- HSRP priority or keyword 'default'.
preempt:
description:
- Enable/Disable preempt.
choices: ['enabled', 'disabled']
vip:
description:
- HSRP virtual IP address or keyword 'default'
auth_string:
description:
- Authentication string. If this needs to be hidden(for md5 type), the string
should be 7 followed by the key string. Otherwise, it can be 0 followed by
key string or just key string (for backward compatibility). For text type,
this should be just be a key string. if this is 'default', authentication
is removed.
auth_type:
description:
- Authentication type.
choices: ['text','md5']
state:
description:
- Specify desired state of the resource.
choices: ['present','absent']
default: 'present'
s�
- name: Ensure HSRP is configured with following params on a SVI
nxos_hsrp:
group: 10
vip: 10.1.1.1
priority: 150
interface: vlan10
preempt: enabled
host: 68.170.147.165
- name: Ensure HSRP is configured with following params on a SVI
with clear text authentication
nxos_hsrp:
group: 10
vip: 10.1.1.1
priority: 150
interface: vlan10
preempt: enabled
host: 68.170.147.165
auth_type: text
auth_string: CISCO
- name: Ensure HSRP is configured with md5 authentication and clear
authentication string
nxos_hsrp:
group: 10
vip: 10.1.1.1
priority: 150
interface: vlan10
preempt: enabled
host: 68.170.147.165
auth_type: md5
auth_string: "0 1234"
- name: Ensure HSRP is configured with md5 authentication and hidden
authentication string
nxos_hsrp:
group: 10
vip: 10.1.1.1
priority: 150
interface: vlan10
preempt: enabled
host: 68.170.147.165
auth_type: md5
auth_string: "7 1234"
- name: Remove HSRP config for given interface, group, and VIP
nxos_hsrp:
group: 10
interface: vlan10
vip: 10.1.1.1
host: 68.170.147.165
state: absent
s�
commands:
description: commands sent to the device
returned: always
type: list
sample: ["interface vlan10", "hsrp version 2", "hsrp 30", "ip 10.30.1.1"]
i����( t load_configt run_commands( t get_capabilitiest nxos_argument_spec( t get_interface_type( t
AnsibleModulet vipt 100t priorityt textt auth_typet ciscot auth_stringc C se i } xX | D]P } | j | � } | r
| j | � } | rP t | � | | <q] | | | <q
q
W| S( N( t gett str( t key_mapt tablet new_dictt keyt new_keyt value( ( sJ /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_hsrp.pyt
apply_key_map� s
c C s� d j | � } i } d } y t | | g � d } Wn t k
rI d SX| d k r� | d d } t | j d d � � } | d
k s� | d k r� d } q� n | d
k r� d } n | S( Ns show interface {0} | jsont unknowni t ethernett portchannelt TABLE_interfacet
ROW_interfacet eth_modet layer3t accesst trunkt layer2t svi( R R ( t formatR t
IndexErrort NoneR R ( t interfacet intf_typet modulet commandt modet bodyt interface_table( ( sJ /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_hsrp.pyt get_interface_mode� s
c
C s� d j | � } i } i d d 6d d 6d d 6d d 6d
d 6d d
6d d 6d d 6d d 6} ye t | | g � d } | d d } d | k r� | d =n d t | � k r� t | | | � } n Wn t t t t f k
r� i SXt | t � r� | g } n x� | D]� } t
| | � } | d j � | d <| d d k rHd | d <n | d d k red | d <n | d d k r�| d d k r�d | d <q�d | d <n | d | k r| SqW| S( Ns show hsrp group {0} all | jsonR) t sh_if_indext groupt sh_group_numt versiont sh_group_versionR
t sh_cfg_priot preemptt
sh_preemptR t sh_vipR t sh_authentication_typet auth_enct sh_keystring_attrR t sh_authentication_datai t TABLE_grp_detailt ROW_grp_details
unknown enum:t v1t 1t v2t 2t md5t hiddent 7t 0( R&