| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
# Copyright 2021 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 nxos_snmp_server |
| 9 |
""" |
| 10 |
|
| 11 |
from __future__ import absolute_import, division, print_function |
| 12 |
|
| 13 |
|
| 14 |
__metaclass__ = type |
| 15 |
|
| 16 |
DOCUMENTATION = """ |
| 17 |
module: nxos_snmp_server |
| 18 |
short_description: SNMP Server resource module. |
| 19 |
description: |
| 20 |
- This module manages SNMP server configuration on devices running Cisco NX-OS. |
| 21 |
version_added: 2.8.0 |
| 22 |
notes: |
| 23 |
- Tested against NX-OS 9.3.6 on Cisco Nexus Switches. |
| 24 |
- This module works with connection C(network_cli) and C(httpapi). |
| 25 |
- Tested against Cisco MDS NX-OS 9.2(2) with connection C(network_cli). |
| 26 |
author: Nilashish Chakraborty (@NilashishC) |
| 27 |
options: |
| 28 |
running_config: |
| 29 |
description: |
| 30 |
- This option is used only with state I(parsed). |
| 31 |
- The value of this option should be the output received from the NX-OS device |
| 32 |
by executing the command B(show running-config | section '^snmp-server'). |
| 33 |
- The state I(parsed) reads the configuration from C(running_config) option and |
| 34 |
transforms it into Ansible structured data as per the resource module's argspec |
| 35 |
and the value is then returned in the I(parsed) key within the result. |
| 36 |
type: str |
| 37 |
config: |
| 38 |
description: A dict of SNMP server configuration |
| 39 |
type: dict |
| 40 |
suboptions: |
| 41 |
aaa_user: |
| 42 |
description: Set duration for which aaa-cached snmp user exists. |
| 43 |
type: dict |
| 44 |
suboptions: |
| 45 |
cache_timeout: |
| 46 |
description: Timeout for which aaa-cached user exists(in secs). |
| 47 |
type: int |
| 48 |
communities: |
| 49 |
description: Set community string and access privs. |
| 50 |
type: list |
| 51 |
elements: dict |
| 52 |
suboptions: |
| 53 |
name: |
| 54 |
description: SNMP community string (Max Size 32). |
| 55 |
type: str |
| 56 |
aliases: ["community"] |
| 57 |
group: |
| 58 |
description: Group to which the community belongs. |
| 59 |
type: str |
| 60 |
ro: |
| 61 |
description: Read-only access with this community string. |
| 62 |
type: bool |
| 63 |
rw: |
| 64 |
description: Read-write access with this community string. |
| 65 |
type: bool |
| 66 |
use_ipv4acl: |
| 67 |
description: |
| 68 |
- Specify IPv4 ACL, the ACL name specified must be IPv4 ACL. |
| 69 |
- This option is unsupported on MDS switches. |
| 70 |
type: str |
| 71 |
use_ipv6acl: |
| 72 |
description: |
| 73 |
- Specify IPv6 ACL, the ACL name specified after must be IPv6 ACL. |
| 74 |
- This option is unsupported on MDS switches. |
| 75 |
type: str |
| 76 |
contact: |
| 77 |
description: Modify sysContact. |
| 78 |
type: str |
| 79 |
context: |
| 80 |
description: SNMP context to be mapped. |
| 81 |
type: dict |
| 82 |
suboptions: |
| 83 |
name: |
| 84 |
description: Name of the SNMP context (Max Size 32). |
| 85 |
type: str |
| 86 |
instance: |
| 87 |
description: Name of the protocol instance (Max Size 32). |
| 88 |
type: str |
| 89 |
topology: |
| 90 |
description: Topology associated with the SNMP context. |
| 91 |
type: str |
| 92 |
vrf: |
| 93 |
description: |
| 94 |
- VRF associated with the SNMP context. |
| 95 |
- This option is unsupported on MDS switches. |
| 96 |
type: str |
| 97 |
counter: |
| 98 |
description: |
| 99 |
- Configure port counter configuration. |
| 100 |
- This option is unsupported on MDS switches. |
| 101 |
type: dict |
| 102 |
suboptions: |
| 103 |
cache: |
| 104 |
description: Port stats cache. |
| 105 |
type: dict |
| 106 |
suboptions: |
| 107 |
enable: |
| 108 |
description: Enable port stats cache. |
| 109 |
type: bool |
| 110 |
timeout: |
| 111 |
description: Timeout for which cached port stats exists(in secs). |
| 112 |
type: int |
| 113 |
drop: |
| 114 |
description: |
| 115 |
- Silently drop unknown v3 user packets. |
| 116 |
- This option is unsupported on MDS switches. |
| 117 |
type: dict |
| 118 |
suboptions: |
| 119 |
unknown_engine_id: |
| 120 |
description: Unknown v3 engine id. |
| 121 |
type: bool |
| 122 |
unknown_user: |
| 123 |
description: Unknown v3 user. |
| 124 |
type: bool |
| 125 |
traps: |
| 126 |
description: Enable SNMP Traps |
| 127 |
type: dict |
| 128 |
suboptions: |
| 129 |
aaa: |
| 130 |
description: AAA traps |
| 131 |
type: dict |
| 132 |
suboptions: |
| 133 |
enable: |
| 134 |
description: Enable AAA traps. |
| 135 |
type: bool |
| 136 |
server_state_change: |
| 137 |
description: AAA server state change notification. |
| 138 |
type: bool |
| 139 |
bgp: |
| 140 |
description: SNMP BGP traps. |
| 141 |
type: dict |
| 142 |
suboptions: |
| 143 |
enable: |
| 144 |
description: Enable SNMP BGP traps. |
| 145 |
type: bool |
| 146 |
bridge: |
| 147 |
description: |
| 148 |
- Bridge traps. |
| 149 |
- This option is unsupported on MDS switches. |
| 150 |
type: dict |
| 151 |
suboptions: |
| 152 |
enable: |
| 153 |
description: Enable bridge traps. |
| 154 |
type: bool |
| 155 |
newroot: |
| 156 |
description: Enable SNMP STP Bridge MIB newroot traps. |
| 157 |
type: bool |
| 158 |
topologychange: |
| 159 |
description: Enable SNMP STP Bridge MIB topologychange traps. |
| 160 |
type: bool |
| 161 |
callhome: |
| 162 |
description: Callhome traps. |
| 163 |
type: dict |
| 164 |
suboptions: |
| 165 |
enable: |
| 166 |
description: |
| 167 |
- Enable callhome traps. |
| 168 |
- This option is unsupported on MDS switches. |
| 169 |
type: bool |
| 170 |
event_notify: |
| 171 |
description: Callhome External Event Notification. |
| 172 |
type: bool |
| 173 |
smtp_send_fail: |
| 174 |
description: SMTP Message Send Fail notification. |
| 175 |
type: bool |
| 176 |
cfs: |
| 177 |
description: CFS traps. |
| 178 |
type: dict |
| 179 |
suboptions: |
| 180 |
enable: |
| 181 |
description: |
| 182 |
- Enable cfs traps. |
| 183 |
- This option is unsupported on MDS switches. |
| 184 |
type: bool |
| 185 |
merge_failure: |
| 186 |
description: Merge failure notification. |
| 187 |
type: bool |
| 188 |
state_change_notif: |
| 189 |
description: State change notification. |
| 190 |
type: bool |
| 191 |
config: |
| 192 |
description: Config traps. |
| 193 |
type: dict |
| 194 |
suboptions: |
| 195 |
enable: |
| 196 |
description: |
| 197 |
- Enable config traps. |
| 198 |
- This option is unsupported on MDS switches. |
| 199 |
type: bool |
| 200 |
ccmCLIRunningConfigChanged: |
| 201 |
description: Running config change trap. |
| 202 |
type: bool |
| 203 |
entity: |
| 204 |
description: Entity traps. |
| 205 |
type: dict |
| 206 |
suboptions: |
| 207 |
enable: |
| 208 |
description: Enable entity traps. |
| 209 |
type: bool |
| 210 |
cefcMIBEnableStatusNotification: |
| 211 |
description: CefcMIBEnableStatusNotification. |
| 212 |
type: bool |
| 213 |
entity_fan_status_change: |
| 214 |
description: Entity Fan Status Change. |
| 215 |
type: bool |
| 216 |
entity_mib_change: |
| 217 |
description: Entity MIB change. |
| 218 |
type: bool |
| 219 |
entity_module_inserted: |
| 220 |
description: Entity Module Inserted. |
| 221 |
type: bool |
| 222 |
entity_module_removed: |
| 223 |
description: Entity Module Removed. |
| 224 |
type: bool |
| 225 |
entity_module_status_change: |
| 226 |
description: Entity Module Status Change. |
| 227 |
type: bool |
| 228 |
entity_power_out_change: |
| 229 |
description: Entity Power Out Change. |
| 230 |
type: bool |
| 231 |
entity_power_status_change: |
| 232 |
description: Entity Power Status Change. |
| 233 |
type: bool |
| 234 |
entity_sensor: |
| 235 |
description: Entity sensor. |
| 236 |
type: bool |
| 237 |
entity_unrecognised_module: |
| 238 |
description: Entity Unrecognised Module. |
| 239 |
type: bool |
| 240 |
feature_control: |
| 241 |
description: Feature-Control traps. |
| 242 |
type: dict |
| 243 |
suboptions: |
| 244 |
enable: |
| 245 |
description: |
| 246 |
- Enable feature-control traps. |
| 247 |
- This option is unsupported on MDS switches. |
| 248 |
type: bool |
| 249 |
featureOpStatusChange: |
| 250 |
description: Feature operation status change notification. |
| 251 |
type: bool |
| 252 |
ciscoFeatOpStatusChange: |
| 253 |
description: Feature operation status change Notification. |
| 254 |
type: bool |
| 255 |
generic: |
| 256 |
description: Generic traps. |
| 257 |
type: dict |
| 258 |
suboptions: |
| 259 |
enable: |
| 260 |
description: |
| 261 |
- Enable generic traps. |
| 262 |
- This option is unsupported on MDS switches. |
| 263 |
type: bool |
| 264 |
coldStart: |
| 265 |
description: Generic coldStart trap. |
| 266 |
type: bool |
| 267 |
warmStart: |
| 268 |
description: Generic warmStart trap. |
| 269 |
type: bool |
| 270 |
license: |
| 271 |
description: License traps. |
| 272 |
type: dict |
| 273 |
suboptions: |
| 274 |
enable: |
| 275 |
description: |
| 276 |
- Enable license traps. |
| 277 |
- This option is unsupported on MDS switches. |
| 278 |
type: bool |
| 279 |
notify_license_expiry: |
| 280 |
description: License Expiry Notification. |
| 281 |
type: bool |
| 282 |
notify_license_expiry_warning: |
| 283 |
description: License Expiry Warning Notification. |
| 284 |
type: bool |
| 285 |
notify_licensefile_missing: |
| 286 |
description: License File Missing Notification. |
| 287 |
type: bool |
| 288 |
notify_no_license_for_feature: |
| 289 |
description: No License installed for feature Notification. |
| 290 |
type: bool |
| 291 |
link: |
| 292 |
description: Link traps. |
| 293 |
type: dict |
| 294 |
suboptions: |
| 295 |
enable: |
| 296 |
description: |
| 297 |
- Enable link traps. |
| 298 |
- This option is unsupported on MDS switches. |
| 299 |
type: bool |
| 300 |
cErrDisableInterfaceEventRev1: |
| 301 |
description: |
| 302 |
- Err-disable state notification. |
| 303 |
- This option is unsupported on MDS switches. |
| 304 |
type: bool |
| 305 |
cieLinkDown: |
| 306 |
description: Cisco extended link state down notification. |
| 307 |
type: bool |
| 308 |
cieLinkUp: |
| 309 |
description: Cisco extended link state up notification. |
| 310 |
type: bool |
| 311 |
cisco_xcvr_mon_status_chg: |
| 312 |
description: Cisco interface transceiver monitor status change notification. |
| 313 |
type: bool |
| 314 |
cmn_mac_move_notification: |
| 315 |
description: |
| 316 |
- Mac addr move trap. |
| 317 |
- This option is unsupported on MDS switches. |
| 318 |
type: bool |
| 319 |
delayed_link_state_change: |
| 320 |
description: Delayed link state change. |
| 321 |
type: bool |
| 322 |
extended_linkDown: |
| 323 |
description: IETF extended link state down notification. |
| 324 |
type: bool |
| 325 |
extended_linkUp: |
| 326 |
description: IETF extended link state up notification. |
| 327 |
type: bool |
| 328 |
linkDown: |
| 329 |
description: IETF Link state down notification. |
| 330 |
type: bool |
| 331 |
linkUp: |
| 332 |
description: IETF Link state up notification. |
| 333 |
type: bool |
| 334 |
mmode: |
| 335 |
description: |
| 336 |
- MMode traps. |
| 337 |
- This option is unsupported on MDS switches. |
| 338 |
type: dict |
| 339 |
suboptions: |
| 340 |
enable: |
| 341 |
description: Enable mmode traps. |
| 342 |
type: bool |
| 343 |
cseMaintModeChangeNotify: |
| 344 |
description: Maint Mode Change Notification. |
| 345 |
type: bool |
| 346 |
cseNormalModeChangeNotify: |
| 347 |
description: Normal Mode Change Notification. |
| 348 |
type: bool |
| 349 |
ospf: |
| 350 |
description: SNMP OSPF traps. |
| 351 |
type: dict |
| 352 |
suboptions: |
| 353 |
enable: |
| 354 |
description: Enable SNMP OSPF traps. |
| 355 |
type: bool |
| 356 |
ospfv3: |
| 357 |
description: SNMP OSPFv3 traps. |
| 358 |
type: dict |
| 359 |
suboptions: |
| 360 |
enable: |
| 361 |
description: Enable SNMP OSPFv3 traps. |
| 362 |
type: bool |
| 363 |
rf: |
| 364 |
description: RF traps. |
| 365 |
type: dict |
| 366 |
suboptions: |
| 367 |
enable: |
| 368 |
description: |
| 369 |
- Enable rf traps. |
| 370 |
- This option is unsupported on MDS switches. |
| 371 |
type: bool |
| 372 |
redundancy_framework: |
| 373 |
description: Redundancy_Framework (RF) Sup switchover MIB. |
| 374 |
type: bool |
| 375 |
rmon: |
| 376 |
description: RMON traps. |
| 377 |
type: dict |
| 378 |
suboptions: |
| 379 |
enable: |
| 380 |
description: |
| 381 |
- Enable rmon traps. |
| 382 |
- This option is unsupported on MDS switches. |
| 383 |
type: bool |
| 384 |
fallingAlarm: |
| 385 |
description: Rmon falling alarm. |
| 386 |
type: bool |
| 387 |
hcFallingAlarm: |
| 388 |
description: High capacity Rmon falling alarm. |
| 389 |
type: bool |
| 390 |
hcRisingAlarm: |
| 391 |
description: High capacity Rmon rising alarm. |
| 392 |
type: bool |
| 393 |
risingAlarm: |
| 394 |
description: Rmon rising alarm. |
| 395 |
type: bool |
| 396 |
snmp: |
| 397 |
description: SNMP traps. |
| 398 |
type: dict |
| 399 |
suboptions: |
| 400 |
enable: |
| 401 |
description: |
| 402 |
- Enable snmp traps. |
| 403 |
- This option is unsupported on MDS switches. |
| 404 |
type: bool |
| 405 |
authentication: |
| 406 |
description: SNMP authentication trap. |
| 407 |
type: bool |
| 408 |
storm_control: |
| 409 |
description: Storm-Control traps. |
| 410 |
type: dict |
| 411 |
suboptions: |
| 412 |
enable: |
| 413 |
description: |
| 414 |
- Enable storm-control traps. |
| 415 |
- This option is unsupported on MDS switches. |
| 416 |
type: bool |
| 417 |
cpscEventRev1: |
| 418 |
description: |
| 419 |
- Port-Storm-Control-Event. |
| 420 |
- This option is unsupported on MDS switches. |
| 421 |
type: bool |
| 422 |
trap_rate: |
| 423 |
description: Number of traps per minute. |
| 424 |
type: bool |
| 425 |
stpx: |
| 426 |
description: |
| 427 |
- Stpx traps. |
| 428 |
- This option is unsupported on MDS switches. |
| 429 |
type: dict |
| 430 |
suboptions: |
| 431 |
enable: |
| 432 |
description: Enable stpx traps. |
| 433 |
type: bool |
| 434 |
inconsistency: |
| 435 |
description: Enable SNMP STPX MIB InconsistencyUpdate traps. |
| 436 |
type: bool |
| 437 |
loop_inconsistency: |
| 438 |
description: Enable SNMP STPX MIB LoopInconsistencyUpdate traps. |
| 439 |
type: bool |
| 440 |
root_inconsistency: |
| 441 |
description: Enable SNMP STPX MIB RootInconsistencyUpdate traps. |
| 442 |
type: bool |
| 443 |
syslog: |
| 444 |
description: Enable syslog traps. |
| 445 |
type: dict |
| 446 |
suboptions: |
| 447 |
enable: |
| 448 |
description: |
| 449 |
- Enable syslog traps. |
| 450 |
- This option is unsupported on MDS switches. |
| 451 |
type: bool |
| 452 |
message_generated: |
| 453 |
description: Message Generated Notification. |
| 454 |
type: bool |
| 455 |
sysmgr: |
| 456 |
description: Sysmgr traps. |
| 457 |
type: dict |
| 458 |
suboptions: |
| 459 |
enable: |
| 460 |
description: |
| 461 |
- Enable sysmgr traps. |
| 462 |
- This option is unsupported on MDS switches. |
| 463 |
type: bool |
| 464 |
cseFailSwCoreNotifyExtended: |
| 465 |
description: Software Core Notification. |
| 466 |
type: bool |
| 467 |
system: |
| 468 |
description: System traps. |
| 469 |
type: dict |
| 470 |
suboptions: |
| 471 |
enable: |
| 472 |
description: |
| 473 |
- Enable system traps. |
| 474 |
- This option is unsupported on MDS switches. |
| 475 |
type: bool |
| 476 |
clock_change_notification: |
| 477 |
description: Clock-change-notification traps. |
| 478 |
type: bool |
| 479 |
upgrade: |
| 480 |
description: Upgrade traps. |
| 481 |
type: dict |
| 482 |
suboptions: |
| 483 |
enable: |
| 484 |
description: |
| 485 |
- Enable upgrade traps. |
| 486 |
- This option is unsupported on MDS switches. |
| 487 |
type: bool |
| 488 |
upgradeJobStatusNotify: |
| 489 |
description: Upgrade Job Status Notification. |
| 490 |
type: bool |
| 491 |
upgradeOpNotifyOnCompletion: |
| 492 |
description: Upgrade Global Status Notification. |
| 493 |
type: bool |
| 494 |
vtp: |
| 495 |
description: |
| 496 |
- VTP traps. |
| 497 |
- This option is unsupported on MDS switches. |
| 498 |
type: dict |
| 499 |
suboptions: |
| 500 |
enable: |
| 501 |
description: Enable VTP traps. |
| 502 |
type: bool |
| 503 |
notifs: |
| 504 |
description: |
| 505 |
- Enable vtpConfigRevNumberError vtpConfigDigestEnable vtpConfigRevNumberError vtpConfigDigestError |
| 506 |
vtpServerDisabled vtpVersionOneDeviceDetected vlanTrunkPortDynamicStatusChange vtpLocalModeChanged |
| 507 |
vtpVersionInUseChanged notification. |
| 508 |
type: bool |
| 509 |
vlancreate: |
| 510 |
description: Enable vtpVlanCreated notification. |
| 511 |
type: bool |
| 512 |
vlandelete: |
| 513 |
description: Enable vtpVlanDeleted notification. |
| 514 |
type: bool |
| 515 |
engine_id: |
| 516 |
description: |
| 517 |
- Configure a local SNMPv3 engineID. |
| 518 |
- This option is unsupported on MDS switches. |
| 519 |
type: dict |
| 520 |
suboptions: |
| 521 |
local: |
| 522 |
description: EngineID of the local agent. |
| 523 |
type: str |
| 524 |
global_enforce_priv: |
| 525 |
description: Globally enforce privacy for all the users. |
| 526 |
type: bool |
| 527 |
hosts: |
| 528 |
description: |
| 529 |
- Specify hosts to receive SNMP notifications. |
| 530 |
- SNMP hosts config lines that appear separately in running-config must be added as individual dictionaries. |
| 531 |
type: list |
| 532 |
elements: dict |
| 533 |
suboptions: |
| 534 |
host: |
| 535 |
description: IPv4 or IPv6 address or DNS Name of SNMP notification host. |
| 536 |
type: str |
| 537 |
community: |
| 538 |
description: SNMP community string or SNMPv3 user name (Max Size 32). |
| 539 |
type: str |
| 540 |
filter_vrf: |
| 541 |
description: |
| 542 |
- Filters notifications to the notification host receiver based on the configured VRF. |
| 543 |
- This option is unsupported on MDS switches. |
| 544 |
type: str |
| 545 |
informs: |
| 546 |
description: Send Inform messages to this host. |
| 547 |
type: bool |
| 548 |
source_interface: |
| 549 |
description: Source interface to be used for sending out SNMP notifications to this host. |
| 550 |
type: str |
| 551 |
traps: |
| 552 |
description: Send Traps messages to this host. |
| 553 |
type: bool |
| 554 |
use_vrf: |
| 555 |
description: |
| 556 |
- Configures SNMP to use the selected VRF to communicate with the host receiver. |
| 557 |
- This option is unsupported on MDS switches. |
| 558 |
type: str |
| 559 |
version: |
| 560 |
description: SNMP version to use for notification messages. |
| 561 |
type: str |
| 562 |
choices: ["1", "2c", "3"] |
| 563 |
auth: |
| 564 |
description: Use the SNMPv3 authNoPriv Security Level. |
| 565 |
type: str |
| 566 |
priv: |
| 567 |
description: Use the SNMPv3 authPriv Security Level. |
| 568 |
type: str |
| 569 |
udp_port: |
| 570 |
description: The notification host's UDP port number. |
| 571 |
type: int |
| 572 |
location: |
| 573 |
description: Modify sysLocation. |
| 574 |
type: str |
| 575 |
mib: |
| 576 |
description: Mib access parameters. |
| 577 |
type: dict |
| 578 |
suboptions: |
| 579 |
community_map: |
| 580 |
description: SNMP community. |
| 581 |
type: dict |
| 582 |
suboptions: |
| 583 |
community: |
| 584 |
description: SNMP community string (Max Size 32). |
| 585 |
type: str |
| 586 |
context: |
| 587 |
description: Name of the SNMP context (Max Size 32). |
| 588 |
type: str |
| 589 |
packetsize: |
| 590 |
description: Largest SNMP packet size |
| 591 |
type: int |
| 592 |
protocol: |
| 593 |
description: Snmp protocol operations. |
| 594 |
type: dict |
| 595 |
suboptions: |
| 596 |
enable: |
| 597 |
description: Enable/Disable snmp protocol operations. |
| 598 |
type: bool |
| 599 |
source_interface: |
| 600 |
description: |
| 601 |
- Source interface to be used for sending out SNMP notifications. |
| 602 |
- This option is unsupported on MDS switches. |
| 603 |
type: dict |
| 604 |
suboptions: |
| 605 |
informs: |
| 606 |
description: SNMP Inform notifications for which this source interface needs to be used. |
| 607 |
type: str |
| 608 |
traps: |
| 609 |
description: SNMP Trap notifications for which this source interface needs to be used. |
| 610 |
type: str |
| 611 |
system_shutdown: |
| 612 |
description: Configure snmp-server for reload(2). |
| 613 |
type: bool |
| 614 |
tcp_session: |
| 615 |
description: Enable one time authentication for snmp over tcp session. |
| 616 |
type: dict |
| 617 |
suboptions: |
| 618 |
enable: |
| 619 |
description: |
| 620 |
- Enable tcp-session. |
| 621 |
- This option is unsupported on MDS switches. |
| 622 |
type: bool |
| 623 |
auth: |
| 624 |
description: Enable one time authentication for snmp over tcp session. |
| 625 |
type: bool |
| 626 |
users: |
| 627 |
description: Define users who can access the SNMP engine. |
| 628 |
type: dict |
| 629 |
suboptions: |
| 630 |
auth: |
| 631 |
description: SNMP User authentication related settings |
| 632 |
type: list |
| 633 |
elements: dict |
| 634 |
suboptions: |
| 635 |
user: |
| 636 |
description: Name of the user (Max Size 28). |
| 637 |
type: str |
| 638 |
group: |
| 639 |
description: Group name (ignored for notif target user) (Max Size 28). |
| 640 |
type: str |
| 641 |
authentication: |
| 642 |
description: Authentication parameters for the user. |
| 643 |
type: dict |
| 644 |
suboptions: |
| 645 |
algorithm: |
| 646 |
description: Select algorithm for authentication. |
| 647 |
type: str |
| 648 |
choices: ["md5", "sha", "sha-256"] |
| 649 |
password: |
| 650 |
description: |
| 651 |
- Authentication password for user (Max Size 127). |
| 652 |
- If this value is localized, it has to be enclosed in quotes in the task. |
| 653 |
type: str |
| 654 |
engine_id: |
| 655 |
description: |
| 656 |
- EngineID for configuring notif target user (for V3 informs). |
| 657 |
- This value needs to be enclosed in quotes in the task. |
| 658 |
type: str |
| 659 |
localized_key: |
| 660 |
description: Specifies whether the passwords are in localized key format. |
| 661 |
type: bool |
| 662 |
localizedv2_key: |
| 663 |
description: Specifies whether the passwords are in localized V2 key format. |
| 664 |
type: bool |
| 665 |
priv: |
| 666 |
description: Encryption parameters for the user. |
| 667 |
type: dict |
| 668 |
suboptions: |
| 669 |
privacy_password: |
| 670 |
description: |
| 671 |
- Privacy password for user (Max Size 130). |
| 672 |
- If this value is localized, it has to be enclosed in quotes in the task. |
| 673 |
type: str |
| 674 |
aes_128: |
| 675 |
description: Use 128-bit AES algorithm for privacy. |
| 676 |
type: bool |
| 677 |
use_acls: |
| 678 |
description: Set IPv4 and IPv6 ACL to use. |
| 679 |
type: list |
| 680 |
elements: dict |
| 681 |
suboptions: |
| 682 |
user: |
| 683 |
description: Name of the user (Max Size 28). |
| 684 |
type: str |
| 685 |
ipv4: |
| 686 |
description: Specify IPv4 ACL, the ACL name specified after must be IPv4 ACL. |
| 687 |
type: str |
| 688 |
ipv6: |
| 689 |
description: Specify IPv6 ACL, the ACL name specified after must be IPv6 ACL. |
| 690 |
type: str |
| 691 |
state: |
| 692 |
description: |
| 693 |
- The state the configuration should be left in. |
| 694 |
- The states C(replaced) and C(overridden) have identical behaviour for this module. |
| 695 |
- Please refer to examples for more details. |
| 696 |
type: str |
| 697 |
choices: |
| 698 |
- merged |
| 699 |
- replaced |
| 700 |
- overridden |
| 701 |
- deleted |
| 702 |
- parsed |
| 703 |
- gathered |
| 704 |
- rendered |
| 705 |
default: merged |
| 706 |
""" |
| 707 |
|
| 708 |
EXAMPLES = """ |
| 709 |
# Using merged |
| 710 |
|
| 711 |
# Before state: |
| 712 |
# ------------- |
| 713 |
# nxos-9k-rdo# show running-config | section "^snmp-server" |
| 714 |
# snmp-server user admin network-admin auth md5 0xcbde46b02c46e0bcd3ac5af6a8b13da9 priv 0xcbde46b02c46e0bcd3ac5af6a8b13da9 localizedkey |
| 715 |
|
| 716 |
- name: Merge the provided configuration with the existing running configuration |
| 717 |
cisco.nxos.nxos_snmp_server: |
| 718 |
config: |
| 719 |
aaa_user: |
| 720 |
cache_timeout: 36000 |
| 721 |
communities: |
| 722 |
- community: public |
| 723 |
group: network-operator |
| 724 |
- community: private |
| 725 |
group: network-admin |
| 726 |
contact: nxosswitchadmin@localhost |
| 727 |
location: serverroom-1 |
| 728 |
traps: |
| 729 |
aaa: |
| 730 |
server_state_change: true |
| 731 |
system: |
| 732 |
clock_change_notification: true |
| 733 |
hosts: |
| 734 |
- host: 192.0.2.1 |
| 735 |
traps: true |
| 736 |
version: '1' |
| 737 |
community: public |
| 738 |
- host: 192.0.2.1 |
| 739 |
source_interface: Ethernet1/1 |
| 740 |
- host: 192.0.2.2 |
| 741 |
informs: true |
| 742 |
version: '3' |
| 743 |
auth: NMS |
| 744 |
users: |
| 745 |
auth: |
| 746 |
- user: snmp_user_1 |
| 747 |
group: network-operator |
| 748 |
authentication: |
| 749 |
algorithm: md5 |
| 750 |
password: '0x5632724fb8ac3699296af26281e1d0f1' |
| 751 |
localized_key: true |
| 752 |
- user: snmp_user_2 |
| 753 |
group: network-operator |
| 754 |
authentication: |
| 755 |
algorithm: md5 |
| 756 |
password: '0x5632724fb8ac3699296af26281e1d0f1' |
| 757 |
localized_key: true |
| 758 |
priv: |
| 759 |
privacy_password: '0x5632724fb8ac3699296af26281e1d0f1' |
| 760 |
aes_128: true |
| 761 |
use_acls: |
| 762 |
- user: snmp_user_1 |
| 763 |
ipv4: acl1 |
| 764 |
ipv6: acl2 |
| 765 |
- user: snmp_user_2 |
| 766 |
ipv4: acl3 |
| 767 |
ipv6: acl4 |
| 768 |
|
| 769 |
# Task output |
| 770 |
# ------------- |
| 771 |
# before: |
| 772 |
# users: |
| 773 |
# auth: |
| 774 |
# - user: admin |
| 775 |
# group: network-admin |
| 776 |
# authentication: |
| 777 |
# algorithm: md5 |
| 778 |
# password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" |
| 779 |
# localized_key: true |
| 780 |
# priv: |
| 781 |
# privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" |
| 782 |
# |
| 783 |
# commands: |
| 784 |
# - snmp-server contact nxosswitchadmin@localhost |
| 785 |
# - snmp-server location serverroom-1 |
| 786 |
# - snmp-server aaa-user cache-timeout 36000 |
| 787 |
# - snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey |
| 788 |
# - snmp-server user snmp_user_2 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128 0x5632724fb8ac3699296af26281e1d0f1 localizedkey |
| 789 |
# - snmp-server user snmp_user_1 use-ipv4acl acl1 use-ipv6acl acl2 |
| 790 |
# - snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4 |
| 791 |
# - snmp-server host 192.0.2.1 traps version 1 public |
| 792 |
# - snmp-server host 192.0.2.1 source-interface Ethernet1/1 |
| 793 |
# - snmp-server host 192.0.2.2 informs version 3 auth NMS |
| 794 |
# - snmp-server community private group network-admin |
| 795 |
# - snmp-server community public group network-operator |
| 796 |
# - snmp-server enable traps aaa server-state-change |
| 797 |
# - snmp-server enable traps system Clock-change-notification |
| 798 |
# |
| 799 |
# after: |
| 800 |
# aaa_user: |
| 801 |
# cache_timeout: 36000 |
| 802 |
# communities: |
| 803 |
# - community: private |
| 804 |
# group: network-admin |
| 805 |
# - community: public |
| 806 |
# group: network-operator |
| 807 |
# contact: nxosswitchadmin@localhost |
| 808 |
# location: serverroom-1 |
| 809 |
# traps: |
| 810 |
# aaa: |
| 811 |
# server_state_change: true |
| 812 |
# system: |
| 813 |
# clock_change_notification: true |
| 814 |
# hosts: |
| 815 |
# - host: 192.0.2.1 |
| 816 |
# traps: true |
| 817 |
# version: "1" |
| 818 |
# community: public |
| 819 |
# |
| 820 |
# - host: 192.0.2.1 |
| 821 |
# source_interface: Ethernet1/1 |
| 822 |
# |
| 823 |
# - host: 192.0.2.2 |
| 824 |
# informs: true |
| 825 |
# version: "3" |
| 826 |
# auth: NMS |
| 827 |
# users: |
| 828 |
# auth: |
| 829 |
# - user: admin |
| 830 |
# group: network-admin |
| 831 |
# authentication: |
| 832 |
# algorithm: md5 |
| 833 |
# password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" |
| 834 |
# localized_key: true |
| 835 |
# priv: |
| 836 |
# privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" |
| 837 |
# |
| 838 |
# - user: snmp_user_1 |
| 839 |
# group: network-operator |
| 840 |
# authentication: |
| 841 |
# algorithm: md5 |
| 842 |
# password: "0x5632724fb8ac3699296af26281e1d0f1" |
| 843 |
# localized_key: true |
| 844 |
# |
| 845 |
# - authentication: |
| 846 |
# algorithm: md5 |
| 847 |
# localized_key: true |
| 848 |
# password: "0x5632724fb8ac3699296af26281e1d0f1" |
| 849 |
# priv: |
| 850 |
# aes_128: true |
| 851 |
# privacy_password: "0x5632724fb8ac3699296af26281e1d0f1" |
| 852 |
# group: network-operator |
| 853 |
# user: snmp_user_2 |
| 854 |
# |
| 855 |
# use_acls: |
| 856 |
# - user: snmp_user_1 |
| 857 |
# ipv4: acl1 |
| 858 |
# ipv6: acl2 |
| 859 |
# - user: snmp_user_2 |
| 860 |
# ipv4: acl3 |
| 861 |
# ipv6: acl4 |
| 862 |
|
| 863 |
# After state: |
| 864 |
# ------------ |
| 865 |
# nxos-9k-rdo# show running-config | section "^snmp-server" |
| 866 |
# snmp-server contact nxosswitchadmin@localhost |
| 867 |
# snmp-server location serverroom-1 |
| 868 |
# snmp-server aaa-user cache-timeout 36000 |
| 869 |
# snmp-server user admin network-admin auth md5 0xcbde46b02c46e0bcd3ac5af6a8b13da9 priv 0xcbde46b02c46e0bcd3ac5af6a8b13da9 localizedkey |
| 870 |
# snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey |
| 871 |
# snmp-server user snmp_user_2 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128 0x5632724fb8ac3699296af26281e1d0f1 localizedkey |
| 872 |
# snmp-server user snmp_user_1 use-ipv4acl acl1 use-ipv6acl acl2 |
| 873 |
# snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4 |
| 874 |
# snmp-server host 192.0.2.1 traps version 1 public |
| 875 |
# snmp-server host 192.0.2.1 source-interface Ethernet1/1 |
| 876 |
# snmp-server host 192.0.2.2 informs version 3 auth NMS |
| 877 |
# snmp-server community private group network-admin |
| 878 |
# snmp-server community public group network-operator |
| 879 |
# snmp-server enable traps aaa server-state-change |
| 880 |
# snmp-server enable traps system Clock-change-notification |
| 881 |
|
| 882 |
# Using replaced |
| 883 |
|
| 884 |
# Before state: |
| 885 |
# ------------ |
| 886 |
# nxos-9k-rdo# show running-config | section "^snmp-server" |
| 887 |
# snmp-server contact nxosswitchadmin@localhost |
| 888 |
# snmp-server location serverroom-1 |
| 889 |
# snmp-server aaa-user cache-timeout 36000 |
| 890 |
# snmp-server user admin network-admin auth md5 0xcbde46b02c46e0bcd3ac5af6a8b13da9 priv 0xcbde46b02c46e0bcd3ac5af6a8b13da9 localizedkey |
| 891 |
# snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey |
| 892 |
# snmp-server user snmp_user_2 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128 0x5632724fb8ac3699296af26281e1d0f1 localizedkey |
| 893 |
# snmp-server user snmp_user_1 use-ipv4acl acl1 use-ipv6acl acl2 |
| 894 |
# snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4 |
| 895 |
# snmp-server host 192.0.2.1 traps version 1 public |
| 896 |
# snmp-server host 192.0.2.1 source-interface Ethernet1/1 |
| 897 |
# snmp-server host 192.0.2.2 informs version 3 auth NMS |
| 898 |
# snmp-server community private group network-admin |
| 899 |
# snmp-server community public group network-operator |
| 900 |
# snmp-server enable traps aaa server-state-change |
| 901 |
# snmp-server enable traps system Clock-change-notification |
| 902 |
|
| 903 |
- name: Replace snmp-server configurations of listed snmp-server with provided configurations |
| 904 |
cisco.nxos.nxos_snmp_server: |
| 905 |
config: |
| 906 |
aaa_user: |
| 907 |
cache_timeout: 36000 |
| 908 |
communities: |
| 909 |
- community: public |
| 910 |
group: network-operator |
| 911 |
- community: secret |
| 912 |
group: network-operator |
| 913 |
contact: nxosswitchadmin2@localhost |
| 914 |
location: serverroom-2 |
| 915 |
traps: |
| 916 |
aaa: |
| 917 |
server_state_change: true |
| 918 |
hosts: |
| 919 |
- host: 192.0.2.1 |
| 920 |
traps: true |
| 921 |
version: '1' |
| 922 |
community: public |
| 923 |
- host: 192.0.2.1 |
| 924 |
source_interface: Ethernet1/1 |
| 925 |
- host: 192.0.3.2 |
| 926 |
informs: true |
| 927 |
version: '3' |
| 928 |
auth: NMS |
| 929 |
users: |
| 930 |
auth: |
| 931 |
- user: admin |
| 932 |
group: network-admin |
| 933 |
authentication: |
| 934 |
algorithm: md5 |
| 935 |
password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" |
| 936 |
localized_key: true |
| 937 |
priv: |
| 938 |
privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" |
| 939 |
|
| 940 |
- user: snmp_user_1 |
| 941 |
group: network-operator |
| 942 |
authentication: |
| 943 |
algorithm: md5 |
| 944 |
password: '0x5632724fb8ac3699296af26281e1d0f1' |
| 945 |
localized_key: true |
| 946 |
|
| 947 |
- user: snmp_user_2 |
| 948 |
group: network-operator |
| 949 |
authentication: |
| 950 |
algorithm: md5 |
| 951 |
password: '0x5632724fb8ac3699296af26281e1d0f1' |
| 952 |
localized_key: true |
| 953 |
priv: |
| 954 |
privacy_password: '0x5632724fb8ac3699296af26281e1d0f1' |
| 955 |
aes_128: true |
| 956 |
use_acls: |
| 957 |
- user: snmp_user_1 |
| 958 |
ipv4: acl1 |
| 959 |
ipv6: acl2 |
| 960 |
state: replaced |
| 961 |
|
| 962 |
# Task output |
| 963 |
# ------------- |
| 964 |
# before: |
| 965 |
# aaa_user: |
| 966 |
# cache_timeout: 36000 |
| 967 |
# communities: |
| 968 |
# - community: private |
| 969 |
# group: network-admin |
| 970 |
# - community: public |
| 971 |
# group: network-operator |
| 972 |
# contact: nxosswitchadmin@localhost |
| 973 |
# location: serverroom-1 |
| 974 |
# traps: |
| 975 |
# aaa: |
| 976 |
# server_state_change: true |
| 977 |
# system: |
| 978 |
# clock_change_notification: true |
| 979 |
# hosts: |
| 980 |
# - host: 192.0.2.1 |
| 981 |
# traps: true |
| 982 |
# version: "1" |
| 983 |
# community: public |
| 984 |
# |
| 985 |
# - host: 192.0.2.1 |
| 986 |
# source_interface: Ethernet1/1 |
| 987 |
# |
| 988 |
# - host: 192.0.2.2 |
| 989 |
# informs: true |
| 990 |
# version: "3" |
| 991 |
# auth: NMS |
| 992 |
# users: |
| 993 |
# auth: |
| 994 |
# - user: admin |
| 995 |
# group: network-admin |
| 996 |
# authentication: |
| 997 |
# algorithm: md5 |
| 998 |
# password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" |
| 999 |
# localized_key: true |
| 1000 |
# priv: |
| 1001 |
# privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" |
| 1002 |
# |
| 1003 |
# - user: snmp_user_1 |
| 1004 |
# group: network-operator |
| 1005 |
# authentication: |
| 1006 |
# algorithm: md5 |
| 1007 |
# password: "0x5632724fb8ac3699296af26281e1d0f1" |
| 1008 |
# localized_key: true |
| 1009 |
# |
| 1010 |
# - authentication: |
| 1011 |
# algorithm: md5 |
| 1012 |
# localized_key: true |
| 1013 |
# password: "0x5632724fb8ac3699296af26281e1d0f1" |
| 1014 |
# priv: |
| 1015 |
# aes_128: true |
| 1016 |
# privacy_password: "0x5632724fb8ac3699296af26281e1d0f1" |
| 1017 |
# group: network-operator |
| 1018 |
# user: snmp_user_2 |
| 1019 |
# |
| 1020 |
# use_acls: |
| 1021 |
# - user: snmp_user_1 |
| 1022 |
# ipv4: acl1 |
| 1023 |
# ipv6: acl2 |
| 1024 |
# - user: snmp_user_2 |
| 1025 |
# ipv4: acl3 |
| 1026 |
# ipv6: acl4 |
| 1027 |
# |
| 1028 |
# commands: |
| 1029 |
# - snmp-server contact nxosswitchadmin2@localhost |
| 1030 |
# - no snmp-server enable traps system Clock-change-notification |
| 1031 |
# - snmp-server location serverroom-2 |
| 1032 |
# - no snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4 |
| 1033 |
# - no snmp-server host 192.0.2.2 informs version 3 auth NMS |
| 1034 |
# - snmp-server host 192.0.3.2 informs version 3 auth NMS |
| 1035 |
# - no snmp-server community private group network-admin |
| 1036 |
# - snmp-server community secret group network-operator |
| 1037 |
# |
| 1038 |
# after: |
| 1039 |
# aaa_user: |
| 1040 |
# cache_timeout: 36000 |
| 1041 |
# communities: |
| 1042 |
# - community: public |
| 1043 |
# group: network-operator |
| 1044 |
# - community: secret |
| 1045 |
# group: network-operator |
| 1046 |
# contact: nxosswitchadmin2@localhost |
| 1047 |
# location: serverroom-2 |
| 1048 |
# traps: |
| 1049 |
# aaa: |
| 1050 |
# server_state_change: true |
| 1051 |
# hosts: |
| 1052 |
# - host: 192.0.2.1 |
| 1053 |
# traps: true |
| 1054 |
# version: '1' |
| 1055 |
# community: public |
| 1056 |
# - host: 192.0.2.1 |
| 1057 |
# source_interface: Ethernet1/1 |
| 1058 |
# - host: 192.0.3.2 |
| 1059 |
# informs: true |
| 1060 |
# version: '3' |
| 1061 |
# auth: NMS |
| 1062 |
# users: |
| 1063 |
# auth: |
| 1064 |
# - user: admin |
| 1065 |
# group: network-admin |
| 1066 |
# authentication: |
| 1067 |
# algorithm: md5 |
| 1068 |
# password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" |
| 1069 |
# localized_key: true |
| 1070 |
# priv: |
| 1071 |
# privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" |
| 1072 |
# |
| 1073 |
# - user: snmp_user_1 |
| 1074 |
# group: network-operator |
| 1075 |
# authentication: |
| 1076 |
# algorithm: md5 |
| 1077 |
# password: '0x5632724fb8ac3699296af26281e1d0f1' |
| 1078 |
# localized_key: true |
| 1079 |
# |
| 1080 |
# - user: snmp_user_2 |
| 1081 |
# group: network-operator |
| 1082 |
# authentication: |
| 1083 |
# algorithm: md5 |
| 1084 |
# password: '0x5632724fb8ac3699296af26281e1d0f1' |
| 1085 |
# localized_key: true |
| 1086 |
# priv: |
| 1087 |
# privacy_password: '0x5632724fb8ac3699296af26281e1d0f1' |
| 1088 |
# aes_128: true |
| 1089 |
# |
| 1090 |
# use_acls: |
| 1091 |
# - user: snmp_user_1 |
| 1092 |
# ipv4: acl1 |
| 1093 |
# ipv6: acl2 |
| 1094 |
# |
| 1095 |
|
| 1096 |
# After state: |
| 1097 |
# ------------ |
| 1098 |
# nxos-9k-rdo# show running-config | section "^snmp-server" |
| 1099 |
# snmp-server contact nxosswitchadmin2@localhost |
| 1100 |
# snmp-server location serverroom-2 |
| 1101 |
# snmp-server aaa-user cache-timeout 36000 |
| 1102 |
# snmp-server user admin network-admin auth md5 0xcbde46b02c46e0bcd3ac5af6a8b13da9 priv 0xcbde46b02c46e0bcd3ac5af6a8b13da9 localizedkey |
| 1103 |
# snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey |
| 1104 |
# snmp-server user snmp_user_2 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128 0x5632724fb8ac3699296af26281e1d0f1 localizedkey |
| 1105 |
# snmp-server user snmp_user_1 use-ipv4acl acl1 use-ipv6acl acl2 |
| 1106 |
# snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4 |
| 1107 |
# snmp-server host 192.0.2.1 traps version 1 public |
| 1108 |
# snmp-server host 192.0.2.1 source-interface Ethernet1/1 |
| 1109 |
# snmp-server host 192.0.2.2 informs version 3 auth NMS |
| 1110 |
# snmp-server community secret group network-operator |
| 1111 |
# snmp-server community public group network-operator |
| 1112 |
# snmp-server enable traps aaa server-state-change |
| 1113 |
# snmp-server enable traps system Clock-change-notification |
| 1114 |
|
| 1115 |
# Using deleted |
| 1116 |
|
| 1117 |
# Before state: |
| 1118 |
# ------------ |
| 1119 |
# nxos-9k-rdo# show running-config | section "^snmp-server" |
| 1120 |
# snmp-server contact nxosswitchadmin@localhost |
| 1121 |
# snmp-server location serverroom-1 |
| 1122 |
# snmp-server aaa-user cache-timeout 36000 |
| 1123 |
# snmp-server user admin network-admin auth md5 0xcbde46b02c46e0bcd3ac5af6a8b13da9 priv 0xcbde46b02c46e0bcd3ac5af6a8b13da9 localizedkey |
| 1124 |
# snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey |
| 1125 |
# snmp-server user snmp_user_2 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128 0x5632724fb8ac3699296af26281e1d0f1 localizedkey |
| 1126 |
# snmp-server user snmp_user_1 use-ipv4acl acl1 use-ipv6acl acl2 |
| 1127 |
# snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4 |
| 1128 |
# snmp-server host 192.0.2.1 traps version 1 public |
| 1129 |
# snmp-server host 192.0.2.1 source-interface Ethernet1/1 |
| 1130 |
# snmp-server host 192.0.2.2 informs version 3 auth NMS |
| 1131 |
# snmp-server community private group network-admin |
| 1132 |
# snmp-server community public group network-operator |
| 1133 |
# snmp-server enable traps aaa server-state-change |
| 1134 |
# snmp-server enable traps system Clock-change-notification |
| 1135 |
|
| 1136 |
- name: Delete SNMP Server configurations from the device (admin user will not be deleted) |
| 1137 |
cisco.nxos.nxos_snmp_server: |
| 1138 |
state: deleted |
| 1139 |
|
| 1140 |
# Task output |
| 1141 |
# ------------- |
| 1142 |
# before: |
| 1143 |
# aaa_user: |
| 1144 |
# cache_timeout: 36000 |
| 1145 |
# communities: |
| 1146 |
# - community: private |
| 1147 |
# group: network-admin |
| 1148 |
# - community: public |
| 1149 |
# group: network-operator |
| 1150 |
# contact: nxosswitchadmin@localhost |
| 1151 |
# location: serverroom-1 |
| 1152 |
# traps: |
| 1153 |
# aaa: |
| 1154 |
# server_state_change: true |
| 1155 |
# system: |
| 1156 |
# clock_change_notification: true |
| 1157 |
# hosts: |
| 1158 |
# - host: 192.0.2.1 |
| 1159 |
# traps: true |
| 1160 |
# version: "1" |
| 1161 |
# community: public |
| 1162 |
# |
| 1163 |
# - host: 192.0.2.1 |
| 1164 |
# source_interface: Ethernet1/1 |
| 1165 |
# |
| 1166 |
# - host: 192.0.2.2 |
| 1167 |
# informs: true |
| 1168 |
# version: "3" |
| 1169 |
# auth: NMS |
| 1170 |
# users: |
| 1171 |
# auth: |
| 1172 |
# - user: admin |
| 1173 |
# group: network-admin |
| 1174 |
# authentication: |
| 1175 |
# algorithm: md5 |
| 1176 |
# password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" |
| 1177 |
# localized_key: true |
| 1178 |
# priv: |
| 1179 |
# privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" |
| 1180 |
# |
| 1181 |
# - user: snmp_user_1 |
| 1182 |
# group: network-operator |
| 1183 |
# authentication: |
| 1184 |
# algorithm: md5 |
| 1185 |
# password: "0x5632724fb8ac3699296af26281e1d0f1" |
| 1186 |
# localized_key: true |
| 1187 |
# |
| 1188 |
# - authentication: |
| 1189 |
# algorithm: md5 |
| 1190 |
# localized_key: true |
| 1191 |
# password: "0x5632724fb8ac3699296af26281e1d0f1" |
| 1192 |
# priv: |
| 1193 |
# aes_128: true |
| 1194 |
# privacy_password: "0x5632724fb8ac3699296af26281e1d0f1" |
| 1195 |
# group: network-operator |
| 1196 |
# user: snmp_user_2 |
| 1197 |
# |
| 1198 |
# use_acls: |
| 1199 |
# - user: snmp_user_1 |
| 1200 |
# ipv4: acl1 |
| 1201 |
# ipv6: acl2 |
| 1202 |
# - user: snmp_user_2 |
| 1203 |
# ipv4: acl3 |
| 1204 |
# ipv6: acl4 |
| 1205 |
# |
| 1206 |
# commands: |
| 1207 |
# - no snmp-server contact nxosswitchadmin@localhost |
| 1208 |
# - no snmp-server location serverroom-1 |
| 1209 |
# - no snmp-server aaa-user cache-timeout 36000 |
| 1210 |
# - no snmp-server user admin network-admin auth md5 0xcbde46b02c46e0bcd3ac5af6a8b13da9 priv 0xcbde46b02c46e0bcd3ac5af6a8b13da9 localizedkey |
| 1211 |
# - no snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey |
| 1212 |
# - no snmp-server user snmp_user_2 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128 0x5632724fb8ac3699296af26281e1d0f1 localizedkey |
| 1213 |
# - no snmp-server user snmp_user_1 use-ipv4acl acl1 use-ipv6acl acl2 |
| 1214 |
# - no snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4 |
| 1215 |
# - no snmp-server host 192.0.2.1 traps version 1 public |
| 1216 |
# - no snmp-server host 192.0.2.1 source-interface Ethernet1/1 |
| 1217 |
# - no snmp-server host 192.0.2.2 informs version 3 auth NMS |
| 1218 |
# - no snmp-server community private group network-admin |
| 1219 |
# - no snmp-server community public group network-operator |
| 1220 |
# - no snmp-server enable traps aaa server-state-change |
| 1221 |
# - no snmp-server enable traps system Clock-change-notification |
| 1222 |
# |
| 1223 |
# after: |
| 1224 |
# users: |
| 1225 |
# auth: |
| 1226 |
# - user: admin |
| 1227 |
# group: network-admin |
| 1228 |
# authentication: |
| 1229 |
# algorithm: md5 |
| 1230 |
# password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" |
| 1231 |
# localized_key: true |
| 1232 |
# priv: |
| 1233 |
# privacy_password: "0xcbde46b02c46e0bcd3ac5af6a8b13da9" |
| 1234 |
|
| 1235 |
# After state: |
| 1236 |
# ------------ |
| 1237 |
# nxos-9k-rdo# show running-config | section "^snmp-server" |
| 1238 |
# snmp-server user admin network-admin auth md5 0xcbde46b02c46e0bcd3ac5af6a8b13da9 priv 0xcbde46b02c46e0bcd3ac5af6a8b13da9 localizedkey |
| 1239 |
|
| 1240 |
# Using rendered |
| 1241 |
# --------------- |
| 1242 |
|
| 1243 |
- name: Render platform specific configuration lines with state rendered (without connecting to the device) |
| 1244 |
cisco.nxos.nxos_snmp_server: |
| 1245 |
config: |
| 1246 |
aaa_user: |
| 1247 |
cache_timeout: 36000 |
| 1248 |
communities: |
| 1249 |
- community: public |
| 1250 |
group: network-operator |
| 1251 |
- community: private |
| 1252 |
group: network-admin |
| 1253 |
contact: nxosswitchadmin@localhost |
| 1254 |
location: serverroom-1 |
| 1255 |
traps: |
| 1256 |
aaa: |
| 1257 |
server_state_change: true |
| 1258 |
system: |
| 1259 |
clock_change_notification: true |
| 1260 |
hosts: |
| 1261 |
- host: 192.0.2.1 |
| 1262 |
traps: true |
| 1263 |
version: '1' |
| 1264 |
community: public |
| 1265 |
- host: 192.0.2.1 |
| 1266 |
source_interface: Ethernet1/1 |
| 1267 |
- host: 192.0.2.2 |
| 1268 |
informs: true |
| 1269 |
version: '3' |
| 1270 |
auth: NMS |
| 1271 |
users: |
| 1272 |
auth: |
| 1273 |
- user: snmp_user_1 |
| 1274 |
group: network-operator |
| 1275 |
authentication: |
| 1276 |
algorithm: md5 |
| 1277 |
password: '0x5632724fb8ac3699296af26281e1d0f1' |
| 1278 |
localized_key: true |
| 1279 |
- user: snmp_user_2 |
| 1280 |
group: network-operator |
| 1281 |
authentication: |
| 1282 |
algorithm: md5 |
| 1283 |
password: '0x5632724fb8ac3699296af26281e1d0f1' |
| 1284 |
localized_key: true |
| 1285 |
priv: |
| 1286 |
privacy_password: '0x5632724fb8ac3699296af26281e1d0f1' |
| 1287 |
aes_128: true |
| 1288 |
use_acls: |
| 1289 |
- user: snmp_user_1 |
| 1290 |
ipv4: acl1 |
| 1291 |
ipv6: acl2 |
| 1292 |
- user: snmp_user_2 |
| 1293 |
ipv4: acl3 |
| 1294 |
ipv6: acl4 |
| 1295 |
state: rendered |
| 1296 |
|
| 1297 |
|
| 1298 |
# Task Output (redacted) |
| 1299 |
# ----------------------- |
| 1300 |
# rendered: |
| 1301 |
# - snmp-server contact nxosswitchadmin@localhost |
| 1302 |
# - snmp-server location serverroom-1 |
| 1303 |
# - snmp-server aaa-user cache-timeout 36000 |
| 1304 |
# - snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey |
| 1305 |
# - snmp-server user snmp_user_2 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128 0x5632724fb8ac3699296af26281e1d0f1 localizedkey |
| 1306 |
# - snmp-server user snmp_user_1 use-ipv4acl acl1 use-ipv6acl acl2 |
| 1307 |
# - snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4 |
| 1308 |
# - snmp-server host 192.0.2.1 traps version 1 public |
| 1309 |
# - snmp-server host 192.0.2.1 source-interface Ethernet1/1 |
| 1310 |
# - snmp-server host 192.0.2.2 informs version 3 auth NMS |
| 1311 |
# - snmp-server community private group network-admin |
| 1312 |
# - snmp-server community public group network-operator |
| 1313 |
# - snmp-server enable traps aaa server-state-change |
| 1314 |
# - snmp-server enable traps system Clock-change-notification |
| 1315 |
|
| 1316 |
# Using parsed |
| 1317 |
|
| 1318 |
# parsed.cfg |
| 1319 |
# ------------ |
| 1320 |
# snmp-server contact nxosswitchadmin@localhost |
| 1321 |
# snmp-server location serverroom-1 |
| 1322 |
# snmp-server aaa-user cache-timeout 36000 |
| 1323 |
# snmp-server user snmp_user_1 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 localizedkey |
| 1324 |
# snmp-server user snmp_user_2 network-operator auth md5 0x5632724fb8ac3699296af26281e1d0f1 priv aes-128 0x5632724fb8ac3699296af26281e1d0f1 localizedkey |
| 1325 |
# snmp-server user snmp_user_1 use-ipv4acl acl1 use-ipv6acl acl2 |
| 1326 |
# snmp-server user snmp_user_2 use-ipv4acl acl3 use-ipv6acl acl4 |
| 1327 |
# snmp-server host 192.0.2.1 traps version 1 public |
| 1328 |
# snmp-server host 192.0.2.1 source-interface Ethernet1/1 |
| 1329 |
# snmp-server host 192.0.2.2 informs version 3 auth NMS |
| 1330 |
# snmp-server community private group network-admin |
| 1331 |
# snmp-server community public group network-operator |
| 1332 |
# snmp-server enable traps aaa server-state-change |
| 1333 |
# snmp-server enable traps system Clock-change-notification |
| 1334 |
|
| 1335 |
- name: Parse externally provided snmp-server configuration |
| 1336 |
cisco.nxos.nxos_snmp_server: |
| 1337 |
running_config: "{{ lookup('file', './parsed.cfg') }}" |
| 1338 |
state: parsed |
| 1339 |
|
| 1340 |
# Task output (redacted) |
| 1341 |
# ----------------------- |
| 1342 |
# parsed: |
| 1343 |
# aaa_user: |
| 1344 |
# cache_timeout: 36000 |
| 1345 |
# communities: |
| 1346 |
# - community: private |
| 1347 |
# group: network-admin |
| 1348 |
# - community: public |
| 1349 |
# group: network-operator |
| 1350 |
# contact: nxosswitchadmin@localhost |
| 1351 |
# location: serverroom-1 |
| 1352 |
# traps: |
| 1353 |
# aaa: |
| 1354 |
# server_state_change: true |
| 1355 |
# system: |
| 1356 |
# clock_change_notification: true |
| 1357 |
# hosts: |
| 1358 |
# - host: 192.0.2.1 |
| 1359 |
# traps: true |
| 1360 |
# version: "1" |
| 1361 |
# community: public |
| 1362 |
# |
| 1363 |
# - host: 192.0.2.1 |
| 1364 |
# source_interface: Ethernet1/1 |
| 1365 |
# |
| 1366 |
# - host: 192.0.2.2 |
| 1367 |
# informs: true |
| 1368 |
# version: "3" |
| 1369 |
# auth: NMS |
| 1370 |
# users: |
| 1371 |
# auth: |
| 1372 |
# - user: snmp_user_1 |
| 1373 |
# group: network-operator |
| 1374 |
# authentication: |
| 1375 |
# algorithm: md5 |
| 1376 |
# password: "0x5632724fb8ac3699296af26281e1d0f1" |
| 1377 |
# localized_key: true |
| 1378 |
# |
| 1379 |
# - authentication: |
| 1380 |
# algorithm: md5 |
| 1381 |
# localized_key: true |
| 1382 |
# password: "0x5632724fb8ac3699296af26281e1d0f1" |
| 1383 |
# priv: |
| 1384 |
# aes_128: true |
| 1385 |
# privacy_password: "0x5632724fb8ac3699296af26281e1d0f1" |
| 1386 |
# group: network-operator |
| 1387 |
# user: snmp_user_2 |
| 1388 |
# |
| 1389 |
# use_acls: |
| 1390 |
# - user: snmp_user_1 |
| 1391 |
# ipv4: acl1 |
| 1392 |
# ipv6: acl2 |
| 1393 |
# - user: snmp_user_2 |
| 1394 |
# ipv4: acl3 |
| 1395 |
# ipv6: acl4 |
| 1396 |
# |
| 1397 |
""" |
| 1398 |
|
| 1399 |
RETURN = """ |
| 1400 |
before: |
| 1401 |
description: The configuration prior to the module execution. |
| 1402 |
returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) |
| 1403 |
type: dict |
| 1404 |
sample: > |
| 1405 |
This output will always be in the same format as the |
| 1406 |
module argspec. |
| 1407 |
after: |
| 1408 |
description: The resulting configuration after module execution. |
| 1409 |
returned: when changed |
| 1410 |
type: dict |
| 1411 |
sample: > |
| 1412 |
This output will always be in the same format as the |
| 1413 |
module argspec. |
| 1414 |
commands: |
| 1415 |
description: The set of commands pushed to the remote device. |
| 1416 |
returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) |
| 1417 |
type: list |
| 1418 |
sample: |
| 1419 |
- sample command 1 |
| 1420 |
- sample command 2 |
| 1421 |
- sample command 3 |
| 1422 |
rendered: |
| 1423 |
description: The provided configuration in the task rendered in device-native format (offline). |
| 1424 |
returned: when I(state) is C(rendered) |
| 1425 |
type: list |
| 1426 |
sample: |
| 1427 |
- sample command 1 |
| 1428 |
- sample command 2 |
| 1429 |
- sample command 3 |
| 1430 |
gathered: |
| 1431 |
description: Facts about the network resource gathered from the remote device as structured data. |
| 1432 |
returned: when I(state) is C(gathered) |
| 1433 |
type: list |
| 1434 |
sample: > |
| 1435 |
This output will always be in the same format as the |
| 1436 |
module argspec. |
| 1437 |
parsed: |
| 1438 |
description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. |
| 1439 |
returned: when I(state) is C(parsed) |
| 1440 |
type: list |
| 1441 |
sample: > |
| 1442 |
This output will always be in the same format as the |
| 1443 |
module argspec. |
| 1444 |
""" |
| 1445 |
|
| 1446 |
from ansible.module_utils.basic import AnsibleModule |
| 1447 |
|
| 1448 |
from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.snmp_server.snmp_server import ( |
| 1449 |
Snmp_serverArgs, |
| 1450 |
) |
| 1451 |
from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.snmp_server.snmp_server import ( |
| 1452 |
Snmp_server, |
| 1453 |
) |
| 1454 |
|
| 1455 |
|
| 1456 |
def main(): |
| 1457 |
""" |
| 1458 |
Main entry point for module execution |
| 1459 |
|
| 1460 |
:returns: the result form module invocation |
| 1461 |
""" |
| 1462 |
module = AnsibleModule( |
| 1463 |
argument_spec=Snmp_serverArgs.argument_spec, |
| 1464 |
mutually_exclusive=[["config", "running_config"]], |
| 1465 |
required_if=[ |
| 1466 |
["state", "merged", ["config"]], |
| 1467 |
["state", "replaced", ["config"]], |
| 1468 |
["state", "overridden", ["config"]], |
| 1469 |
["state", "rendered", ["config"]], |
| 1470 |
["state", "parsed", ["running_config"]], |
| 1471 |
], |
| 1472 |
supports_check_mode=True, |
| 1473 |
) |
| 1474 |
|
| 1475 |
result = Snmp_server(module).execute_module() |
| 1476 |
module.exit_json(**result) |
| 1477 |
|
| 1478 |
|
| 1479 |
if __name__ == "__main__": |
| 1480 |
main() |