| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
# Copyright 2025 Red Hat |
| 4 |
# GNU General Public License v3.0+ |
| 5 |
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 6 |
|
| 7 |
""" |
| 8 |
The module file for ios_evpn_ethernet |
| 9 |
""" |
| 10 |
|
| 11 |
from __future__ import absolute_import, division, print_function |
| 12 |
|
| 13 |
|
| 14 |
__metaclass__ = type |
| 15 |
|
| 16 |
DOCUMENTATION = """ |
| 17 |
module: ios_evpn_ethernet |
| 18 |
short_description: Resource module to configure L2VPN EVPN Ethernet Segment. |
| 19 |
description: This module manages the L2VPN EVPN Ethernet Segment attributes of Cisco IOS network devices. |
| 20 |
version_added: 9.2.0 |
| 21 |
author: |
| 22 |
- Sagar Paul (@KB-perByte) |
| 23 |
- Jorgen Spange (@jorgenspange) |
| 24 |
notes: |
| 25 |
- Tested against Cisco IOSXE Version 17.16. |
| 26 |
- This module works with connection C(network_cli). |
| 27 |
See U(https://docs.ansible.com/ansible/latest/network/user_guide/platform_ios.html) |
| 28 |
- The module examples uses callback plugin (callback_result_format=yaml) to generate task |
| 29 |
output in yaml format. |
| 30 |
options: |
| 31 |
config: |
| 32 |
description: A dictionary of L2VPN EVPN Ethernet Segment options |
| 33 |
type: list |
| 34 |
elements: dict |
| 35 |
suboptions: |
| 36 |
segment: |
| 37 |
description: |
| 38 |
- L2VPN EVPN Ethernet Segment, l2vpn evpn ethernet-segment 1 |
| 39 |
type: str |
| 40 |
required: true |
| 41 |
default: |
| 42 |
description: Set a command to its defaults |
| 43 |
type: bool |
| 44 |
df_election: |
| 45 |
description: Designated forwarder election parameters |
| 46 |
type: dict |
| 47 |
suboptions: |
| 48 |
preempt_time: |
| 49 |
description: Preempt time before advertising routes |
| 50 |
type: int |
| 51 |
wait_time: |
| 52 |
description: Designated forwarder election wait time |
| 53 |
type: int |
| 54 |
identifier: |
| 55 |
description: Ethernet Segment Identifiers |
| 56 |
type: dict |
| 57 |
suboptions: |
| 58 |
identifier_type: |
| 59 |
description: |
| 60 |
- Type 0 (arbitrary 9-octet ESI value) |
| 61 |
- Type 3 (MAC-based ESI value) |
| 62 |
type: str |
| 63 |
choices: |
| 64 |
- '0' |
| 65 |
- '3' |
| 66 |
esi_value: |
| 67 |
description: system mac or 9-octet ESI value in hex |
| 68 |
type: str |
| 69 |
redundancy: |
| 70 |
description: Multi-homing redundancy parameters |
| 71 |
type: dict |
| 72 |
suboptions: |
| 73 |
all_active: |
| 74 |
description: Per-flow load-balancing between PEs on same Ethernet Segment |
| 75 |
type: bool |
| 76 |
single_active: |
| 77 |
description: Per-vlan load-balancing between PEs on same Ethernet Segment |
| 78 |
type: bool |
| 79 |
running_config: |
| 80 |
description: |
| 81 |
- This option is used only with state I(parsed). |
| 82 |
- The value of this option should be the output received from the IOS device by |
| 83 |
executing the command B(show running-config | section ^l2vpn). |
| 84 |
- The state I(parsed) reads the configuration from C(running_config) option and |
| 85 |
transforms it into Ansible structured data as per the resource module's argspec |
| 86 |
and the value is then returned in the I(parsed) key within the result. |
| 87 |
type: str |
| 88 |
state: |
| 89 |
choices: |
| 90 |
- merged |
| 91 |
- replaced |
| 92 |
- overridden |
| 93 |
- deleted |
| 94 |
- rendered |
| 95 |
- gathered |
| 96 |
- purged |
| 97 |
- parsed |
| 98 |
default: merged |
| 99 |
description: |
| 100 |
- The state the configuration should be left in |
| 101 |
- The states I(rendered), I(gathered) and I(parsed) does not perform any change |
| 102 |
on the device. |
| 103 |
- The state I(rendered) will transform the configuration in C(config) option to |
| 104 |
platform specific CLI commands which will be returned in the I(rendered) key |
| 105 |
within the result. For state I(rendered) active connection to remote host is |
| 106 |
not required. |
| 107 |
- The state I(gathered) will fetch the running configuration from device and transform |
| 108 |
it into structured data in the format as per the resource module argspec and |
| 109 |
the value is returned in the I(gathered) key within the result. |
| 110 |
- The state I(parsed) reads the configuration from C(running_config) option and |
| 111 |
transforms it into JSON format as per the resource module parameters and the |
| 112 |
value is returned in the I(parsed) key within the result. The value of C(running_config) |
| 113 |
option should be the same format as the output of command I(show running-config |
| 114 |
| section ^l2vpn) executed on device. For state I(parsed) active |
| 115 |
connection to remote host is not required. |
| 116 |
- The state I(purged) negates virtual/logical interfaces that are specified in task |
| 117 |
from running-config. |
| 118 |
type: str |
| 119 |
""" |
| 120 |
|
| 121 |
EXAMPLES = """ |
| 122 |
# Using merged |
| 123 |
|
| 124 |
# Before state: |
| 125 |
# ------------- |
| 126 |
# |
| 127 |
# vios#sh running-config | section ^l2vpn evpn ethernet-segment |
| 128 |
# l2vpn evpn ethernet-segment 1 |
| 129 |
# identifier type 0 00.00.00.00.00.00.00.00.01 |
| 130 |
# redundancy single-active |
| 131 |
# ! |
| 132 |
# l2vpn evpn ethernet-segment 2 |
| 133 |
# identifier type 0 00.00.00.00.00.00.00.00.02 |
| 134 |
# redundancy single-active |
| 135 |
# df-election preempt-time 1 |
| 136 |
# ! |
| 137 |
# l2vpn evpn ethernet-segment 3 |
| 138 |
# identifier type 3 system-mac 00.00.00.00.00.00.00.00.03 |
| 139 |
# redundancy single-active |
| 140 |
# ! |
| 141 |
# l2vpn evpn ethernet-segment 4 |
| 142 |
# identifier type 0 00.00.00.00.00.00.00.00.04 |
| 143 |
# redundancy all-active |
| 144 |
# df-election wait-time 1 |
| 145 |
# ! |
| 146 |
|
| 147 |
- name: Gather facts of evpn ethernet segment |
| 148 |
cisco.ios.ios_evpn_ethernet: |
| 149 |
config: |
| 150 |
- identifier: |
| 151 |
identifier_type: '0' |
| 152 |
esi_value: 00.00.00.00.00.00.00.00.01 |
| 153 |
redundancy: |
| 154 |
single_active: true |
| 155 |
segment: '1' |
| 156 |
- df_election: |
| 157 |
preempt_time: 1 |
| 158 |
identifier: |
| 159 |
identifier_type: '0' |
| 160 |
esi_value: 00.00.00.00.00.00.00.00.02 |
| 161 |
redundancy: |
| 162 |
single_active: true |
| 163 |
segment: '2' |
| 164 |
- identifier: |
| 165 |
identifier_type: '3' |
| 166 |
esi_value: 00.00.00.00.00.00.00.00.03 |
| 167 |
redundancy: |
| 168 |
single_active: true |
| 169 |
segment: '3' |
| 170 |
- df_election: |
| 171 |
wait_time: 1 |
| 172 |
identifier: |
| 173 |
identifier_type: '0' |
| 174 |
esi_value: 00.00.00.00.00.00.00.00.04 |
| 175 |
redundancy: |
| 176 |
all_active: true |
| 177 |
segment: '4' |
| 178 |
- df_election: |
| 179 |
wait_time: 1 |
| 180 |
identifier: |
| 181 |
identifier_type: '0' |
| 182 |
esi_value: 00.00.00.00.00.00.00.00.05 |
| 183 |
redundancy: |
| 184 |
all_active: true |
| 185 |
segment: '5' |
| 186 |
state: merged |
| 187 |
|
| 188 |
# Task Output |
| 189 |
# ----------- |
| 190 |
# |
| 191 |
# before: |
| 192 |
# - identifier: |
| 193 |
# identifier_type: '0' |
| 194 |
# esi_value: 00.00.00.00.00.00.00.00.01 |
| 195 |
# redundancy: |
| 196 |
# single_active: true |
| 197 |
# segment: '1' |
| 198 |
# - df_election: |
| 199 |
# preempt_time: 1 |
| 200 |
# identifier: |
| 201 |
# identifier_type: '0' |
| 202 |
# esi_value: 00.00.00.00.00.00.00.00.02 |
| 203 |
# redundancy: |
| 204 |
# single_active: true |
| 205 |
# segment: '2' |
| 206 |
# - identifier: |
| 207 |
# identifier_type: '3' |
| 208 |
# esi_value: 00.00.00.00.00.00.00.00.03 |
| 209 |
# redundancy: |
| 210 |
# single_active: true |
| 211 |
# segment: '3' |
| 212 |
# - df_election: |
| 213 |
# wait_time: 1 |
| 214 |
# identifier: |
| 215 |
# identifier_type: '0' |
| 216 |
# esi_value: 00.00.00.00.00.00.00.00.04 |
| 217 |
# redundancy: |
| 218 |
# all_active: true |
| 219 |
# segment: '4' |
| 220 |
# commands: |
| 221 |
# - l2vpn evpn ethernet-segment 5 |
| 222 |
# - identifier type 0 00.00.00.00.00.00.00.00.05 |
| 223 |
# - redundancy all-active |
| 224 |
# - df-election wait-time 1 |
| 225 |
# after: |
| 226 |
# - identifier: |
| 227 |
# identifier_type: '0' |
| 228 |
# esi_value: 00.00.00.00.00.00.00.00.01 |
| 229 |
# redundancy: |
| 230 |
# single_active: true |
| 231 |
# segment: '1' |
| 232 |
# - df_election: |
| 233 |
# preempt_time: 1 |
| 234 |
# identifier: |
| 235 |
# identifier_type: '0' |
| 236 |
# esi_value: 00.00.00.00.00.00.00.00.02 |
| 237 |
# redundancy: |
| 238 |
# single_active: true |
| 239 |
# segment: '2' |
| 240 |
# - identifier: |
| 241 |
# identifier_type: '3' |
| 242 |
# esi_value: 00.00.00.00.00.00.00.00.03 |
| 243 |
# redundancy: |
| 244 |
# single_active: true |
| 245 |
# segment: '3' |
| 246 |
# - df_election: |
| 247 |
# wait_time: 1 |
| 248 |
# identifier: |
| 249 |
# identifier_type: '0' |
| 250 |
# esi_value: 00.00.00.00.00.00.00.00.04 |
| 251 |
# redundancy: |
| 252 |
# all_active: true |
| 253 |
# segment: '4' |
| 254 |
# - df_election: |
| 255 |
# wait_time: 1 |
| 256 |
# identifier: |
| 257 |
# identifier_type: '0' |
| 258 |
# esi_value: 00.00.00.00.00.00.00.00.05 |
| 259 |
# redundancy: |
| 260 |
# all_active: true |
| 261 |
# segment: '5' |
| 262 |
|
| 263 |
# After state: |
| 264 |
# ------------- |
| 265 |
# |
| 266 |
# vios#sh running-config | section ^l2vpn evpn ethernet-segment |
| 267 |
# l2vpn evpn ethernet-segment 1 |
| 268 |
# identifier type 0 00.00.00.00.00.00.00.00.01 |
| 269 |
# redundancy single-active |
| 270 |
# ! |
| 271 |
# l2vpn evpn ethernet-segment 2 |
| 272 |
# identifier type 0 00.00.00.00.00.00.00.00.02 |
| 273 |
# redundancy single-active |
| 274 |
# df-election preempt-time 1 |
| 275 |
# ! |
| 276 |
# l2vpn evpn ethernet-segment 3 |
| 277 |
# identifier type 3 system-mac 00.00.00.00.00.00.00.00.03 |
| 278 |
# redundancy single-active |
| 279 |
# ! |
| 280 |
# l2vpn evpn ethernet-segment 4 |
| 281 |
# identifier type 0 00.00.00.00.00.00.00.00.04 |
| 282 |
# redundancy all-active |
| 283 |
# df-election wait-time 1 |
| 284 |
# ! |
| 285 |
# l2vpn evpn ethernet-segment 5 |
| 286 |
# identifier type 0 00.00.00.00.00.00.00.00.05 |
| 287 |
# redundancy all-active |
| 288 |
# df-election wait-time 1 |
| 289 |
# ! |
| 290 |
|
| 291 |
# Using replaced |
| 292 |
|
| 293 |
# Before state: |
| 294 |
# ------------- |
| 295 |
# |
| 296 |
# vios#sh running-config | section ^l2vpn evpn ethernet-segment |
| 297 |
# l2vpn evpn ethernet-segment 1 |
| 298 |
# identifier type 0 00.00.00.00.00.00.00.00.01 |
| 299 |
# redundancy single-active |
| 300 |
# ! |
| 301 |
# l2vpn evpn ethernet-segment 2 |
| 302 |
# identifier type 0 00.00.00.00.00.00.00.00.02 |
| 303 |
# redundancy single-active |
| 304 |
# df-election preempt-time 1 |
| 305 |
# ! |
| 306 |
# l2vpn evpn ethernet-segment 3 |
| 307 |
# identifier type 3 system-mac 00.00.00.00.00.00.00.00.03 |
| 308 |
# redundancy single-active |
| 309 |
# ! |
| 310 |
# l2vpn evpn ethernet-segment 4 |
| 311 |
# identifier type 0 00.00.00.00.00.00.00.00.04 |
| 312 |
# redundancy all-active |
| 313 |
# df-election wait-time 1 |
| 314 |
# ! |
| 315 |
|
| 316 |
- name: Gather facts of evpn ethernet segment |
| 317 |
cisco.ios.ios_evpn_ethernet: |
| 318 |
config: |
| 319 |
- df_election: |
| 320 |
wait_time: 1 |
| 321 |
identifier: |
| 322 |
identifier_type: '0' |
| 323 |
esi_value: 00.00.00.00.00.00.00.00.04 |
| 324 |
redundancy: |
| 325 |
single_active: true |
| 326 |
segment: '4' |
| 327 |
- df_election: |
| 328 |
wait_time: 1 |
| 329 |
identifier: |
| 330 |
identifier_type: '0' |
| 331 |
esi_value: 00.00.00.00.00.00.00.00.05 |
| 332 |
redundancy: |
| 333 |
all_active: true |
| 334 |
segment: '5' |
| 335 |
state: replaced |
| 336 |
|
| 337 |
# Task Output |
| 338 |
# ----------- |
| 339 |
# |
| 340 |
# before: |
| 341 |
# - identifier: |
| 342 |
# identifier_type: '0' |
| 343 |
# esi_value: 00.00.00.00.00.00.00.00.01 |
| 344 |
# redundancy: |
| 345 |
# single_active: true |
| 346 |
# segment: '1' |
| 347 |
# - df_election: |
| 348 |
# preempt_time: 1 |
| 349 |
# identifier: |
| 350 |
# identifier_type: '0' |
| 351 |
# esi_value: 00.00.00.00.00.00.00.00.02 |
| 352 |
# redundancy: |
| 353 |
# single_active: true |
| 354 |
# segment: '2' |
| 355 |
# - identifier: |
| 356 |
# identifier_type: '3' |
| 357 |
# esi_value: 00.00.00.00.00.00.00.00.03 |
| 358 |
# redundancy: |
| 359 |
# single_active: true |
| 360 |
# segment: '3' |
| 361 |
# - df_election: |
| 362 |
# wait_time: 1 |
| 363 |
# identifier: |
| 364 |
# identifier_type: '0' |
| 365 |
# esi_value: 00.00.00.00.00.00.00.00.04 |
| 366 |
# redundancy: |
| 367 |
# all_active: true |
| 368 |
# segment: '4' |
| 369 |
# commands: |
| 370 |
# - l2vpn evpn ethernet-segment 4 |
| 371 |
# - redundancy single-active |
| 372 |
# - l2vpn evpn ethernet-segment 5 |
| 373 |
# - identifier type 0 00.00.00.00.00.00.00.00.05 |
| 374 |
# - redundancy all-active |
| 375 |
# - df-election wait-time 1 |
| 376 |
# after: |
| 377 |
# - identifier: |
| 378 |
# identifier_type: '0' |
| 379 |
# esi_value: 00.00.00.00.00.00.00.00.01 |
| 380 |
# redundancy: |
| 381 |
# single_active: true |
| 382 |
# segment: '1' |
| 383 |
# - df_election: |
| 384 |
# preempt_time: 1 |
| 385 |
# identifier: |
| 386 |
# identifier_type: '0' |
| 387 |
# esi_value: 00.00.00.00.00.00.00.00.02 |
| 388 |
# redundancy: |
| 389 |
# single_active: true |
| 390 |
# segment: '2' |
| 391 |
# - identifier: |
| 392 |
# identifier_type: '3' |
| 393 |
# esi_value: 00.00.00.00.00.00.00.00.03 |
| 394 |
# redundancy: |
| 395 |
# single_active: true |
| 396 |
# segment: '3' |
| 397 |
# - df_election: |
| 398 |
# wait_time: 1 |
| 399 |
# identifier: |
| 400 |
# identifier_type: '0' |
| 401 |
# esi_value: 00.00.00.00.00.00.00.00.04 |
| 402 |
# redundancy: |
| 403 |
# single_active: true |
| 404 |
# segment: '4' |
| 405 |
# - df_election: |
| 406 |
# wait_time: 1 |
| 407 |
# identifier: |
| 408 |
# identifier_type: '0' |
| 409 |
# esi_value: 00.00.00.00.00.00.00.00.05 |
| 410 |
# redundancy: |
| 411 |
# all_active: true |
| 412 |
# segment: '5' |
| 413 |
|
| 414 |
# After state: |
| 415 |
# ------------- |
| 416 |
# |
| 417 |
# vios#sh running-config | section ^l2vpn evpn ethernet-segment |
| 418 |
# l2vpn evpn ethernet-segment 1 |
| 419 |
# identifier type 0 00.00.00.00.00.00.00.00.01 |
| 420 |
# redundancy single-active |
| 421 |
# ! |
| 422 |
# l2vpn evpn ethernet-segment 2 |
| 423 |
# identifier type 0 00.00.00.00.00.00.00.00.02 |
| 424 |
# redundancy single-active |
| 425 |
# df-election preempt-time 1 |
| 426 |
# ! |
| 427 |
# l2vpn evpn ethernet-segment 3 |
| 428 |
# identifier type 3 system-mac 00.00.00.00.00.00.00.00.03 |
| 429 |
# redundancy single-active |
| 430 |
# ! |
| 431 |
# l2vpn evpn ethernet-segment 4 |
| 432 |
# identifier type 0 00.00.00.00.00.00.00.00.04 |
| 433 |
# redundancy single-active |
| 434 |
# df-election wait-time 1 |
| 435 |
# ! |
| 436 |
# l2vpn evpn ethernet-segment 5 |
| 437 |
# identifier type 0 00.00.00.00.00.00.00.00.05 |
| 438 |
# redundancy all-active |
| 439 |
# df-election wait-time 1 |
| 440 |
# ! |
| 441 |
|
| 442 |
# Using overridden |
| 443 |
|
| 444 |
# Before state: |
| 445 |
# ------------- |
| 446 |
# |
| 447 |
# vios#sh running-config | section ^l2vpn evpn ethernet-segment |
| 448 |
# l2vpn evpn ethernet-segment 1 |
| 449 |
# identifier type 0 00.00.00.00.00.00.00.00.01 |
| 450 |
# redundancy single-active |
| 451 |
# ! |
| 452 |
# l2vpn evpn ethernet-segment 2 |
| 453 |
# identifier type 0 00.00.00.00.00.00.00.00.02 |
| 454 |
# redundancy single-active |
| 455 |
# df-election preempt-time 1 |
| 456 |
# ! |
| 457 |
# l2vpn evpn ethernet-segment 3 |
| 458 |
# identifier type 3 system-mac 00.00.00.00.00.00.00.00.03 |
| 459 |
# redundancy single-active |
| 460 |
# ! |
| 461 |
# l2vpn evpn ethernet-segment 4 |
| 462 |
# identifier type 0 00.00.00.00.00.00.00.00.04 |
| 463 |
# redundancy all-active |
| 464 |
# df-election wait-time 1 |
| 465 |
# ! |
| 466 |
|
| 467 |
- name: Gather facts of evpn ethernet segment |
| 468 |
cisco.ios.ios_evpn_ethernet: |
| 469 |
config: |
| 470 |
- df_election: |
| 471 |
wait_time: 1 |
| 472 |
identifier: |
| 473 |
identifier_type: '0' |
| 474 |
esi_value: 00.00.00.00.00.00.00.00.04 |
| 475 |
redundancy: |
| 476 |
single_active: true |
| 477 |
segment: '4' |
| 478 |
- df_election: |
| 479 |
wait_time: 1 |
| 480 |
identifier: |
| 481 |
identifier_type: '0' |
| 482 |
esi_value: 00.00.00.00.00.00.00.00.05 |
| 483 |
redundancy: |
| 484 |
all_active: true |
| 485 |
segment: '5' |
| 486 |
state: overridden |
| 487 |
|
| 488 |
# After state: |
| 489 |
# ------------- |
| 490 |
# |
| 491 |
# vios#sh running-config | section ^l2vpn evpn ethernet-segment |
| 492 |
# l2vpn evpn ethernet-segment 4 |
| 493 |
# identifier type 0 00.00.00.00.00.00.00.00.04 |
| 494 |
# redundancy single-active |
| 495 |
# df-election wait-time 1 |
| 496 |
# ! |
| 497 |
# l2vpn evpn ethernet-segment 5 |
| 498 |
# identifier type 0 00.00.00.00.00.00.00.00.05 |
| 499 |
# redundancy all-active |
| 500 |
# df-election wait-time 1 |
| 501 |
# ! |
| 502 |
|
| 503 |
# Using deleted |
| 504 |
|
| 505 |
# Before state: |
| 506 |
# ------------- |
| 507 |
# |
| 508 |
# vios#sh running-config | section ^l2vpn evpn ethernet-segment |
| 509 |
# l2vpn evpn ethernet-segment 1 |
| 510 |
# identifier type 0 00.00.00.00.00.00.00.00.01 |
| 511 |
# redundancy single-active |
| 512 |
# ! |
| 513 |
# l2vpn evpn ethernet-segment 2 |
| 514 |
# identifier type 0 00.00.00.00.00.00.00.00.02 |
| 515 |
# redundancy single-active |
| 516 |
# df-election preempt-time 1 |
| 517 |
# ! |
| 518 |
# l2vpn evpn ethernet-segment 3 |
| 519 |
# identifier type 3 system-mac 00.00.00.00.00.00.00.00.03 |
| 520 |
# redundancy single-active |
| 521 |
# ! |
| 522 |
# l2vpn evpn ethernet-segment 4 |
| 523 |
# identifier type 0 00.00.00.00.00.00.00.00.04 |
| 524 |
# redundancy all-active |
| 525 |
# df-election wait-time 1 |
| 526 |
# ! |
| 527 |
|
| 528 |
- name: Gather facts of evpn ethernet segment |
| 529 |
cisco.ios.ios_evpn_ethernet: |
| 530 |
config: |
| 531 |
- identifier: |
| 532 |
identifier_type: '0' |
| 533 |
esi_value: 00.00.00.00.00.00.00.00.01 |
| 534 |
redundancy: |
| 535 |
single_active: true |
| 536 |
segment: '1' |
| 537 |
- df_election: |
| 538 |
preempt_time: 1 |
| 539 |
identifier: |
| 540 |
identifier_type: '0' |
| 541 |
esi_value: 00.00.00.00.00.00.00.00.02 |
| 542 |
redundancy: |
| 543 |
single_active: true |
| 544 |
segment: '2' |
| 545 |
state: deleted |
| 546 |
|
| 547 |
# Task Output |
| 548 |
# ----------- |
| 549 |
# |
| 550 |
# before: |
| 551 |
# - identifier: |
| 552 |
# identifier_type: '0' |
| 553 |
# esi_value: 00.00.00.00.00.00.00.00.01 |
| 554 |
# redundancy: |
| 555 |
# single_active: true |
| 556 |
# segment: '1' |
| 557 |
# - df_election: |
| 558 |
# preempt_time: 1 |
| 559 |
# identifier: |
| 560 |
# identifier_type: '0' |
| 561 |
# esi_value: 00.00.00.00.00.00.00.00.02 |
| 562 |
# redundancy: |
| 563 |
# single_active: true |
| 564 |
# segment: '2' |
| 565 |
# - identifier: |
| 566 |
# identifier_type: '3' |
| 567 |
# esi_value: 00.00.00.00.00.00.00.00.03 |
| 568 |
# redundancy: |
| 569 |
# single_active: true |
| 570 |
# segment: '3' |
| 571 |
# - df_election: |
| 572 |
# wait_time: 1 |
| 573 |
# identifier: |
| 574 |
# identifier_type: '0' |
| 575 |
# esi_value: 00.00.00.00.00.00.00.00.04 |
| 576 |
# redundancy: |
| 577 |
# all_active: true |
| 578 |
# segment: '4' |
| 579 |
# commands: |
| 580 |
# - l2vpn evpn ethernet-segment 1 |
| 581 |
# - no identifier type 0 00.00.00.00.00.00.00.00.01 |
| 582 |
# - no redundancy single-active |
| 583 |
# - l2vpn evpn ethernet-segment 2 |
| 584 |
# - no identifier type 0 00.00.00.00.00.00.00.00.02 |
| 585 |
# - no redundancy single-active |
| 586 |
# - no df-election wait-time 1 |
| 587 |
# after: |
| 588 |
# - segment: '1' |
| 589 |
# - segment: '2' |
| 590 |
# - identifier: |
| 591 |
# identifier_type: '3' |
| 592 |
# esi_value: 00.00.00.00.00.00.00.00.03 |
| 593 |
# redundancy: |
| 594 |
# single_active: true |
| 595 |
# segment: '3' |
| 596 |
# - df_election: |
| 597 |
# wait_time: 1 |
| 598 |
# identifier: |
| 599 |
# identifier_type: '0' |
| 600 |
# esi_value: 00.00.00.00.00.00.00.00.04 |
| 601 |
# redundancy: |
| 602 |
# all_active: true |
| 603 |
# segment: '4' |
| 604 |
# - df_election: |
| 605 |
# wait_time: 1 |
| 606 |
# identifier: |
| 607 |
# identifier_type: '0' |
| 608 |
# esi_value: 00.00.00.00.00.00.00.00.05 |
| 609 |
# redundancy: |
| 610 |
# all_active: true |
| 611 |
# segment: '5' |
| 612 |
|
| 613 |
# After state: |
| 614 |
# ------------- |
| 615 |
# |
| 616 |
# vios#sh running-config | section ^l2vpn evpn ethernet-segment |
| 617 |
# l2vpn evpn ethernet-segment 1 |
| 618 |
# ! |
| 619 |
# l2vpn evpn ethernet-segment 2 |
| 620 |
# ! |
| 621 |
# l2vpn evpn ethernet-segment 3 |
| 622 |
# identifier type 3 system-mac 00.00.00.00.00.00.00.00.03 |
| 623 |
# redundancy single-active |
| 624 |
# ! |
| 625 |
# l2vpn evpn ethernet-segment 4 |
| 626 |
# identifier type 0 00.00.00.00.00.00.00.00.04 |
| 627 |
# redundancy all-active |
| 628 |
# df-election wait-time 1 |
| 629 |
# ! |
| 630 |
# l2vpn evpn ethernet-segment 5 |
| 631 |
# identifier type 0 00.00.00.00.00.00.00.00.05 |
| 632 |
# redundancy all-active |
| 633 |
# df-election wait-time 1 |
| 634 |
# ! |
| 635 |
|
| 636 |
# Using purged |
| 637 |
|
| 638 |
# Before state: |
| 639 |
# ------------- |
| 640 |
# |
| 641 |
# vios#sh running-config | section ^l2vpn evpn ethernet-segment |
| 642 |
# l2vpn evpn ethernet-segment 1 |
| 643 |
# identifier type 0 00.00.00.00.00.00.00.00.01 |
| 644 |
# redundancy single-active |
| 645 |
# ! |
| 646 |
# l2vpn evpn ethernet-segment 2 |
| 647 |
# identifier type 0 00.00.00.00.00.00.00.00.02 |
| 648 |
# redundancy single-active |
| 649 |
# df-election preempt-time 1 |
| 650 |
# ! |
| 651 |
# l2vpn evpn ethernet-segment 3 |
| 652 |
# identifier type 3 system-mac 00.00.00.00.00.00.00.00.03 |
| 653 |
# redundancy single-active |
| 654 |
# ! |
| 655 |
# l2vpn evpn ethernet-segment 4 |
| 656 |
# identifier type 0 00.00.00.00.00.00.00.00.04 |
| 657 |
# redundancy all-active |
| 658 |
# df-election wait-time 1 |
| 659 |
# ! |
| 660 |
|
| 661 |
- name: Gather facts of evpn ethernet segment |
| 662 |
cisco.ios.ios_evpn_ethernet: |
| 663 |
config: |
| 664 |
- segment: '1' |
| 665 |
- segment: '2' |
| 666 |
state: purged |
| 667 |
|
| 668 |
# Task Output |
| 669 |
# ----------- |
| 670 |
# |
| 671 |
# before: |
| 672 |
# - identifier: |
| 673 |
# identifier_type: '0' |
| 674 |
# esi_value: 00.00.00.00.00.00.00.00.01 |
| 675 |
# redundancy: |
| 676 |
# single_active: true |
| 677 |
# segment: '1' |
| 678 |
# - df_election: |
| 679 |
# preempt_time: 1 |
| 680 |
# identifier: |
| 681 |
# identifier_type: '0' |
| 682 |
# esi_value: 00.00.00.00.00.00.00.00.02 |
| 683 |
# redundancy: |
| 684 |
# single_active: true |
| 685 |
# segment: '2' |
| 686 |
# - identifier: |
| 687 |
# identifier_type: '3' |
| 688 |
# esi_value: 00.00.00.00.00.00.00.00.03 |
| 689 |
# redundancy: |
| 690 |
# single_active: true |
| 691 |
# segment: '3' |
| 692 |
# - df_election: |
| 693 |
# wait_time: 1 |
| 694 |
# identifier: |
| 695 |
# identifier_type: '0' |
| 696 |
# esi_value: 00.00.00.00.00.00.00.00.04 |
| 697 |
# redundancy: |
| 698 |
# all_active: true |
| 699 |
# segment: '4' |
| 700 |
# commands: |
| 701 |
# - no l2vpn evpn ethernet-segment 1 |
| 702 |
# - no l2vpn evpn ethernet-segment 2 |
| 703 |
# after: |
| 704 |
# - identifier: |
| 705 |
# identifier_type: '3' |
| 706 |
# esi_value: 00.00.00.00.00.00.00.00.03 |
| 707 |
# redundancy: |
| 708 |
# single_active: true |
| 709 |
# segment: '3' |
| 710 |
# - df_election: |
| 711 |
# wait_time: 1 |
| 712 |
# identifier: |
| 713 |
# identifier_type: '0' |
| 714 |
# esi_value: 00.00.00.00.00.00.00.00.04 |
| 715 |
# redundancy: |
| 716 |
# all_active: true |
| 717 |
# segment: '4' |
| 718 |
# - df_election: |
| 719 |
# wait_time: 1 |
| 720 |
# identifier: |
| 721 |
# identifier_type: '0' |
| 722 |
# esi_value: 00.00.00.00.00.00.00.00.05 |
| 723 |
# redundancy: |
| 724 |
# all_active: true |
| 725 |
# segment: '5' |
| 726 |
|
| 727 |
# After state: |
| 728 |
# ------------- |
| 729 |
# |
| 730 |
# vios#sh running-config | section ^l2vpn evpn ethernet-segment |
| 731 |
# l2vpn evpn ethernet-segment 3 |
| 732 |
# identifier type 3 system-mac 00.00.00.00.00.00.00.00.03 |
| 733 |
# redundancy single-active |
| 734 |
# ! |
| 735 |
# l2vpn evpn ethernet-segment 4 |
| 736 |
# identifier type 0 00.00.00.00.00.00.00.00.04 |
| 737 |
# redundancy all-active |
| 738 |
# df-election wait-time 1 |
| 739 |
# ! |
| 740 |
# l2vpn evpn ethernet-segment 5 |
| 741 |
# identifier type 0 00.00.00.00.00.00.00.00.05 |
| 742 |
# redundancy all-active |
| 743 |
# df-election wait-time 1 |
| 744 |
# ! |
| 745 |
|
| 746 |
# Using gathered |
| 747 |
|
| 748 |
# Before state: |
| 749 |
# ------------- |
| 750 |
# |
| 751 |
# vios#sh running-config | section ^l2vpn evpn ethernet-segment |
| 752 |
# l2vpn evpn ethernet-segment 1 |
| 753 |
# identifier type 0 00.00.00.00.00.00.00.00.01 |
| 754 |
# redundancy single-active |
| 755 |
# ! |
| 756 |
# l2vpn evpn ethernet-segment 2 |
| 757 |
# identifier type 0 00.00.00.00.00.00.00.00.02 |
| 758 |
# redundancy single-active |
| 759 |
# df-election preempt-time 1 |
| 760 |
# ! |
| 761 |
# l2vpn evpn ethernet-segment 3 |
| 762 |
# identifier type 3 system-mac 00.00.00.00.00.00.00.00.03 |
| 763 |
# redundancy single-active |
| 764 |
# ! |
| 765 |
# l2vpn evpn ethernet-segment 4 |
| 766 |
# identifier type 0 00.00.00.00.00.00.00.00.04 |
| 767 |
# redundancy all-active |
| 768 |
# df-election wait-time 1 |
| 769 |
# ! |
| 770 |
|
| 771 |
- name: Gather facts of evpn ethernet segment |
| 772 |
cisco.ios.ios_evpn_ethernet: |
| 773 |
config: |
| 774 |
state: gathered |
| 775 |
|
| 776 |
# Task Output |
| 777 |
# ----------- |
| 778 |
# |
| 779 |
# gathered: |
| 780 |
# - identifier: |
| 781 |
# identifier_type: '0' |
| 782 |
# esi_value: 00.00.00.00.00.00.00.00.01 |
| 783 |
# redundancy: |
| 784 |
# single_active: true |
| 785 |
# segment: '1' |
| 786 |
# - df_election: |
| 787 |
# preempt_time: 1 |
| 788 |
# identifier: |
| 789 |
# identifier_type: '0' |
| 790 |
# esi_value: 00.00.00.00.00.00.00.00.02 |
| 791 |
# redundancy: |
| 792 |
# single_active: true |
| 793 |
# segment: '2' |
| 794 |
# - identifier: |
| 795 |
# identifier_type: '3' |
| 796 |
# esi_value: 00.00.00.00.00.00.00.00.03 |
| 797 |
# redundancy: |
| 798 |
# single_active: true |
| 799 |
# segment: '3' |
| 800 |
# - df_election: |
| 801 |
# wait_time: 1 |
| 802 |
# identifier: |
| 803 |
# identifier_type: '0' |
| 804 |
# esi_value: 00.00.00.00.00.00.00.00.04 |
| 805 |
# redundancy: |
| 806 |
# all_active: true |
| 807 |
# segment: '4' |
| 808 |
|
| 809 |
# Using rendered |
| 810 |
|
| 811 |
- name: Render commands with provided configuration |
| 812 |
cisco.ios.ios_evpn_ethernet: |
| 813 |
config: |
| 814 |
- identifier: |
| 815 |
identifier_type: '0' |
| 816 |
esi_value: 00.00.00.00.00.00.00.00.01 |
| 817 |
redundancy: |
| 818 |
single_active: true |
| 819 |
segment: '1' |
| 820 |
- df_election: |
| 821 |
preempt_time: 1 |
| 822 |
identifier: |
| 823 |
identifier_type: '0' |
| 824 |
esi_value: 00.00.00.00.00.00.00.00.02 |
| 825 |
redundancy: |
| 826 |
single_active: true |
| 827 |
segment: '2' |
| 828 |
- identifier: |
| 829 |
identifier_type: '3' |
| 830 |
esi_value: 00.00.00.00.00.00.00.00.03 |
| 831 |
redundancy: |
| 832 |
single_active: true |
| 833 |
segment: '3' |
| 834 |
- df_election: |
| 835 |
wait_time: 1 |
| 836 |
identifier: |
| 837 |
identifier_type: '0' |
| 838 |
esi_value: 00.00.00.00.00.00.00.00.04 |
| 839 |
redundancy: |
| 840 |
all_active: true |
| 841 |
segment: '4' |
| 842 |
state: rendered |
| 843 |
|
| 844 |
# Task Output |
| 845 |
# ----------- |
| 846 |
# |
| 847 |
# rendered: |
| 848 |
# - l2vpn evpn ethernet-segment 1 |
| 849 |
# - redundancy single-active |
| 850 |
# - identifier type 0 00.00.00.00.00.00.00.00.01 |
| 851 |
# - l2vpn evpn ethernet-segment 2 |
| 852 |
# - df-election preempt-time 1 |
| 853 |
# - redundancy single-active |
| 854 |
# - identifier type 0 00.00.00.00.00.00.00.00.02 |
| 855 |
# - l2vpn evpn ethernet-segment 3 |
| 856 |
# - redundancy single-active |
| 857 |
# - identifier type 3 system-mac 00.00.00.00.00.00.00.00.03 |
| 858 |
# - l2vpn evpn ethernet-segment 4 |
| 859 |
# - df-election wait-time 1 |
| 860 |
# - redundancy all-active |
| 861 |
# - identifier type 0 00.00.00.00.00.00.00.00.04 |
| 862 |
|
| 863 |
# Using parsed |
| 864 |
|
| 865 |
# File: parsed.cfg |
| 866 |
# ---------------- |
| 867 |
# |
| 868 |
# l2vpn evpn ethernet-segment 1 |
| 869 |
# identifier type 0 00.00.00.00.00.00.00.00.01 |
| 870 |
# redundancy single-active |
| 871 |
# ! |
| 872 |
# l2vpn evpn ethernet-segment 2 |
| 873 |
# identifier type 0 00.00.00.00.00.00.00.00.02 |
| 874 |
# redundancy single-active |
| 875 |
# df-election preempt-time 1 |
| 876 |
# ! |
| 877 |
# l2vpn evpn ethernet-segment 3 |
| 878 |
# identifier type 3 system-mac 00.00.00.00.00.00.00.00.03 |
| 879 |
# redundancy single-active |
| 880 |
# ! |
| 881 |
# l2vpn evpn ethernet-segment 4 |
| 882 |
# identifier type 0 00.00.00.00.00.00.00.00.04 |
| 883 |
# redundancy all-active |
| 884 |
# df-election wait-time 1 |
| 885 |
# ! |
| 886 |
|
| 887 |
- name: Parse the provided configuration |
| 888 |
cisco.ios.ios_evpn_ethernet: |
| 889 |
running_config: "{{ lookup('file', 'ios_ethernet_segment_parsed.cfg') }}" |
| 890 |
state: parsed |
| 891 |
|
| 892 |
# Task Output |
| 893 |
# ----------- |
| 894 |
# |
| 895 |
# parsed: |
| 896 |
# - identifier: |
| 897 |
# identifier_type: '0' |
| 898 |
# esi_value: 00.00.00.00.00.00.00.00.01 |
| 899 |
# redundancy: |
| 900 |
# single_active: true |
| 901 |
# segment: '1' |
| 902 |
# - df_election: |
| 903 |
# preempt_time: 1 |
| 904 |
# identifier: |
| 905 |
# identifier_type: '0' |
| 906 |
# esi_value: 00.00.00.00.00.00.00.00.02 |
| 907 |
# redundancy: |
| 908 |
# single_active: true |
| 909 |
# segment: '2' |
| 910 |
# - identifier: |
| 911 |
# identifier_type: '3' |
| 912 |
# esi_value: 00.00.00.00.00.00.00.00.03 |
| 913 |
# redundancy: |
| 914 |
# single_active: true |
| 915 |
# segment: '3' |
| 916 |
# - df_election: |
| 917 |
# wait_time: 1 |
| 918 |
# identifier: |
| 919 |
# identifier_type: '0' |
| 920 |
# esi_value: 00.00.00.00.00.00.00.00.04 |
| 921 |
# redundancy: |
| 922 |
# all_active: true |
| 923 |
# segment: '4' |
| 924 |
""" |
| 925 |
|
| 926 |
RETURN = """ |
| 927 |
before: |
| 928 |
description: The configuration prior to the module execution. |
| 929 |
returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) |
| 930 |
type: list |
| 931 |
sample: > |
| 932 |
This output will always be in the same format as the |
| 933 |
module argspec. |
| 934 |
after: |
| 935 |
description: The resulting configuration after module execution. |
| 936 |
returned: when changed |
| 937 |
type: list |
| 938 |
sample: > |
| 939 |
This output will always be in the same format as the |
| 940 |
module argspec. |
| 941 |
commands: |
| 942 |
description: The set of commands pushed to the remote device. |
| 943 |
returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) |
| 944 |
type: list |
| 945 |
sample: |
| 946 |
- l2vpn evpn ethernet-segment 1 |
| 947 |
- identifier type 0 00.00.00.00.00.00.00.00.01 |
| 948 |
- redundancy single-active |
| 949 |
rendered: |
| 950 |
description: The provided configuration in the task rendered in device-native format (offline). |
| 951 |
returned: when I(state) is C(rendered) |
| 952 |
type: list |
| 953 |
sample: |
| 954 |
- l2vpn evpn ethernet-segment 1 |
| 955 |
- identifier type 3 system-mac 0000.0000.0000.0001 |
| 956 |
- redundancy all-active |
| 957 |
gathered: |
| 958 |
description: Facts about the network resource gathered from the remote device as structured data. |
| 959 |
returned: when I(state) is C(gathered) |
| 960 |
type: list |
| 961 |
sample: > |
| 962 |
This output will always be in the same format as the |
| 963 |
module argspec. |
| 964 |
parsed: |
| 965 |
description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. |
| 966 |
returned: when I(state) is C(parsed) |
| 967 |
type: list |
| 968 |
sample: > |
| 969 |
This output will always be in the same format as the |
| 970 |
module argspec. |
| 971 |
""" |
| 972 |
|
| 973 |
from ansible.module_utils.basic import AnsibleModule |
| 974 |
|
| 975 |
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.argspec.evpn_ethernet.evpn_ethernet import ( |
| 976 |
Evpn_ethernetArgs, |
| 977 |
) |
| 978 |
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.config.evpn_ethernet.evpn_ethernet import ( |
| 979 |
Evpn_ethernet, |
| 980 |
) |
| 981 |
|
| 982 |
|
| 983 |
def main(): |
| 984 |
""" |
| 985 |
Main entry point for module execution |
| 986 |
|
| 987 |
:returns: the result form module invocation |
| 988 |
""" |
| 989 |
module = AnsibleModule( |
| 990 |
argument_spec=Evpn_ethernetArgs.argument_spec, |
| 991 |
mutually_exclusive=[["config", "running_config"]], |
| 992 |
required_if=[ |
| 993 |
["state", "merged", ["config"]], |
| 994 |
["state", "replaced", ["config"]], |
| 995 |
["state", "overridden", ["config"]], |
| 996 |
["state", "rendered", ["config"]], |
| 997 |
["state", "parsed", ["running_config"]], |
| 998 |
], |
| 999 |
supports_check_mode=True, |
| 1000 |
) |
| 1001 |
|
| 1002 |
result = Evpn_ethernet(module).execute_module() |
| 1003 |
module.exit_json(**result) |
| 1004 |
|
| 1005 |
|
| 1006 |
if __name__ == "__main__": |
| 1007 |
main() |