| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
# Copyright 2019 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 |
# WARNING # |
| 9 |
############################################# |
| 10 |
# |
| 11 |
# This file is auto generated by the resource |
| 12 |
# module builder playbook. |
| 13 |
# |
| 14 |
# Do not edit this file manually. |
| 15 |
# |
| 16 |
# Changes to this file will be over written |
| 17 |
# by the resource module builder. |
| 18 |
# |
| 19 |
# Changes should be made in the model used to |
| 20 |
# generate this file or in the resource module |
| 21 |
# builder template. |
| 22 |
# |
| 23 |
############################################# |
| 24 |
|
| 25 |
""" |
| 26 |
The module file for iosxr_lag_interfaces |
| 27 |
""" |
| 28 |
|
| 29 |
from __future__ import absolute_import, division, print_function |
| 30 |
|
| 31 |
|
| 32 |
__metaclass__ = type |
| 33 |
DOCUMENTATION = """ |
| 34 |
module: iosxr_lag_interfaces |
| 35 |
short_description: Resource module to configure LAG interfaces. |
| 36 |
description: |
| 37 |
- This module manages the attributes of LAG/Ether-Bundle interfaces on IOS-XR devices. |
| 38 |
version_added: 1.0.0 |
| 39 |
notes: |
| 40 |
- This module works with connection C(network_cli). See L(the IOS-XR Platform Options,../network/user_guide/platform_iosxr.html). |
| 41 |
author: Nilashish Chakraborty (@NilashishC) |
| 42 |
options: |
| 43 |
config: |
| 44 |
description: A provided Link Aggregation Group (LAG) configuration. |
| 45 |
type: list |
| 46 |
elements: dict |
| 47 |
suboptions: |
| 48 |
name: |
| 49 |
description: |
| 50 |
- Name/Identifier of the LAG/Ether-Bundle to configure. |
| 51 |
type: str |
| 52 |
required: true |
| 53 |
members: |
| 54 |
description: |
| 55 |
- List of member interfaces for the LAG/Ether-Bundle. |
| 56 |
type: list |
| 57 |
elements: dict |
| 58 |
suboptions: |
| 59 |
member: |
| 60 |
description: |
| 61 |
- Name of the member interface. |
| 62 |
type: str |
| 63 |
mode: |
| 64 |
description: |
| 65 |
- Specifies the mode of the operation for the member interface. |
| 66 |
- Mode 'active' runs LACP in active mode. |
| 67 |
- Mode 'on' does not run LACP over the port. |
| 68 |
- Mode 'passive' runs LACP in passive mode over the port. |
| 69 |
- Mode 'inherit' runs LACP as configured in the bundle. |
| 70 |
type: str |
| 71 |
choices: ["on", "active", "passive", "inherit"] |
| 72 |
mode: |
| 73 |
description: |
| 74 |
- LAG mode. |
| 75 |
- Mode 'active' runs LACP in active mode over the port. |
| 76 |
- Mode 'on' does not run LACP over the port. |
| 77 |
- Mode 'passive' runs LACP in passive mode over the port. |
| 78 |
type: str |
| 79 |
choices: ["on", "active", "passive"] |
| 80 |
links: |
| 81 |
description: |
| 82 |
- This dict contains configurable options related to LAG/Ether-Bundle links. |
| 83 |
type: dict |
| 84 |
suboptions: |
| 85 |
max_active: |
| 86 |
description: |
| 87 |
- Specifies the limit on the number of links that can be active in the LAG/Ether-Bundle. |
| 88 |
- Refer to vendor documentation for valid values. |
| 89 |
type: int |
| 90 |
min_active: |
| 91 |
description: |
| 92 |
- Specifies the minimum number of active links needed to bring up the LAG/Ether-Bundle. |
| 93 |
- Refer to vendor documentation for valid values. |
| 94 |
type: int |
| 95 |
load_balancing_hash: |
| 96 |
description: |
| 97 |
- Specifies the hash function used for traffic forwarded over the LAG/Ether-Bundle. |
| 98 |
- Option 'dst-ip' uses the destination IP as the hash function. |
| 99 |
- Option 'src-ip' uses the source IP as the hash function. |
| 100 |
type: str |
| 101 |
choices: ["dst-ip", "src-ip"] |
| 102 |
running_config: |
| 103 |
description: |
| 104 |
- This option is used only with state I(parsed). |
| 105 |
- The value of this option should be the output received from the IOS-XR device |
| 106 |
by executing the command B(show running-config int). |
| 107 |
- The state I(parsed) reads the configuration from C(running_config) option and |
| 108 |
transforms it into Ansible structured data as per the resource module's argspec |
| 109 |
and the value is then returned in the I(parsed) key within the result. |
| 110 |
type: str |
| 111 |
state: |
| 112 |
description: |
| 113 |
- The state of the configuration after module completion. |
| 114 |
type: str |
| 115 |
choices: |
| 116 |
- merged |
| 117 |
- replaced |
| 118 |
- overridden |
| 119 |
- deleted |
| 120 |
- parsed |
| 121 |
- rendered |
| 122 |
- gathered |
| 123 |
default: merged |
| 124 |
|
| 125 |
""" |
| 126 |
EXAMPLES = """ |
| 127 |
# Using merged |
| 128 |
# |
| 129 |
# |
| 130 |
# ------------ |
| 131 |
# Before state |
| 132 |
# ------------ |
| 133 |
# |
| 134 |
# RP/0/0/CPU0:iosxr01#show run int |
| 135 |
# Sun Jul 7 19:42:59.416 UTC |
| 136 |
# interface Loopback888 |
| 137 |
# description test for ansible |
| 138 |
# shutdown |
| 139 |
# ! |
| 140 |
# interface MgmtEth0/0/CPU0/0 |
| 141 |
# ipv4 address 192.0.2.11 255.255.255.0 |
| 142 |
# ! |
| 143 |
# interface GigabitEthernet0/0/0/1 |
| 144 |
# description "GigabitEthernet - 1" |
| 145 |
# ! |
| 146 |
# interface GigabitEthernet0/0/0/2 |
| 147 |
# description "GigabitEthernet - 2" |
| 148 |
# ! |
| 149 |
# interface GigabitEthernet0/0/0/3 |
| 150 |
# description "GigabitEthernet - 3" |
| 151 |
# ! |
| 152 |
# interface GigabitEthernet0/0/0/4 |
| 153 |
# description "GigabitEthernet - 4" |
| 154 |
# ! |
| 155 |
# |
| 156 |
# |
| 157 |
- name: Merge provided configuration with device configuration |
| 158 |
cisco.iosxr.iosxr_lag_interfaces: |
| 159 |
config: |
| 160 |
- name: Bundle-Ether10 |
| 161 |
members: |
| 162 |
- member: GigabitEthernet0/0/0/1 |
| 163 |
mode: inherit |
| 164 |
- member: GigabitEthernet0/0/0/3 |
| 165 |
mode: inherit |
| 166 |
mode: active |
| 167 |
links: |
| 168 |
max_active: 5 |
| 169 |
min_active: 2 |
| 170 |
load_balancing_hash: src-ip |
| 171 |
- name: Bundle-Ether12 |
| 172 |
members: |
| 173 |
- member: GigabitEthernet0/0/0/2 |
| 174 |
mode: passive |
| 175 |
- member: GigabitEthernet0/0/0/4 |
| 176 |
mode: passive |
| 177 |
load_balancing_hash: dst-ip |
| 178 |
state: merged |
| 179 |
|
| 180 |
# |
| 181 |
# |
| 182 |
# ----------- |
| 183 |
# After state |
| 184 |
# ----------- |
| 185 |
# |
| 186 |
# RP/0/0/CPU0:iosxr01#show run int |
| 187 |
# Sun Jul 7 20:51:17.685 UTC |
| 188 |
# interface Bundle-Ether10 |
| 189 |
# lacp mode active |
| 190 |
# bundle load-balancing hash src-ip |
| 191 |
# bundle maximum-active links 5 |
| 192 |
# bundle minimum-active links 2 |
| 193 |
# ! |
| 194 |
# interface Bundle-Ether12 |
| 195 |
# bundle load-balancing hash dst-ip |
| 196 |
# ! |
| 197 |
# interface Loopback888 |
| 198 |
# description test for ansible |
| 199 |
# shutdown |
| 200 |
# ! |
| 201 |
# interface MgmtEth0/0/CPU0/0 |
| 202 |
# ipv4 address 192.0.2.11 255.255.255.0 |
| 203 |
# ! |
| 204 |
# interface GigabitEthernet0/0/0/1 |
| 205 |
# description 'GigabitEthernet - 1" |
| 206 |
# bundle id 10 mode inherit |
| 207 |
# ! |
| 208 |
# interface GigabitEthernet0/0/0/2 |
| 209 |
# description "GigabitEthernet - 2" |
| 210 |
# bundle id 12 mode passive |
| 211 |
# ! |
| 212 |
# interface GigabitEthernet0/0/0/3 |
| 213 |
# description "GigabitEthernet - 3" |
| 214 |
# bundle id 10 mode inherit |
| 215 |
# ! |
| 216 |
# interface GigabitEthernet0/0/0/4 |
| 217 |
# description "GigabitEthernet - 4" |
| 218 |
# bundle id 12 mode passive |
| 219 |
# ! |
| 220 |
# |
| 221 |
|
| 222 |
|
| 223 |
# Using replaced |
| 224 |
# |
| 225 |
# |
| 226 |
# ------------- |
| 227 |
# Before state |
| 228 |
# ------------- |
| 229 |
# |
| 230 |
# |
| 231 |
# RP/0/0/CPU0:iosxr01#sho run int |
| 232 |
# Sun Jul 7 20:58:06.527 UTC |
| 233 |
# interface Bundle-Ether10 |
| 234 |
# lacp mode active |
| 235 |
# bundle load-balancing hash src-ip |
| 236 |
# bundle maximum-active links 5 |
| 237 |
# bundle minimum-active links 2 |
| 238 |
# ! |
| 239 |
# interface Bundle-Ether12 |
| 240 |
# bundle load-balancing hash dst-ip |
| 241 |
# ! |
| 242 |
# interface Loopback888 |
| 243 |
# description test for ansible |
| 244 |
# shutdown |
| 245 |
# ! |
| 246 |
# interface MgmtEth0/0/CPU0/0 |
| 247 |
# ipv4 address 192.0.2.11 255.255.255.0 |
| 248 |
# ! |
| 249 |
# interface GigabitEthernet0/0/0/1 |
| 250 |
# description 'GigabitEthernet - 1" |
| 251 |
# bundle id 10 mode inherit |
| 252 |
# ! |
| 253 |
# interface GigabitEthernet0/0/0/2 |
| 254 |
# description "GigabitEthernet - 2" |
| 255 |
# bundle id 12 mode passive |
| 256 |
# ! |
| 257 |
# interface GigabitEthernet0/0/0/3 |
| 258 |
# description "GigabitEthernet - 3" |
| 259 |
# bundle id 10 mode inherit |
| 260 |
# ! |
| 261 |
# interface GigabitEthernet0/0/0/4 |
| 262 |
# description "GigabitEthernet - 4" |
| 263 |
# bundle id 12 mode passive |
| 264 |
# ! |
| 265 |
# |
| 266 |
# |
| 267 |
- name: Replace device configuration of listed Bundles with provided configurations |
| 268 |
cisco.iosxr.iosxr_lag_interfaces: |
| 269 |
config: |
| 270 |
- name: Bundle-Ether12 |
| 271 |
members: |
| 272 |
- name: GigabitEthernet0/0/0/2 |
| 273 |
mode: passive |
| 274 |
- name: Bundle-Ether11 |
| 275 |
members: |
| 276 |
- name: GigabitEthernet0/0/0/4 |
| 277 |
load_balancing_hash: src-ip |
| 278 |
state: replaced |
| 279 |
# |
| 280 |
# |
| 281 |
# ----------- |
| 282 |
# After state |
| 283 |
# ----------- |
| 284 |
# |
| 285 |
# |
| 286 |
# RP/0/0/CPU0:iosxr01#sh run int |
| 287 |
# Sun Jul 7 21:22:27.397 UTC |
| 288 |
# interface Bundle-Ether10 |
| 289 |
# lacp mode active |
| 290 |
# bundle load-balancing hash src-ip |
| 291 |
# bundle maximum-active links 5 |
| 292 |
# bundle minimum-active links 2 |
| 293 |
# ! |
| 294 |
# interface Bundle-Ether11 |
| 295 |
# bundle load-balancing hash src-ip |
| 296 |
# ! |
| 297 |
# interface Bundle-Ether12 |
| 298 |
# lacp mode passive |
| 299 |
# ! |
| 300 |
# interface Loopback888 |
| 301 |
# description test for ansible |
| 302 |
# shutdown |
| 303 |
# ! |
| 304 |
# interface MgmtEth0/0/CPU0/0 |
| 305 |
# ipv4 address 192.0.2.11 255.255.255.0 |
| 306 |
# ! |
| 307 |
# interface GigabitEthernet0/0/0/1 |
| 308 |
# description 'GigabitEthernet - 1" |
| 309 |
# bundle id 10 mode inherit |
| 310 |
# ! |
| 311 |
# interface GigabitEthernet0/0/0/2 |
| 312 |
# description "GigabitEthernet - 2" |
| 313 |
# bundle id 12 mode on |
| 314 |
# ! |
| 315 |
# interface GigabitEthernet0/0/0/3 |
| 316 |
# description "GigabitEthernet - 3" |
| 317 |
# bundle id 10 mode inherit |
| 318 |
# ! |
| 319 |
# interface GigabitEthernet0/0/0/4 |
| 320 |
# description "GigabitEthernet - 4" |
| 321 |
# bundle id 11 mode on |
| 322 |
# ! |
| 323 |
# |
| 324 |
# |
| 325 |
|
| 326 |
|
| 327 |
# Using overridden |
| 328 |
# |
| 329 |
# |
| 330 |
# ------------ |
| 331 |
# Before state |
| 332 |
# ------------ |
| 333 |
# |
| 334 |
# |
| 335 |
# RP/0/0/CPU0:iosxr01#sh run int |
| 336 |
# Sun Jul 7 21:22:27.397 UTC |
| 337 |
# interface Bundle-Ether10 |
| 338 |
# lacp mode active |
| 339 |
# bundle load-balancing hash src-ip |
| 340 |
# bundle maximum-active links 5 |
| 341 |
# bundle minimum-active links 2 |
| 342 |
# ! |
| 343 |
# interface Bundle-Ether11 |
| 344 |
# bundle load-balancing hash src-ip |
| 345 |
# ! |
| 346 |
# interface Bundle-Ether12 |
| 347 |
# lacp mode passive |
| 348 |
# ! |
| 349 |
# interface Loopback888 |
| 350 |
# description test for ansible |
| 351 |
# shutdown |
| 352 |
# ! |
| 353 |
# interface MgmtEth0/0/CPU0/0 |
| 354 |
# ipv4 address 192.0.2.11 255.255.255.0 |
| 355 |
# ! |
| 356 |
# interface GigabitEthernet0/0/0/1 |
| 357 |
# description 'GigabitEthernet - 1" |
| 358 |
# bundle id 10 mode inherit |
| 359 |
# ! |
| 360 |
# interface GigabitEthernet0/0/0/2 |
| 361 |
# description "GigabitEthernet - 2" |
| 362 |
# bundle id 12 mode on |
| 363 |
# ! |
| 364 |
# interface GigabitEthernet0/0/0/3 |
| 365 |
# description "GigabitEthernet - 3" |
| 366 |
# bundle id 10 mode inherit |
| 367 |
# ! |
| 368 |
# interface GigabitEthernet0/0/0/4 |
| 369 |
# description "GigabitEthernet - 4" |
| 370 |
# bundle id 11 mode on |
| 371 |
# ! |
| 372 |
# |
| 373 |
# |
| 374 |
|
| 375 |
- name: Overrides all device configuration with provided configuration |
| 376 |
cisco.iosxr.iosxr_lag_interfaces: |
| 377 |
config: |
| 378 |
- name: Bundle-Ether10 |
| 379 |
members: |
| 380 |
- member: GigabitEthernet0/0/0/1 |
| 381 |
mode: inherit |
| 382 |
- member: GigabitEthernet0/0/0/2 |
| 383 |
mode: inherit |
| 384 |
mode: active |
| 385 |
load_balancing_hash: dst-ip |
| 386 |
state: overridden |
| 387 |
|
| 388 |
# |
| 389 |
# |
| 390 |
# ------------ |
| 391 |
# After state |
| 392 |
# ------------ |
| 393 |
# |
| 394 |
# |
| 395 |
# RP/0/0/CPU0:iosxr01#sh run int |
| 396 |
# Sun Jul 7 21:43:04.802 UTC |
| 397 |
# interface Bundle-Ether10 |
| 398 |
# lacp mode active |
| 399 |
# bundle load-balancing hash dst-ip |
| 400 |
# ! |
| 401 |
# interface Bundle-Ether11 |
| 402 |
# ! |
| 403 |
# interface Bundle-Ether12 |
| 404 |
# ! |
| 405 |
# interface Loopback888 |
| 406 |
# description test for ansible |
| 407 |
# shutdown |
| 408 |
# ! |
| 409 |
# interface MgmtEth0/0/CPU0/0 |
| 410 |
# ipv4 address 192.0.2.11 255.255.255.0 |
| 411 |
# ! |
| 412 |
# interface GigabitEthernet0/0/0/1 |
| 413 |
# description 'GigabitEthernet - 1" |
| 414 |
# bundle id 10 mode inherit |
| 415 |
# ! |
| 416 |
# interface GigabitEthernet0/0/0/2 |
| 417 |
# description "GigabitEthernet - 2" |
| 418 |
# bundle id 10 mode inherit |
| 419 |
# ! |
| 420 |
# interface GigabitEthernet0/0/0/3 |
| 421 |
# description "GigabitEthernet - 3" |
| 422 |
# ! |
| 423 |
# interface GigabitEthernet0/0/0/4 |
| 424 |
# description "GigabitEthernet - 4" |
| 425 |
# ! |
| 426 |
# |
| 427 |
# |
| 428 |
|
| 429 |
|
| 430 |
# Using deleted |
| 431 |
# |
| 432 |
# |
| 433 |
# ------------ |
| 434 |
# Before state |
| 435 |
# ------------ |
| 436 |
# |
| 437 |
# RP/0/0/CPU0:iosxr01#sh run int |
| 438 |
# Sun Jul 7 21:22:27.397 UTC |
| 439 |
# interface Bundle-Ether10 |
| 440 |
# lacp mode active |
| 441 |
# bundle load-balancing hash src-ip |
| 442 |
# bundle maximum-active links 5 |
| 443 |
# bundle minimum-active links 2 |
| 444 |
# ! |
| 445 |
# interface Bundle-Ether11 |
| 446 |
# bundle load-balancing hash src-ip |
| 447 |
# ! |
| 448 |
# interface Bundle-Ether12 |
| 449 |
# lacp mode passive |
| 450 |
# ! |
| 451 |
# interface Loopback888 |
| 452 |
# description test for ansible |
| 453 |
# shutdown |
| 454 |
# ! |
| 455 |
# interface MgmtEth0/0/CPU0/0 |
| 456 |
# ipv4 address 192.0.2.11 255.255.255.0 |
| 457 |
# ! |
| 458 |
# interface GigabitEthernet0/0/0/1 |
| 459 |
# description 'GigabitEthernet - 1" |
| 460 |
# bundle id 10 mode inherit |
| 461 |
# ! |
| 462 |
# interface GigabitEthernet0/0/0/2 |
| 463 |
# description "GigabitEthernet - 2" |
| 464 |
# bundle id 12 mode on |
| 465 |
# !n |
| 466 |
# interface GigabitEthernet0/0/0/3 |
| 467 |
# description "GigabitEthernet - 3" |
| 468 |
# bundle id 10 mode inherit |
| 469 |
# ! |
| 470 |
# interface GigabitEthernet0/0/0/4 |
| 471 |
# description "GigabitEthernet - 4" |
| 472 |
# bundle id 11 mode on |
| 473 |
# ! |
| 474 |
# |
| 475 |
# |
| 476 |
|
| 477 |
- name: >- |
| 478 |
Delete attributes of given bundles and removes member interfaces from them |
| 479 |
(Note - This won't delete the bundles themselves) |
| 480 |
cisco.iosxr.iosxr_lag_interfaces: |
| 481 |
config: |
| 482 |
- name: Bundle-Ether10 |
| 483 |
- name: Bundle-Ether11 |
| 484 |
- name: Bundle-Ether12 |
| 485 |
state: deleted |
| 486 |
|
| 487 |
|
| 488 |
# |
| 489 |
# |
| 490 |
# ------------ |
| 491 |
# After state |
| 492 |
# ------------ |
| 493 |
# |
| 494 |
# RP/0/0/CPU0:iosxr01#sh run int |
| 495 |
# Sun Jul 7 21:49:50.004 UTC |
| 496 |
# interface Bundle-Ether10 |
| 497 |
# ! |
| 498 |
# interface Bundle-Ether11 |
| 499 |
# ! |
| 500 |
# interface Bundle-Ether12 |
| 501 |
# ! |
| 502 |
# interface Loopback888 |
| 503 |
# description test for ansible |
| 504 |
# shutdown |
| 505 |
# ! |
| 506 |
# interface MgmtEth0/0/CPU0/0 |
| 507 |
# ipv4 address 192.0.2.11 255.255.255.0 |
| 508 |
# ! |
| 509 |
# interface GigabitEthernet0/0/0/1 |
| 510 |
# description 'GigabitEthernet - 1" |
| 511 |
# ! |
| 512 |
# interface GigabitEthernet0/0/0/2 |
| 513 |
# description "GigabitEthernet - 2" |
| 514 |
# ! |
| 515 |
# interface GigabitEthernet0/0/0/3 |
| 516 |
# description "GigabitEthernet - 3" |
| 517 |
# ! |
| 518 |
# interface GigabitEthernet0/0/0/4 |
| 519 |
# description "GigabitEthernet - 4" |
| 520 |
# ! |
| 521 |
# |
| 522 |
# |
| 523 |
|
| 524 |
# Using deleted (without config) |
| 525 |
# |
| 526 |
# |
| 527 |
# ------------ |
| 528 |
# Before state |
| 529 |
# ------------ |
| 530 |
# |
| 531 |
# RP/0/0/CPU0:an-iosxr#sh run int |
| 532 |
# Sun Aug 18 19:49:51.908 UTC |
| 533 |
# interface Bundle-Ether10 |
| 534 |
# lacp mode active |
| 535 |
# bundle load-balancing hash src-ip |
| 536 |
# bundle maximum-active links 10 |
| 537 |
# bundle minimum-active links 2 |
| 538 |
# ! |
| 539 |
# interface Bundle-Ether11 |
| 540 |
# bundle load-balancing hash dst-ip |
| 541 |
# ! |
| 542 |
# interface MgmtEth0/0/CPU0/0 |
| 543 |
# ipv4 address 192.0.2.11 255.255.255.0 |
| 544 |
# ! |
| 545 |
# interface GigabitEthernet0/0/0/0 |
| 546 |
# shutdown |
| 547 |
# ! |
| 548 |
# interface GigabitEthernet0/0/0/1 |
| 549 |
# bundle id 10 mode inherit |
| 550 |
# shutdown |
| 551 |
# ! |
| 552 |
# interface GigabitEthernet0/0/0/2 |
| 553 |
# bundle id 10 mode passive |
| 554 |
# shutdown |
| 555 |
# ! |
| 556 |
# interface GigabitEthernet0/0/0/3 |
| 557 |
# bundle id 11 mode passive |
| 558 |
# shutdown |
| 559 |
# ! |
| 560 |
# interface GigabitEthernet0/0/0/4 |
| 561 |
# bundle id 11 mode passive |
| 562 |
# shutdown |
| 563 |
# ! |
| 564 |
# |
| 565 |
|
| 566 |
- name: Delete attributes of all bundles and removes member interfaces from them (Note |
| 567 |
- This won't delete the bundles themselves) |
| 568 |
cisco.iosxr.iosxr_lag_interfaces: |
| 569 |
state: deleted |
| 570 |
|
| 571 |
# |
| 572 |
# |
| 573 |
# ------------ |
| 574 |
# After state |
| 575 |
# ------------ |
| 576 |
# |
| 577 |
# |
| 578 |
# RP/0/0/CPU0:an-iosxr#sh run int |
| 579 |
# Sun Aug 18 19:54:22.389 UTC |
| 580 |
# interface Bundle-Ether10 |
| 581 |
# ! |
| 582 |
# interface Bundle-Ether11 |
| 583 |
# ! |
| 584 |
# interface MgmtEth0/0/CPU0/0 |
| 585 |
# ipv4 address 10.8.38.69 255.255.255.0 |
| 586 |
# ! |
| 587 |
# interface GigabitEthernet0/0/0/0 |
| 588 |
# shutdown |
| 589 |
# ! |
| 590 |
# interface GigabitEthernet0/0/0/1 |
| 591 |
# shutdown |
| 592 |
# ! |
| 593 |
# interface GigabitEthernet0/0/0/2 |
| 594 |
# shutdown |
| 595 |
# ! |
| 596 |
# interface GigabitEthernet0/0/0/3 |
| 597 |
# shutdown |
| 598 |
# ! |
| 599 |
# interface GigabitEthernet0/0/0/4 |
| 600 |
# shutdown |
| 601 |
# ! |
| 602 |
|
| 603 |
# Using parsed: |
| 604 |
|
| 605 |
# parsed.cfg |
| 606 |
|
| 607 |
# interface Bundle-Ether10 |
| 608 |
# lacp mode active |
| 609 |
# bundle load-balancing hash src-ip |
| 610 |
# bundle maximum-active links 5 |
| 611 |
# bundle minimum-active links 2 |
| 612 |
# ! |
| 613 |
# interface Bundle-Ether12 |
| 614 |
# bundle load-balancing hash dst-ip |
| 615 |
# ! |
| 616 |
# interface Loopback888 |
| 617 |
# description test for ansible |
| 618 |
# shutdown |
| 619 |
# ! |
| 620 |
# interface MgmtEth0/0/CPU0/0 |
| 621 |
# ipv4 address 192.0.2.11 255.255.255.0 |
| 622 |
# ! |
| 623 |
# interface GigabitEthernet0/0/0/1 |
| 624 |
# description 'GigabitEthernet - 1" |
| 625 |
# bundle id 10 mode inherit |
| 626 |
# ! |
| 627 |
# interface GigabitEthernet0/0/0/2 |
| 628 |
# description "GigabitEthernet - 2" |
| 629 |
# bundle id 12 mode passive |
| 630 |
# ! |
| 631 |
# interface GigabitEthernet0/0/0/3 |
| 632 |
# description "GigabitEthernet - 3" |
| 633 |
# bundle id 10 mode inherit |
| 634 |
# ! |
| 635 |
# interface GigabitEthernet0/0/0/4 |
| 636 |
# description "GigabitEthernet - 4" |
| 637 |
# bundle id 12 mode passive |
| 638 |
# ! |
| 639 |
# |
| 640 |
- name: Convert lag interfaces config to argspec without connecting to the appliance |
| 641 |
cisco.iosxr.iosxr_lag_interfaces: |
| 642 |
running_config: "{{ lookup('file', './parsed.cfg') }}" |
| 643 |
state: parsed |
| 644 |
|
| 645 |
# -------------- |
| 646 |
# Output |
| 647 |
# -------------- |
| 648 |
# parsed: |
| 649 |
# - name: Bundle-Ether10 |
| 650 |
# members: |
| 651 |
# - member: GigabitEthernet0/0/0/1 |
| 652 |
# mode: inherit |
| 653 |
# - member: GigabitEthernet0/0/0/3 |
| 654 |
# mode: inherit |
| 655 |
# mode: active |
| 656 |
# links: |
| 657 |
# max_active: 5 |
| 658 |
# min_active: 2 |
| 659 |
# load_balancing_hash: src-ip |
| 660 |
|
| 661 |
# - name: Bundle-Ether12 |
| 662 |
# members: |
| 663 |
# - member: GigabitEthernet0/0/0/2 |
| 664 |
# mode: passive |
| 665 |
# - member: GigabitEthernet0/0/0/4 |
| 666 |
# mode: passive |
| 667 |
# load_balancing_hash: dst-ip |
| 668 |
|
| 669 |
# using gathered |
| 670 |
|
| 671 |
# Device Config: |
| 672 |
# ------------- |
| 673 |
|
| 674 |
# interface Bundle-Ether10 |
| 675 |
# lacp mode active |
| 676 |
# bundle load-balancing hash src-ip |
| 677 |
# bundle maximum-active links 5 |
| 678 |
# bundle minimum-active links 2 |
| 679 |
# ! |
| 680 |
# interface Bundle-Ether12 |
| 681 |
# bundle load-balancing hash dst-ip |
| 682 |
# ! |
| 683 |
# interface Loopback888 |
| 684 |
# description test for ansible |
| 685 |
# shutdown |
| 686 |
# ! |
| 687 |
# interface MgmtEth0/0/CPU0/0 |
| 688 |
# ipv4 address 192.0.2.11 255.255.255.0 |
| 689 |
# ! |
| 690 |
# interface GigabitEthernet0/0/0/1 |
| 691 |
# description 'GigabitEthernet - 1" |
| 692 |
# bundle id 10 mode inherit |
| 693 |
# ! |
| 694 |
# interface GigabitEthernet0/0/0/2 |
| 695 |
# description "GigabitEthernet - 2" |
| 696 |
# bundle id 12 mode passive |
| 697 |
# ! |
| 698 |
# interface GigabitEthernet0/0/0/3 |
| 699 |
# description "GigabitEthernet - 3" |
| 700 |
# bundle id 10 mode inherit |
| 701 |
# ! |
| 702 |
# interface GigabitEthernet0/0/0/4 |
| 703 |
# description "GigabitEthernet - 4" |
| 704 |
# bundle id 12 mode passive |
| 705 |
# ! |
| 706 |
# |
| 707 |
|
| 708 |
- name: Gather IOSXR lag interfaces configuration |
| 709 |
cisco.iosxr.iosxr_lag_interfaces: |
| 710 |
config: |
| 711 |
state: gathered |
| 712 |
|
| 713 |
# -------------- |
| 714 |
# Output |
| 715 |
# -------------- |
| 716 |
# gathered: |
| 717 |
# - name: Bundle-Ether10 |
| 718 |
# members: |
| 719 |
# - member: GigabitEthernet0/0/0/1 |
| 720 |
# mode: inherit |
| 721 |
# - member: GigabitEthernet0/0/0/3 |
| 722 |
# mode: inherit |
| 723 |
# mode: active |
| 724 |
# links: |
| 725 |
# max_active: 5 |
| 726 |
# min_active: 2 |
| 727 |
# load_balancing_hash: src-ip |
| 728 |
|
| 729 |
# - name: Bundle-Ether12 |
| 730 |
# members: |
| 731 |
# - member: GigabitEthernet0/0/0/2 |
| 732 |
# mode: passive |
| 733 |
# - member: GigabitEthernet0/0/0/4 |
| 734 |
# mode: passive |
| 735 |
# load_balancing_hash: dst-ip |
| 736 |
|
| 737 |
# Using rendered: |
| 738 |
- name: Render platform specific commands from task input using rendered state |
| 739 |
cisco.iosxr.iosxr_lag_interfaces: |
| 740 |
config: |
| 741 |
- name: Bundle-Ether10 |
| 742 |
members: |
| 743 |
- member: GigabitEthernet0/0/0/1 |
| 744 |
mode: inherit |
| 745 |
- member: GigabitEthernet0/0/0/3 |
| 746 |
mode: inherit |
| 747 |
mode: active |
| 748 |
links: |
| 749 |
max_active: 5 |
| 750 |
min_active: 2 |
| 751 |
load_balancing_hash: src-ip |
| 752 |
- name: Bundle-Ether12 |
| 753 |
members: |
| 754 |
- member: GigabitEthernet0/0/0/2 |
| 755 |
mode: passive |
| 756 |
- member: GigabitEthernet0/0/0/4 |
| 757 |
mode: passive |
| 758 |
load_balancing_hash: dst-ip |
| 759 |
state: rendered |
| 760 |
|
| 761 |
# Output: |
| 762 |
|
| 763 |
# rendered: |
| 764 |
# [ |
| 765 |
# - "interface Bundle-Ether10" |
| 766 |
# - " lacp mode active" |
| 767 |
# - " bundle load-balancing hash src-ip" |
| 768 |
# - " bundle maximum-active links 5" |
| 769 |
# - " bundle minimum-active links 2" |
| 770 |
# - "interface Bundle-Ether12" |
| 771 |
# - " bundle load-balancing hash dst-ip" |
| 772 |
# - "interface Loopback888" |
| 773 |
# - " description test for ansible" |
| 774 |
# - " shutdown" |
| 775 |
# - "interface MgmtEth0/0/CPU0/0" |
| 776 |
# - " ipv4 address 192.0.2.11 255.255.255.0" |
| 777 |
# - "interface GigabitEthernet0/0/0/1" |
| 778 |
# - " description 'GigabitEthernet - 1"" |
| 779 |
# - " bundle id 10 mode inherit" |
| 780 |
# - "interface GigabitEthernet0/0/0/2" |
| 781 |
# - " description "GigabitEthernet - 2"" |
| 782 |
# - " bundle id 12 mode passive" |
| 783 |
# - "interface GigabitEthernet0/0/0/3" |
| 784 |
# - " description "GigabitEthernet - 3"" |
| 785 |
# - " bundle id 10 mode inherit" |
| 786 |
# - "interface GigabitEthernet0/0/0/4" |
| 787 |
# - " description "GigabitEthernet - 4"" |
| 788 |
# - " bundle id 12 mode passive" |
| 789 |
# ] |
| 790 |
# |
| 791 |
""" |
| 792 |
RETURN = """ |
| 793 |
before: |
| 794 |
description: The configuration as structured data prior to module invocation. |
| 795 |
returned: always |
| 796 |
type: list |
| 797 |
sample: > |
| 798 |
The configuration returned will always be in the same format |
| 799 |
of the parameters above. |
| 800 |
after: |
| 801 |
description: The configuration as structured data after module completion. |
| 802 |
returned: when changed |
| 803 |
type: list |
| 804 |
sample: > |
| 805 |
The configuration returned will always be in the same format |
| 806 |
of the parameters above. |
| 807 |
commands: |
| 808 |
description: The set of commands pushed to the remote device. |
| 809 |
returned: always |
| 810 |
type: list |
| 811 |
sample: ['interface Bundle-Ether10', 'bundle minimum-active links 2', 'bundle load-balancing hash src-ip'] |
| 812 |
""" |
| 813 |
|
| 814 |
|
| 815 |
from ansible.module_utils.basic import AnsibleModule |
| 816 |
|
| 817 |
from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.argspec.lag_interfaces.lag_interfaces import ( |
| 818 |
Lag_interfacesArgs, |
| 819 |
) |
| 820 |
from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.config.lag_interfaces.lag_interfaces import ( |
| 821 |
Lag_interfaces, |
| 822 |
) |
| 823 |
|
| 824 |
|
| 825 |
def main(): |
| 826 |
""" |
| 827 |
Main entry point for module execution |
| 828 |
|
| 829 |
:returns: the result form module invocation |
| 830 |
""" |
| 831 |
required_if = [ |
| 832 |
("state", "merged", ("config",)), |
| 833 |
("state", "replaced", ("config",)), |
| 834 |
("state", "overridden", ("config",)), |
| 835 |
("state", "rendered", ("config",)), |
| 836 |
("state", "parsed", ("running_config",)), |
| 837 |
] |
| 838 |
|
| 839 |
mutually_exclusive = [("config", "running_config")] |
| 840 |
module = AnsibleModule( |
| 841 |
argument_spec=Lag_interfacesArgs.argument_spec, |
| 842 |
required_if=required_if, |
| 843 |
supports_check_mode=True, |
| 844 |
mutually_exclusive=mutually_exclusive, |
| 845 |
) |
| 846 |
|
| 847 |
result = Lag_interfaces(module).execute_module() |
| 848 |
module.exit_json(**result) |
| 849 |
|
| 850 |
|
| 851 |
if __name__ == "__main__": |
| 852 |
main() |