| 1 |
#!/usr/bin/python |
| 2 |
# |
| 3 |
# This file is part of Ansible |
| 4 |
# |
| 5 |
# Ansible is free software: you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation, either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# Ansible is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
# |
| 18 |
""" |
| 19 |
The module file for ios_lldp_interfaces |
| 20 |
""" |
| 21 |
from __future__ import absolute_import, division, print_function |
| 22 |
|
| 23 |
|
| 24 |
__metaclass__ = type |
| 25 |
|
| 26 |
|
| 27 |
DOCUMENTATION = """ |
| 28 |
module: ios_lldp_interfaces |
| 29 |
short_description: Resource module to configure LLDP interfaces. |
| 30 |
description: |
| 31 |
This module manages link layer discovery protocol (LLDP) attributes of |
| 32 |
interfaces on Cisco IOS devices. |
| 33 |
version_added: 1.0.0 |
| 34 |
author: Sumit Jaiswal (@justjais) |
| 35 |
notes: |
| 36 |
- Tested against Cisco IOSXE Version 17.3 on CML. |
| 37 |
- This module works with connection C(network_cli). |
| 38 |
See U(https://docs.ansible.com/ansible/latest/network/user_guide/platform_ios.html) |
| 39 |
options: |
| 40 |
config: |
| 41 |
description: A dictionary of LLDP options |
| 42 |
type: list |
| 43 |
elements: dict |
| 44 |
suboptions: |
| 45 |
name: |
| 46 |
description: |
| 47 |
- Full name of the interface excluding any logical unit number, i.e. GigabitEthernet0/1. |
| 48 |
type: str |
| 49 |
required: true |
| 50 |
receive: |
| 51 |
description: |
| 52 |
- Enable LLDP reception on interface. |
| 53 |
type: bool |
| 54 |
transmit: |
| 55 |
description: |
| 56 |
- Enable LLDP transmission on interface. |
| 57 |
type: bool |
| 58 |
med_tlv_select: |
| 59 |
description: |
| 60 |
- Selection of LLDP MED TLVs to send |
| 61 |
- NOTE, if med-tlv-select is configured idempotency won't be maintained as |
| 62 |
Cisco device doesn't record configured med-tlv-select options. As such, |
| 63 |
Ansible cannot verify if the respective med-tlv-select options is already |
| 64 |
configured or not from the device side. If you try to apply med-tlv-select |
| 65 |
option in every play run, Ansible will show changed as True. |
| 66 |
type: dict |
| 67 |
suboptions: |
| 68 |
inventory_management: |
| 69 |
description: |
| 70 |
- LLDP MED Inventory Management TLV |
| 71 |
type: bool |
| 72 |
tlv_select: |
| 73 |
description: |
| 74 |
- Selection of LLDP type-length-value i.e. TLVs to send |
| 75 |
- NOTE, if tlv-select is configured idempotency won't be maintained as Cisco |
| 76 |
device doesn't record configured tlv-select options. As such, Ansible cannot |
| 77 |
verify if the respective tlv-select options is already configured or not |
| 78 |
from the device side. If you try to apply tlv-select option in every play |
| 79 |
run, Ansible will show changed as True. |
| 80 |
type: dict |
| 81 |
suboptions: |
| 82 |
power_management: |
| 83 |
description: |
| 84 |
- IEEE 802.3 DTE Power via MDI TLV |
| 85 |
type: bool |
| 86 |
running_config: |
| 87 |
description: |
| 88 |
- This option is used only with state I(parsed). |
| 89 |
- The value of this option should be the output received from the IOS device by |
| 90 |
executing the command B(sh lldp interface). |
| 91 |
- The state I(parsed) reads the configuration from C(running_config) option and |
| 92 |
transforms it into Ansible structured data as per the resource module's argspec |
| 93 |
and the value is then returned in the I(parsed) key within the result. |
| 94 |
type: str |
| 95 |
state: |
| 96 |
description: |
| 97 |
- The state the configuration should be left in |
| 98 |
- The states I(rendered), I(gathered) and I(parsed) does not perform any change |
| 99 |
on the device. |
| 100 |
- The state I(rendered) will transform the configuration in C(config) option to |
| 101 |
platform specific CLI commands which will be returned in the I(rendered) key |
| 102 |
within the result. For state I(rendered) active connection to remote host is |
| 103 |
not required. |
| 104 |
- The state I(gathered) will fetch the running configuration from device and transform |
| 105 |
it into structured data in the format as per the resource module argspec and |
| 106 |
the value is returned in the I(gathered) key within the result. |
| 107 |
- The state I(parsed) reads the configuration from C(running_config) option and |
| 108 |
transforms it into JSON format as per the resource module parameters and the |
| 109 |
value is returned in the I(parsed) key within the result. The value of C(running_config) |
| 110 |
option should be the same format as the output of command I(show running-config |
| 111 |
| include ip route|ipv6 route) executed on device. For state I(parsed) active |
| 112 |
connection to remote host is not required. |
| 113 |
type: str |
| 114 |
choices: |
| 115 |
- merged |
| 116 |
- replaced |
| 117 |
- overridden |
| 118 |
- deleted |
| 119 |
- rendered |
| 120 |
- gathered |
| 121 |
- parsed |
| 122 |
default: merged |
| 123 |
""" |
| 124 |
|
| 125 |
EXAMPLES = """ |
| 126 |
# Using merged |
| 127 |
# |
| 128 |
# Before state: |
| 129 |
# ------------- |
| 130 |
# |
| 131 |
# vios#sh lldp interface |
| 132 |
# GigabitEthernet0/0: |
| 133 |
# Tx: enabled |
| 134 |
# Rx: disabled |
| 135 |
# Tx state: IDLE |
| 136 |
# Rx state: WAIT FOR FRAME |
| 137 |
# |
| 138 |
# GigabitEthernet0/1: |
| 139 |
# Tx: disabled |
| 140 |
# Rx: disabled |
| 141 |
# Tx state: IDLE |
| 142 |
# Rx state: WAIT FOR FRAME |
| 143 |
# |
| 144 |
# GigabitEthernet0/2: |
| 145 |
# Tx: disabled |
| 146 |
# Rx: disabled |
| 147 |
# Tx state: IDLE |
| 148 |
# Rx state: INIT |
| 149 |
# |
| 150 |
# GigabitEthernet0/3: |
| 151 |
# Tx: enabled |
| 152 |
# Rx: enabled |
| 153 |
# Tx state: IDLE |
| 154 |
# Rx state: WAIT FOR FRAME |
| 155 |
# |
| 156 |
|
| 157 |
- name: Merge provided configuration with device configuration |
| 158 |
cisco.ios.ios_lldp_interfaces: |
| 159 |
config: |
| 160 |
- name: GigabitEthernet0/1 |
| 161 |
receive: true |
| 162 |
transmit: true |
| 163 |
- name: GigabitEthernet0/2 |
| 164 |
receive: true |
| 165 |
- name: GigabitEthernet0/3 |
| 166 |
transmit: true |
| 167 |
state: merged |
| 168 |
|
| 169 |
# After state: |
| 170 |
# ------------ |
| 171 |
# |
| 172 |
# vios#sh lldp interface |
| 173 |
# GigabitEthernet0/0: |
| 174 |
# Tx: enabled |
| 175 |
# Rx: disabled |
| 176 |
# Tx state: IDLE |
| 177 |
# Rx state: WAIT FOR FRAME |
| 178 |
# |
| 179 |
# GigabitEthernet0/1: |
| 180 |
# Tx: enabled |
| 181 |
# Rx: enabled |
| 182 |
# Tx state: IDLE |
| 183 |
# Rx state: WAIT FOR FRAME |
| 184 |
# |
| 185 |
# GigabitEthernet0/2: |
| 186 |
# Tx: disabled |
| 187 |
# Rx: enabled |
| 188 |
# Tx state: IDLE |
| 189 |
# Rx state: INIT |
| 190 |
# |
| 191 |
# GigabitEthernet0/3: |
| 192 |
# Tx: enabled |
| 193 |
# Rx: disabled |
| 194 |
# Tx state: IDLE |
| 195 |
# Rx state: WAIT FOR FRAME |
| 196 |
# |
| 197 |
|
| 198 |
# Using overridden |
| 199 |
# |
| 200 |
# Before state: |
| 201 |
# ------------- |
| 202 |
# |
| 203 |
# vios#sh lldp interface |
| 204 |
# GigabitEthernet0/0: |
| 205 |
# Tx: enabled |
| 206 |
# Rx: enabled |
| 207 |
# Tx state: IDLE |
| 208 |
# Rx state: WAIT FOR FRAME |
| 209 |
# |
| 210 |
# GigabitEthernet0/1: |
| 211 |
# Tx: enabled |
| 212 |
# Rx: enabled |
| 213 |
# Tx state: IDLE |
| 214 |
# Rx state: WAIT FOR FRAME |
| 215 |
# |
| 216 |
# GigabitEthernet0/2: |
| 217 |
# Tx: disabled |
| 218 |
# Rx: disabled |
| 219 |
# Tx state: IDLE |
| 220 |
# Rx state: INIT |
| 221 |
# |
| 222 |
# GigabitEthernet0/3: |
| 223 |
# Tx: enabled |
| 224 |
# Rx: enabled |
| 225 |
# Tx state: IDLE |
| 226 |
# Rx state: WAIT FOR FRAME |
| 227 |
|
| 228 |
- name: Override device configuration of all lldp_interfaces with provided configuration |
| 229 |
cisco.ios.ios_lldp_interfaces: |
| 230 |
config: |
| 231 |
- name: GigabitEthernet0/2 |
| 232 |
receive: true |
| 233 |
transmit: true |
| 234 |
state: overridden |
| 235 |
|
| 236 |
# After state: |
| 237 |
# ------------ |
| 238 |
# |
| 239 |
# vios#sh lldp interface |
| 240 |
# GigabitEthernet0/0: |
| 241 |
# Tx: disabled |
| 242 |
# Rx: disabled |
| 243 |
# Tx state: IDLE |
| 244 |
# Rx state: WAIT FOR FRAME |
| 245 |
# |
| 246 |
# GigabitEthernet0/1: |
| 247 |
# Tx: disabled |
| 248 |
# Rx: disabled |
| 249 |
# Tx state: IDLE |
| 250 |
# Rx state: WAIT FOR FRAME |
| 251 |
# |
| 252 |
# GigabitEthernet0/2: |
| 253 |
# Tx: enabled |
| 254 |
# Rx: enabled |
| 255 |
# Tx state: IDLE |
| 256 |
# Rx state: INIT |
| 257 |
# |
| 258 |
# GigabitEthernet0/3: |
| 259 |
# Tx: disabled |
| 260 |
# Rx: disabled |
| 261 |
# Tx state: IDLE |
| 262 |
# Rx state: WAIT FOR FRAME |
| 263 |
|
| 264 |
# Using replaced |
| 265 |
# |
| 266 |
# Before state: |
| 267 |
# ------------- |
| 268 |
# |
| 269 |
# vios#sh lldp interface |
| 270 |
# GigabitEthernet0/0: |
| 271 |
# Tx: enabled |
| 272 |
# Rx: enabled |
| 273 |
# Tx state: IDLE |
| 274 |
# Rx state: WAIT FOR FRAME |
| 275 |
# |
| 276 |
# GigabitEthernet0/1: |
| 277 |
# Tx: enabled |
| 278 |
# Rx: enabled |
| 279 |
# Tx state: IDLE |
| 280 |
# Rx state: WAIT FOR FRAME |
| 281 |
# |
| 282 |
# GigabitEthernet0/2: |
| 283 |
# Tx: disabled |
| 284 |
# Rx: disabled |
| 285 |
# Tx state: IDLE |
| 286 |
# Rx state: INIT |
| 287 |
# |
| 288 |
# GigabitEthernet0/3: |
| 289 |
# Tx: enabled |
| 290 |
# Rx: enabled |
| 291 |
# Tx state: IDLE |
| 292 |
# Rx state: WAIT FOR FRAME |
| 293 |
# |
| 294 |
|
| 295 |
- name: Replaces device configuration of listed lldp_interfaces with provided configuration |
| 296 |
cisco.ios.ios_lldp_interfaces: |
| 297 |
config: |
| 298 |
- name: GigabitEthernet0/2 |
| 299 |
receive: true |
| 300 |
transmit: true |
| 301 |
- name: GigabitEthernet0/3 |
| 302 |
receive: true |
| 303 |
state: replaced |
| 304 |
|
| 305 |
# After state: |
| 306 |
# ------------ |
| 307 |
# |
| 308 |
# vios#sh lldp interface |
| 309 |
# GigabitEthernet0/0: |
| 310 |
# Tx: enabled |
| 311 |
# Rx: enabled |
| 312 |
# Tx state: IDLE |
| 313 |
# Rx state: WAIT FOR FRAME |
| 314 |
# |
| 315 |
# GigabitEthernet0/1: |
| 316 |
# Tx: enabled |
| 317 |
# Rx: enabled |
| 318 |
# Tx state: IDLE |
| 319 |
# Rx state: WAIT FOR FRAME |
| 320 |
# |
| 321 |
# GigabitEthernet0/2: |
| 322 |
# Tx: enabled |
| 323 |
# Rx: enabled |
| 324 |
# Tx state: IDLE |
| 325 |
# Rx state: INIT |
| 326 |
# |
| 327 |
# GigabitEthernet0/3: |
| 328 |
# Tx: disabled |
| 329 |
# Rx: enabled |
| 330 |
# Tx state: IDLE |
| 331 |
# Rx state: WAIT FOR FRAME |
| 332 |
# |
| 333 |
|
| 334 |
# Using Deleted |
| 335 |
# |
| 336 |
# Before state: |
| 337 |
# ------------- |
| 338 |
# |
| 339 |
# vios#sh lldp interface |
| 340 |
# GigabitEthernet0/0: |
| 341 |
# Tx: enabled |
| 342 |
# Rx: enabled |
| 343 |
# Tx state: IDLE |
| 344 |
# Rx state: WAIT FOR FRAME |
| 345 |
# |
| 346 |
# GigabitEthernet0/1: |
| 347 |
# Tx: enabled |
| 348 |
# Rx: enabled |
| 349 |
# Tx state: IDLE |
| 350 |
# Rx state: WAIT FOR FRAME |
| 351 |
# |
| 352 |
# GigabitEthernet0/2: |
| 353 |
# Tx: disabled |
| 354 |
# Rx: disabled |
| 355 |
# Tx state: IDLE |
| 356 |
# Rx state: INIT |
| 357 |
# |
| 358 |
# GigabitEthernet0/3: |
| 359 |
# Tx: enabled |
| 360 |
# Rx: enabled |
| 361 |
# Tx state: IDLE |
| 362 |
# Rx state: WAIT FOR FRAME |
| 363 |
|
| 364 |
- name: "Delete LLDP attributes of given interfaces (Note: This won't delete the interface itself)" |
| 365 |
cisco.ios.ios_lldp_interfaces: |
| 366 |
config: |
| 367 |
- name: GigabitEthernet0/1 |
| 368 |
state: deleted |
| 369 |
|
| 370 |
# After state: |
| 371 |
# ------------- |
| 372 |
# |
| 373 |
# vios#sh lldp interface |
| 374 |
# GigabitEthernet0/0: |
| 375 |
# Tx: enabled |
| 376 |
# Rx: enabled |
| 377 |
# Tx state: IDLE |
| 378 |
# Rx state: WAIT FOR FRAME |
| 379 |
# |
| 380 |
# GigabitEthernet0/1: |
| 381 |
# Tx: disabled |
| 382 |
# Rx: disabled |
| 383 |
# Tx state: IDLE |
| 384 |
# Rx state: INIT |
| 385 |
# |
| 386 |
# GigabitEthernet0/2: |
| 387 |
# Tx: disabled |
| 388 |
# Rx: disabled |
| 389 |
# Tx state: IDLE |
| 390 |
# Rx state: INIT |
| 391 |
# |
| 392 |
# GigabitEthernet0/3: |
| 393 |
# Tx: enabled |
| 394 |
# Rx: enabled |
| 395 |
# Tx state: IDLE |
| 396 |
# Rx state: WAIT FOR FRAME |
| 397 |
# |
| 398 |
|
| 399 |
# Using Deleted without any config passed |
| 400 |
# "(NOTE: This will delete all of configured LLDP module attributes)" |
| 401 |
# |
| 402 |
# Before state: |
| 403 |
# ------------- |
| 404 |
# |
| 405 |
# vios#sh lldp interface |
| 406 |
# GigabitEthernet0/0: |
| 407 |
# Tx: enabled |
| 408 |
# Rx: enabled |
| 409 |
# Tx state: IDLE |
| 410 |
# Rx state: WAIT FOR FRAME |
| 411 |
# |
| 412 |
# GigabitEthernet0/1: |
| 413 |
# Tx: enabled |
| 414 |
# Rx: enabled |
| 415 |
# Tx state: IDLE |
| 416 |
# Rx state: WAIT FOR FRAME |
| 417 |
# |
| 418 |
# GigabitEthernet0/2: |
| 419 |
# Tx: disabled |
| 420 |
# Rx: disabled |
| 421 |
# Tx state: IDLE |
| 422 |
# Rx state: INIT |
| 423 |
# |
| 424 |
# GigabitEthernet0/3: |
| 425 |
# Tx: enabled |
| 426 |
# Rx: enabled |
| 427 |
# Tx state: IDLE |
| 428 |
# Rx state: WAIT FOR FRAME |
| 429 |
|
| 430 |
- name: "Delete LLDP attributes for all configured interfaces (Note: This won't delete the interface itself)" |
| 431 |
cisco.ios.ios_lldp_interfaces: |
| 432 |
state: deleted |
| 433 |
|
| 434 |
# After state: |
| 435 |
# ------------- |
| 436 |
# |
| 437 |
# vios#sh lldp interface |
| 438 |
# GigabitEthernet0/0: |
| 439 |
# Tx: disabled |
| 440 |
# Rx: disabled |
| 441 |
# Tx state: IDLE |
| 442 |
# Rx state: WAIT FOR FRAME |
| 443 |
# |
| 444 |
# GigabitEthernet0/1: |
| 445 |
# Tx: disabled |
| 446 |
# Rx: disabled |
| 447 |
# Tx state: IDLE |
| 448 |
# Rx state: WAIT FOR FRAME |
| 449 |
# |
| 450 |
# GigabitEthernet0/2: |
| 451 |
# Tx: disabled |
| 452 |
# Rx: disabled |
| 453 |
# Tx state: IDLE |
| 454 |
# Rx state: INIT |
| 455 |
# |
| 456 |
# GigabitEthernet0/3: |
| 457 |
# Tx: disabled |
| 458 |
# Rx: disabled |
| 459 |
# Tx state: IDLE |
| 460 |
# Rx state: WAIT FOR FRAME |
| 461 |
|
| 462 |
# Using Gathered |
| 463 |
|
| 464 |
# Before state: |
| 465 |
# ------------- |
| 466 |
# |
| 467 |
# vios#sh lldp interface |
| 468 |
# GigabitEthernet0/0: |
| 469 |
# Tx: enabled |
| 470 |
# Rx: enabled |
| 471 |
# Tx state: IDLE |
| 472 |
# Rx state: WAIT FOR FRAME |
| 473 |
# |
| 474 |
# GigabitEthernet0/1: |
| 475 |
# Tx: enabled |
| 476 |
# Rx: enabled |
| 477 |
# Tx state: IDLE |
| 478 |
# Rx state: WAIT FOR FRAME |
| 479 |
# |
| 480 |
# GigabitEthernet0/2: |
| 481 |
# Tx: enabled |
| 482 |
# Rx: enabled |
| 483 |
# Tx state: IDLE |
| 484 |
# Rx state: WAIT FOR FRAME |
| 485 |
|
| 486 |
- name: Gather listed LLDP interfaces with provided configurations |
| 487 |
cisco.ios.ios_lldp_interfaces: |
| 488 |
config: |
| 489 |
state: gathered |
| 490 |
|
| 491 |
# Module Execution Result: |
| 492 |
# ------------------------ |
| 493 |
# |
| 494 |
# "gathered": [ |
| 495 |
# { |
| 496 |
# "name": "GigabitEthernet0/0", |
| 497 |
# "receive": true, |
| 498 |
# "transmit": true |
| 499 |
# }, |
| 500 |
# { |
| 501 |
# "name": "GigabitEthernet0/1", |
| 502 |
# "receive": true, |
| 503 |
# "transmit": true |
| 504 |
# }, |
| 505 |
# { |
| 506 |
# "name": "GigabitEthernet0/2", |
| 507 |
# "receive": true, |
| 508 |
# "transmit": true |
| 509 |
# } |
| 510 |
# ] |
| 511 |
|
| 512 |
# After state: |
| 513 |
# ------------ |
| 514 |
# |
| 515 |
# vios#sh lldp interface |
| 516 |
# GigabitEthernet0/0: |
| 517 |
# Tx: enabled |
| 518 |
# Rx: enabled |
| 519 |
# Tx state: IDLE |
| 520 |
# Rx state: WAIT FOR FRAME |
| 521 |
# |
| 522 |
# GigabitEthernet0/1: |
| 523 |
# Tx: enabled |
| 524 |
# Rx: enabled |
| 525 |
# Tx state: IDLE |
| 526 |
# Rx state: WAIT FOR FRAME |
| 527 |
|
| 528 |
# GigabitEthernet0/2: |
| 529 |
# Tx: enabled |
| 530 |
# Rx: enabled |
| 531 |
# Tx state: IDLE |
| 532 |
# Rx state: WAIT FOR FRAME |
| 533 |
|
| 534 |
# Using Rendered |
| 535 |
|
| 536 |
- name: Render the commands for provided configuration |
| 537 |
cisco.ios.ios_lldp_interfaces: |
| 538 |
config: |
| 539 |
- name: GigabitEthernet0/0 |
| 540 |
receive: true |
| 541 |
transmit: true |
| 542 |
- name: GigabitEthernet0/1 |
| 543 |
receive: true |
| 544 |
transmit: true |
| 545 |
- name: GigabitEthernet0/2 |
| 546 |
receive: true |
| 547 |
state: rendered |
| 548 |
|
| 549 |
# Module Execution Result: |
| 550 |
# ------------------------ |
| 551 |
# |
| 552 |
# "rendered": [ |
| 553 |
# "interface GigabitEthernet0/0", |
| 554 |
# "lldp receive", |
| 555 |
# "lldp transmit", |
| 556 |
# "interface GigabitEthernet0/1", |
| 557 |
# "lldp receive", |
| 558 |
# "lldp transmit", |
| 559 |
# "interface GigabitEthernet0/2", |
| 560 |
# "lldp receive" |
| 561 |
# ] |
| 562 |
|
| 563 |
# Using Parsed |
| 564 |
|
| 565 |
# File: parsed.cfg |
| 566 |
# ---------------- |
| 567 |
# |
| 568 |
# GigabitEthernet0/0: |
| 569 |
# Tx: enabled |
| 570 |
# Rx: disabled |
| 571 |
# Tx state: IDLE |
| 572 |
# Rx state: WAIT FOR FRAME |
| 573 |
# |
| 574 |
# GigabitEthernet0/1: |
| 575 |
# Tx: enabled |
| 576 |
# Rx: enabled |
| 577 |
# Tx state: IDLE |
| 578 |
# Rx state: WAIT FOR FRAME |
| 579 |
# |
| 580 |
# GigabitEthernet0/2: |
| 581 |
# Tx: disabled |
| 582 |
# Rx: enabled |
| 583 |
# Tx state: IDLE |
| 584 |
# Rx state: INIT |
| 585 |
|
| 586 |
- name: Parse the commands for provided configuration |
| 587 |
cisco.ios.ios_lldp_interfaces: |
| 588 |
running_config: "{{ lookup('file', 'parsed.cfg') }}" |
| 589 |
state: parsed |
| 590 |
|
| 591 |
# Module Execution Result: |
| 592 |
# ------------------------ |
| 593 |
# |
| 594 |
# "parsed": [ |
| 595 |
# { |
| 596 |
# "name": "GigabitEthernet0/0", |
| 597 |
# "receive": false, |
| 598 |
# "transmit": true |
| 599 |
# }, |
| 600 |
# { |
| 601 |
# "name": "GigabitEthernet0/1", |
| 602 |
# "receive": true, |
| 603 |
# "transmit": true |
| 604 |
# }, |
| 605 |
# { |
| 606 |
# "name": "GigabitEthernet0/2", |
| 607 |
# "receive": true, |
| 608 |
# "transmit": false |
| 609 |
# } |
| 610 |
# ] |
| 611 |
""" |
| 612 |
|
| 613 |
RETURN = """ |
| 614 |
before: |
| 615 |
description: The configuration as structured data prior to module invocation. |
| 616 |
returned: always |
| 617 |
type: list |
| 618 |
sample: > |
| 619 |
The configuration returned will always be in the same format |
| 620 |
of the parameters above. |
| 621 |
after: |
| 622 |
description: The configuration as structured data after module completion. |
| 623 |
returned: when changed |
| 624 |
type: list |
| 625 |
sample: > |
| 626 |
The configuration returned will always be in the same format |
| 627 |
of the parameters above. |
| 628 |
commands: |
| 629 |
description: The set of commands pushed to the remote device. |
| 630 |
returned: always |
| 631 |
type: list |
| 632 |
sample: ['interface GigabitEthernet 0/1', 'lldp transmit', 'lldp receive'] |
| 633 |
""" |
| 634 |
|
| 635 |
from ansible.module_utils.basic import AnsibleModule |
| 636 |
|
| 637 |
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.argspec.lldp_interfaces.lldp_interfaces import ( |
| 638 |
Lldp_InterfacesArgs, |
| 639 |
) |
| 640 |
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.config.lldp_interfaces.lldp_interfaces import ( |
| 641 |
Lldp_Interfaces, |
| 642 |
) |
| 643 |
|
| 644 |
|
| 645 |
def main(): |
| 646 |
""" |
| 647 |
Main entry point for module execution |
| 648 |
|
| 649 |
:returns: the result form module invocation |
| 650 |
""" |
| 651 |
required_if = [ |
| 652 |
("state", "merged", ("config",)), |
| 653 |
("state", "replaced", ("config",)), |
| 654 |
("state", "overridden", ("config",)), |
| 655 |
("state", "rendered", ("config",)), |
| 656 |
("state", "parsed", ("running_config",)), |
| 657 |
] |
| 658 |
mutually_exclusive = [("config", "running_config")] |
| 659 |
|
| 660 |
module = AnsibleModule( |
| 661 |
argument_spec=Lldp_InterfacesArgs.argument_spec, |
| 662 |
required_if=required_if, |
| 663 |
mutually_exclusive=mutually_exclusive, |
| 664 |
supports_check_mode=True, |
| 665 |
) |
| 666 |
result = Lldp_Interfaces(module).execute_module() |
| 667 |
module.exit_json(**result) |
| 668 |
|
| 669 |
|
| 670 |
if __name__ == "__main__": |
| 671 |
main() |