�
�Udac @ s� i d d 6d g d 6d d 6Z d Z d Z d Z d d
l m Z d d l m Z d d l m Z d d
l
m Z m Z d d l
m Z m Z d d l
m Z m Z d � Z d � Z d d � Z d � Z e d k r� e � n d S( s 1.1t metadata_versiont previewt statust networkt supported_bys9
---
module: ios_static_route
version_added: "2.4"
author: "Ricardo Carrillo Cruz (@rcarrillocruz)"
short_description: Manage static IP routes on Cisco IOS network devices
description:
- This module provides declarative management of static
IP routes on Cisco IOS network devices.
notes:
- Tested against IOS 15.6
options:
prefix:
description:
- Network prefix of the static route.
mask:
description:
- Network prefix mask of the static route.
next_hop:
description:
- Next hop IP of the static route.
vrf:
description:
- VRF of the static route.
version_added: "2.8"
interface:
description:
- Interface of the static route.
version_added: "2.8"
name:
description:
- Name of the static route
aliases: ['description']
version_added: "2.8"
admin_distance:
description:
- Admin distance of the static route.
tag:
description:
- Set tag of the static route.
version_added: "2.8"
track:
description:
- Tracked item to depend on for the static route.
version_added: "2.8"
aggregate:
description: List of static route definitions.
state:
description:
- State of the static route configuration.
default: present
choices: ['present', 'absent']
extends_documentation_fragment: ios
sF
- name: configure static route
ios_static_route:
prefix: 192.168.2.0
mask: 255.255.255.0
next_hop: 10.0.0.1
- name: configure black hole in vrf blue depending on tracked item 10
ios_static_route:
prefix: 192.168.2.0
mask: 255.255.255.0
vrf: blue
interface: null0
track: 10
- name: configure ultimate route with name and tag
ios_static_route:
prefix: 192.168.2.0
mask: 255.255.255.0
interface: GigabitEthernet1
name: hello world
tag: 100
- name: remove configuration
ios_static_route:
prefix: 192.168.2.0
mask: 255.255.255.0
next_hop: 10.0.0.1
state: absent
- name: Add static route aggregates
ios_static_route:
aggregate:
- { prefix: 172.16.32.0, mask: 255.255.255.0, next_hop: 10.0.0.8 }
- { prefix: 172.16.33.0, mask: 255.255.255.0, next_hop: 10.0.0.8 }
- name: Remove static route aggregates
ios_static_route:
aggregate:
- { prefix: 172.16.32.0, mask: 255.255.255.0, next_hop: 10.0.0.8 }
- { prefix: 172.16.33.0, mask: 255.255.255.0, next_hop: 10.0.0.8 }
state: absent
s�
commands:
description: The list of configuration mode commands to send to the device
returned: always
type: list
sample:
- ip route 192.168.2.0 255.255.255.0 10.0.0.1
i����( t deepcopy( t findall( t
AnsibleModule( t remove_default_spect validate_ip_address( t
get_configt load_config( t ios_argument_spect
check_argsc
C s� t � } x~| D]v} | d } | d =x� | D]� } | j d � r] | j d � r] | d =n t t | j � � t | j � � A� } | s� Pq. t | � d k r. | d d | d d k o� d k n r. | d s� | d j | d � r. Pq. q. Wd } d } | d } | d } | j d
� }
|
rMd j | d
|
| | f � } n d j | | | f � } x� d d
d d d d g D]� } | j | � r~| d k r�t | j | � j � � d k r�d j | | d | j | � f � } q9| d k rd j | | | j | � f � } q9d j | | j | � f � } q~q~W| d k rc| rc| j d | � q | d k r | r | j | � q q W| S( Nt statet admin_distancei i i t names ip routet prefixt maskt vrft t interfacet next_hopt tagt tracks "%s"t absents no %st present( s names tags track(
t listt gett sett itemst lent
startswitht Nonet joint splitt append( t wantt havet commandst wR t ht difft commandR R R t key( ( sP /usr/lib/python2.7/site-packages/ansible/modules/network/ios/ios_static_route.pyt map_obj_to_commands� s@
(`
!-($%c
C s] g } t | d d �} x>| j � D]0} t d | � } | d d k re i | d d 6} | d 4n
i } | d 4| d } | d } | j i | d
6| d 6d d
6� d } x� | d D]� } | r� | j d � | | <d } q� t | � r | j d | � q� | j � r| j d
| � q� | d k r4| } q� | j d | � q� W| j | � q% W| S( Nt flagss | include ip routes [^"\s]\S*|".+?"i R i i i i R R t 1R t "R R R R R ( s tags names track( R
t
splitlinesR t updateR! t stripR t isdigitR$ (
t modulet objt outt linet
splitted_linet routeR R t next_wordt word( ( sP /usr/lib/python2.7/site-packages/ansible/modules/network/ios/ios_static_route.pyt map_config_to_obj� s4
" c
C sI d d d d d d d d d d
g
} g } | j j d � } | r� x | D]� } | j � } x<