| 1 |
--- |
| 2 |
# getNetworkSwitchMtu - checked |
| 3 |
cisco.meraki.networks_switch_mtu_info: |
| 4 |
query: >- |
| 5 |
if .meraki_response then |
| 6 |
.meraki_response | |
| 7 |
if .overrides and (.overrides | length > 0) then |
| 8 |
. as $parent | |
| 9 |
[ |
| 10 |
$parent.overrides[] | |
| 11 |
. as $override | |
| 12 |
# Create entries for each switch serial |
| 13 |
($override.switches // [])[] | |
| 14 |
{ |
| 15 |
name: (. | tostring), |
| 16 |
canonical_facts: { |
| 17 |
ansible_product_serial: (. | tostring) |
| 18 |
}, |
| 19 |
facts: { |
| 20 |
device_type: "switch", |
| 21 |
mtu_size: $override.mtuSize, |
| 22 |
default_mtu_size: $parent.defaultMtuSize |
| 23 |
} |
| 24 |
} |
| 25 |
] |
| 26 |
else |
| 27 |
[] |
| 28 |
end |
| 29 |
else [] |
| 30 |
end |
| 31 |
|
| 32 |
# Devices |
| 33 |
cisco.meraki.devices_info: |
| 34 |
query: >- |
| 35 |
if .meraki_response then |
| 36 |
.meraki_response | [.] | flatten | |
| 37 |
map({ |
| 38 |
name: ((.name | select(. != "")) // (.productType + "-" + .serial)), |
| 39 |
canonical_facts: { |
| 40 |
ansible_product_serial: .serial, |
| 41 |
hostname: (.lanIp // "") |
| 42 |
}, |
| 43 |
facts: { |
| 44 |
device_type: .productType, |
| 45 |
meraki_network_id: .networkId, |
| 46 |
ansible_hostname: (.lanIp // ""), |
| 47 |
ansible_product_name: .model, |
| 48 |
ansible_bios_version: .firmware, |
| 49 |
macaddress: .mac |
| 50 |
} |
| 51 |
}) |
| 52 |
else [] |
| 53 |
end |
| 54 |
|
| 55 |
# getDeviceSwitchPort |
| 56 |
cisco.meraki.devices_switch_ports_info: |
| 57 |
query: >- |
| 58 |
if .meraki_response then |
| 59 |
[.meraki_response] | |
| 60 |
map({ |
| 61 |
name: (.name // ("port-" + (.portId | tostring))), |
| 62 |
canonical_facts: { |
| 63 |
ansible_product_serial: .module.serial |
| 64 |
}, |
| 65 |
facts: { |
| 66 |
device_type: "switch", |
| 67 |
port_id: .portId, |
| 68 |
vlan_id: .vlan, |
| 69 |
} |
| 70 |
}) |
| 71 |
else [] |
| 72 |
end |
| 73 |
|
| 74 |
# getNetworkSwitchStack |
| 75 |
cisco.meraki.networks_switch_stacks_info: |
| 76 |
query: >- |
| 77 |
if .meraki_response then |
| 78 |
.meraki_response | |
| 79 |
. as $parent | |
| 80 |
[ |
| 81 |
# Create entries for each switch serial in the stack |
| 82 |
($parent.serials // [])[] | |
| 83 |
{ |
| 84 |
name: (. | tostring), |
| 85 |
canonical_facts: { |
| 86 |
ansible_product_serial: (. | tostring) |
| 87 |
}, |
| 88 |
facts: { |
| 89 |
device_type: "switch", |
| 90 |
stack_id: ($parent.id | tostring), |
| 91 |
stack_name: $parent.name, |
| 92 |
virtual_mac: $parent.virtualMac, |
| 93 |
is_monitor_only: $parent.isMonitorOnly |
| 94 |
} |
| 95 |
} |
| 96 |
] |
| 97 |
else [] |
| 98 |
end |
| 99 |
|
| 100 |
# getNetworkSwitchStackRoutingInterfaces |
| 101 |
cisco.meraki.networks_switch_stacks_routing_interfaces_info: |
| 102 |
query: >- |
| 103 |
if .meraki_response then |
| 104 |
(.meraki_response | if type == "array" then . else [.] end) | |
| 105 |
map({ |
| 106 |
name: .name, |
| 107 |
canonical_facts: { |
| 108 |
ansible_product_serial: .serial, |
| 109 |
hostname: .interfaceIp |
| 110 |
}, |
| 111 |
facts: { |
| 112 |
device_type: "switch", |
| 113 |
interface_id: .interfaceId, |
| 114 |
uplink: { |
| 115 |
ipv4_enabled: .uplinkV4, |
| 116 |
ipv6_enabled: .uplinkV6 |
| 117 |
}, |
| 118 |
} |
| 119 |
}) |
| 120 |
else [] |
| 121 |
end |
| 122 |
|
| 123 |
# updateDeviceSwitchPort |
| 124 |
cisco.meraki.devices_switch_ports: |
| 125 |
query: >- |
| 126 |
if .meraki_response then |
| 127 |
[.meraki_response] | |
| 128 |
map({ |
| 129 |
name: (.name // ("port-" + (.portId | tostring))), |
| 130 |
canonical_facts: { |
| 131 |
ansible_product_serial: .module.serial |
| 132 |
}, |
| 133 |
facts: { |
| 134 |
device_type: "switch", |
| 135 |
port_id: .portId, |
| 136 |
module: { |
| 137 |
model: .module.model, |
| 138 |
serial: .module.serial, |
| 139 |
slot: .module.slot |
| 140 |
} |
| 141 |
} |
| 142 |
}) |
| 143 |
else [] |
| 144 |
end |
| 145 |
|
| 146 |
# getOrganizationSwitchPortsBySwitch |
| 147 |
cisco.meraki.organizations_switch_ports_by_switch_info: |
| 148 |
query: >- |
| 149 |
if .meraki_response then |
| 150 |
(.meraki_response | if type == "array" then . else [.] end) | |
| 151 |
map({ |
| 152 |
name: .name, |
| 153 |
canonical_facts: { |
| 154 |
ansible_product_serial: .serial, |
| 155 |
hostname: (.mac // "") |
| 156 |
}, |
| 157 |
facts: { |
| 158 |
device_type: "switch", |
| 159 |
mac_address: .mac, |
| 160 |
model: .model, |
| 161 |
switch_info: { |
| 162 |
network_name: .network.name, |
| 163 |
network_id: .network.id |
| 164 |
}, |
| 165 |
} |
| 166 |
}) |
| 167 |
else [] |
| 168 |
end |
| 169 |
|
| 170 |
# getDeviceSwitchPortsStatuses |
| 171 |
cisco.meraki.devices_switch_ports_statuses_info: |
| 172 |
query: >- |
| 173 |
if .meraki_response then |
| 174 |
(.meraki_response.items | if type == "array" then . else [.] end) | |
| 175 |
map({ |
| 176 |
name: .name, |
| 177 |
canonical_facts: { |
| 178 |
ansible_product_serial: .serial, |
| 179 |
hostname: (.mac // "") |
| 180 |
}, |
| 181 |
facts: { |
| 182 |
device_type: "switch", |
| 183 |
mac_address: .mac, |
| 184 |
model: .model, |
| 185 |
switch_info: { |
| 186 |
network_name: .network.name, |
| 187 |
network_id: .network.id |
| 188 |
}, |
| 189 |
} |
| 190 |
}) |
| 191 |
else [] |
| 192 |
end |
| 193 |
|
| 194 |
# getNetworkSwitchAccessPolicies |
| 195 |
cisco.meraki.networks_switch_access_policies_info: |
| 196 |
query: >- |
| 197 |
if .meraki_response then |
| 198 |
(.meraki_response | if type == "array" then . else [.] end) | |
| 199 |
map({ |
| 200 |
name: .name, |
| 201 |
canonical_facts: { |
| 202 |
ansible_machine_id: (.accessPolicyNumber | tostring) |
| 203 |
}, |
| 204 |
facts: { |
| 205 |
device_type: "switch", |
| 206 |
access_policy_number: .accessPolicyNumber, |
| 207 |
access_policy_type: .accessPolicyType, |
| 208 |
} |
| 209 |
}) |
| 210 |
else [] |
| 211 |
end |
| 212 |
|
| 213 |
# getNetworkSwitchSettings |
| 214 |
cisco.meraki.networks_switch_settings_info: |
| 215 |
query: >- |
| 216 |
if .meraki_response then |
| 217 |
.meraki_response | |
| 218 |
if .powerExceptions and (.powerExceptions | length > 0) then |
| 219 |
. as $parent | |
| 220 |
[ |
| 221 |
$parent.powerExceptions[] | |
| 222 |
{ |
| 223 |
name: .serial, |
| 224 |
canonical_facts: { |
| 225 |
ansible_product_serial: .serial |
| 226 |
}, |
| 227 |
facts: { |
| 228 |
device_type: "switch", |
| 229 |
power_exception: { |
| 230 |
power_type: .powerType |
| 231 |
}, |
| 232 |
network_settings: { |
| 233 |
vlan: $parent.vlan, |
| 234 |
use_combined_power: $parent.useCombinedPower, |
| 235 |
} |
| 236 |
} |
| 237 |
} |
| 238 |
] |
| 239 |
else |
| 240 |
[] |
| 241 |
end |
| 242 |
else [] |
| 243 |
end |
| 244 |
|
| 245 |
# updateNetworkSwitchAccessPolicy |
| 246 |
cisco.meraki.networks_switch_access_policies: |
| 247 |
query: >- |
| 248 |
if .meraki_response then |
| 249 |
(.meraki_response | if type == "array" then . else [.] end) | |
| 250 |
map({ |
| 251 |
name: .name, |
| 252 |
canonical_facts: { |
| 253 |
ansible_machine_id: (.accessPolicyNumber | tostring) |
| 254 |
}, |
| 255 |
facts: { |
| 256 |
device_type: "switch", |
| 257 |
access_policy_number: .accessPolicyNumber, |
| 258 |
access_policy_type: .accessPolicyType, |
| 259 |
} |
| 260 |
}) |
| 261 |
else [] |
| 262 |
end |
| 263 |
|
| 264 |
# createNetworkSwitchStackRoutingInterface |
| 265 |
cisco.meraki.networks_switch_stacks_routing_interfaces: |
| 266 |
query: >- |
| 267 |
if .meraki_response then |
| 268 |
(.meraki_response | if type == "array" then . else [.] end) | |
| 269 |
map({ |
| 270 |
name: .name, |
| 271 |
canonical_facts: { |
| 272 |
ansible_product_serial: .serial, |
| 273 |
hostname: .interfaceIp |
| 274 |
}, |
| 275 |
facts: { |
| 276 |
device_type: "switch", |
| 277 |
interface_id: .interfaceId, |
| 278 |
vlan_id: .vlanId, |
| 279 |
interface_ip: .interfaceIp, |
| 280 |
} |
| 281 |
}) |
| 282 |
else [] |
| 283 |
end |
| 284 |
|
| 285 |
# getNetworkSwitchStp |
| 286 |
cisco.meraki.networks_switch_stp_info: |
| 287 |
query: >- |
| 288 |
if .meraki_response then |
| 289 |
.meraki_response | |
| 290 |
if .stpBridgePriority and (.stpBridgePriority | length > 0) then |
| 291 |
. as $parent | |
| 292 |
[ |
| 293 |
$parent.stpBridgePriority[] | |
| 294 |
. as $priority_config | |
| 295 |
( |
| 296 |
# Create entries for each switch serial |
| 297 |
($priority_config.switches // [])[] | |
| 298 |
{ |
| 299 |
name: (. | tostring), |
| 300 |
canonical_facts: { |
| 301 |
ansible_product_serial: (. | tostring) |
| 302 |
}, |
| 303 |
facts: { |
| 304 |
device_type: "switch", |
| 305 |
stp_priority: $priority_config.stpPriority, |
| 306 |
rstp_enabled: $parent.rstpEnabled |
| 307 |
} |
| 308 |
} |
| 309 |
) |
| 310 |
] | flatten |
| 311 |
else |
| 312 |
[] |
| 313 |
end |
| 314 |
else [] |
| 315 |
end |
| 316 |
|
| 317 |
# createNetworkSwitchQosRule / updateNetworkSwitchQosRule / deleteNetworkSwitchQosRule |
| 318 |
cisco.meraki.networks_switch_qos_rules_order: |
| 319 |
query: >- |
| 320 |
if .meraki_response then |
| 321 |
(.meraki_response | if type == "array" then . else [.] end) | |
| 322 |
map({ |
| 323 |
name: ("qos-rule-" + (.id | tostring)), |
| 324 |
canonical_facts: { |
| 325 |
ansible_machine_id: (.id | tostring) |
| 326 |
}, |
| 327 |
facts: { |
| 328 |
device_type: "switch", |
| 329 |
qos_rule: { |
| 330 |
id: (.id | tostring), |
| 331 |
vlan: .vlan, |
| 332 |
protocol: .protocol, |
| 333 |
src_port: .srcPort, |
| 334 |
src_port_range: .srcPortRange, |
| 335 |
dst_port: .dstPort, |
| 336 |
dst_port_range: .dstPortRange, |
| 337 |
dscp: .dscp |
| 338 |
} |
| 339 |
} |
| 340 |
}) |
| 341 |
else [] |
| 342 |
end |
| 343 |
|
| 344 |
# cycleDeviceSwitchPorts |
| 345 |
cisco.meraki.devices_switch_ports_cycle: |
| 346 |
query: >- |
| 347 |
if .meraki_response then |
| 348 |
(.meraki_response.ports // []) | |
| 349 |
map({ |
| 350 |
name: ("port-" + .), |
| 351 |
canonical_facts: { |
| 352 |
ansible_machine_id: . |
| 353 |
}, |
| 354 |
facts: { |
| 355 |
device_type: "switch", |
| 356 |
port_identifier: . |
| 357 |
} |
| 358 |
}) |
| 359 |
else [] |
| 360 |
end |
| 361 |
|
| 362 |
# getNetworkSwitchAccessControlLists - not good |
| 363 |
cisco.meraki.networks_switch_access_control_lists_info: |
| 364 |
query: >- |
| 365 |
if .meraki_response then |
| 366 |
(.meraki_response.rules // []) | |
| 367 |
to_entries | |
| 368 |
map({ |
| 369 |
name: (.value.comment // ("acl-rule-" + (.key | tostring))), |
| 370 |
canonical_facts: { |
| 371 |
ansible_machine_id: ( |
| 372 |
(.value.dstCidr // "") + "-" + |
| 373 |
(.key | tostring) |
| 374 |
) |
| 375 |
}, |
| 376 |
facts: { |
| 377 |
device_type: "switch", |
| 378 |
acl_rule: { |
| 379 |
comment: .value.comment, |
| 380 |
policy: .value.policy, |
| 381 |
ip_version: .value.ipVersion, |
| 382 |
protocol: .value.protocol, |
| 383 |
src_cidr: .value.srcCidr, |
| 384 |
src_port: .value.srcPort, |
| 385 |
dst_cidr: .value.dstCidr, |
| 386 |
dst_port: .value.dstPort, |
| 387 |
vlan: .value.vlan, |
| 388 |
rule_index: .key |
| 389 |
} |
| 390 |
} |
| 391 |
}) |
| 392 |
else [] |
| 393 |
end |
| 394 |
|
| 395 |
# createNetworkSwitchStack / deleteNetworkSwitchStack |
| 396 |
cisco.meraki.networks_switch_stacks: |
| 397 |
query: >- |
| 398 |
if .meraki_response then |
| 399 |
.meraki_response | |
| 400 |
. as $parent | |
| 401 |
[ |
| 402 |
# Create entries for each switch serial in the stack |
| 403 |
($parent.serials // [])[] | |
| 404 |
{ |
| 405 |
name: ., |
| 406 |
canonical_facts: { |
| 407 |
ansible_product_serial: . |
| 408 |
}, |
| 409 |
facts: { |
| 410 |
device_type: "switch", |
| 411 |
stack_id: ($parent.id | tostring), |
| 412 |
stack_name: $parent.name, |
| 413 |
workflow_id: ($parent.workflowId | tostring) |
| 414 |
} |
| 415 |
} |
| 416 |
] |
| 417 |
else [] |
| 418 |
end |
| 419 |
|
| 420 |
# updateNetworkSwitchSettings |
| 421 |
cisco.meraki.networks_switch_settings: |
| 422 |
query: >- |
| 423 |
if .meraki_response then |
| 424 |
.meraki_response | |
| 425 |
. as $parent | |
| 426 |
[ |
| 427 |
# Create entries for each switch with power exceptions |
| 428 |
($parent.powerExceptions // [])[] | |
| 429 |
{ |
| 430 |
name: .serial, |
| 431 |
canonical_facts: { |
| 432 |
ansible_product_serial: .serial |
| 433 |
}, |
| 434 |
facts: { |
| 435 |
device_type: "switch", |
| 436 |
power_exception: { |
| 437 |
power_type: .powerType |
| 438 |
}, |
| 439 |
network_settings: { |
| 440 |
vlan: $parent.vlan, |
| 441 |
use_combined_power: $parent.useCombinedPower, |
| 442 |
} |
| 443 |
} |
| 444 |
} |
| 445 |
] |
| 446 |
else [] |
| 447 |
end |
| 448 |
|
| 449 |
# getNetworkSwitchStackRoutingInterfaceDhcp |
| 450 |
cisco.meraki.networks_switch_stacks_routing_interfaces_dhcp_info: |
| 451 |
query: >- |
| 452 |
if .meraki_response then |
| 453 |
.meraki_response | |
| 454 |
. as $parent | |
| 455 |
[ |
| 456 |
# Create entries for each device with fixed IP assignment |
| 457 |
($parent.fixedIpAssignments // [])[] | |
| 458 |
{ |
| 459 |
name: (.name // .mac), |
| 460 |
canonical_facts: { |
| 461 |
hostname: .ip, |
| 462 |
ansible_machine_id: .mac |
| 463 |
}, |
| 464 |
facts: { |
| 465 |
device_type: "switch", |
| 466 |
fixed_ip_assignment: { |
| 467 |
mac: .mac, |
| 468 |
ip: .ip, |
| 469 |
name: .name |
| 470 |
}, |
| 471 |
} |
| 472 |
} |
| 473 |
] |
| 474 |
else [] |
| 475 |
end |
| 476 |
|
| 477 |
# updateNetworkSwitchStackRoutingInterfaceDhcp |
| 478 |
cisco.meraki.networks_switch_stacks_routing_interfaces_dhcp: |
| 479 |
query: >- |
| 480 |
if .meraki_response then |
| 481 |
.meraki_response | |
| 482 |
. as $parent | |
| 483 |
[ |
| 484 |
# Create entries for each device with fixed IP assignment |
| 485 |
($parent.fixedIpAssignments // [])[] | |
| 486 |
{ |
| 487 |
name: (.name // .mac), |
| 488 |
canonical_facts: { |
| 489 |
hostname: .ip, |
| 490 |
ansible_machine_id: .mac |
| 491 |
}, |
| 492 |
facts: { |
| 493 |
device_type: "switch", |
| 494 |
fixed_ip_assignment: { |
| 495 |
mac: .mac, |
| 496 |
ip: .ip, |
| 497 |
name: .name |
| 498 |
}, |
| 499 |
dhcp_config: { |
| 500 |
dhcp_mode: $parent.dhcpMode, |
| 501 |
dhcp_lease_time: $parent.dhcpLeaseTime, |
| 502 |
dns_nameservers_option: $parent.dnsNameserversOption, |
| 503 |
boot_options_enabled: $parent.bootOptionsEnabled |
| 504 |
} |
| 505 |
} |
| 506 |
} |
| 507 |
] |
| 508 |
else [] |
| 509 |
end |
| 510 |
|
| 511 |
# getNetworkSwitchDhcpServerPolicy |
| 512 |
cisco.meraki.networks_switch_dhcp_server_policy_info: |
| 513 |
query: >- |
| 514 |
if .meraki_response then |
| 515 |
.meraki_response | |
| 516 |
. as $parent | |
| 517 |
[ |
| 518 |
( |
| 519 |
# Create entries for each blocked DHCP server |
| 520 |
($parent.blockedServers // [])[] | |
| 521 |
{ |
| 522 |
name: ("blocked-dhcp-server-" + .), |
| 523 |
canonical_facts: { |
| 524 |
ansible_machine_id: . |
| 525 |
}, |
| 526 |
facts: { |
| 527 |
device_type: "switch", |
| 528 |
dhcp_server_policy: { |
| 529 |
status: "blocked", |
| 530 |
mac_address: ., |
| 531 |
default_policy: $parent.defaultPolicy, |
| 532 |
arp_inspection_enabled: ($parent.arpInspection.enabled // false) |
| 533 |
} |
| 534 |
} |
| 535 |
} |
| 536 |
), |
| 537 |
( |
| 538 |
# Create entries for each allowed DHCP server |
| 539 |
($parent.allowedServers // [])[] | |
| 540 |
{ |
| 541 |
name: ("allowed-dhcp-server-" + .), |
| 542 |
canonical_facts: { |
| 543 |
ansible_machine_id: . |
| 544 |
}, |
| 545 |
facts: { |
| 546 |
device_type: "switch", |
| 547 |
dhcp_server_policy: { |
| 548 |
status: "allowed", |
| 549 |
mac_address: ., |
| 550 |
default_policy: $parent.defaultPolicy, |
| 551 |
arp_inspection_enabled: ($parent.arpInspection.enabled // false) |
| 552 |
} |
| 553 |
} |
| 554 |
} |
| 555 |
) |
| 556 |
] |
| 557 |
else [] |
| 558 |
end |
| 559 |
|
| 560 |
# updateNetworkSwitchStp |
| 561 |
cisco.meraki.networks_switch_stp: |
| 562 |
query: >- |
| 563 |
if .meraki_response then |
| 564 |
.meraki_response | |
| 565 |
if .stpBridgePriority and (.stpBridgePriority | length > 0) then |
| 566 |
. as $parent | |
| 567 |
[ |
| 568 |
$parent.stpBridgePriority[] | |
| 569 |
. as $priority_config | |
| 570 |
( |
| 571 |
# Create entries for each switch serial |
| 572 |
($priority_config.switches // [])[] | |
| 573 |
{ |
| 574 |
name: (. | tostring), |
| 575 |
canonical_facts: { |
| 576 |
ansible_product_serial: (. | tostring) |
| 577 |
}, |
| 578 |
facts: { |
| 579 |
device_type: "switch", |
| 580 |
stp_priority: $priority_config.stpPriority, |
| 581 |
rstp_enabled: $parent.rstpEnabled |
| 582 |
} |
| 583 |
} |
| 584 |
) |
| 585 |
] | flatten |
| 586 |
else |
| 587 |
[] |
| 588 |
end |
| 589 |
else [] |
| 590 |
end |
| 591 |
|
| 592 |
# createNetworkSwitchLinkAggregation / updateNetworkSwitchLinkAggregation / deleteNetworkSwitchLinkAggregation |
| 593 |
cisco.meraki.networks_switch_link_aggregations: |
| 594 |
query: >- |
| 595 |
if .meraki_response then |
| 596 |
.meraki_response | |
| 597 |
. as $parent | |
| 598 |
[ |
| 599 |
# Create entries for each port in the link aggregation |
| 600 |
($parent.switchPorts // [])[] | |
| 601 |
{ |
| 602 |
name: (.serial + "-port-" + (.portId | tostring)), |
| 603 |
canonical_facts: { |
| 604 |
ansible_product_serial: .serial |
| 605 |
}, |
| 606 |
facts: { |
| 607 |
device_type: "switch", |
| 608 |
link_aggregation: { |
| 609 |
aggregation_id: ($parent.id | tostring), |
| 610 |
port_id: (.portId | tostring), |
| 611 |
serial: .serial |
| 612 |
} |
| 613 |
} |
| 614 |
} |
| 615 |
] |
| 616 |
else [] |
| 617 |
end |
| 618 |
|
| 619 |
# getDeviceSwitchRoutingInterfaces / getDeviceSwitchRoutingInterface |
| 620 |
cisco.meraki.devices_switch_routing_interfaces_info: |
| 621 |
query: >- |
| 622 |
if .meraki_response then |
| 623 |
(.meraki_response | if type == "array" then . else [.] end) | |
| 624 |
map({ |
| 625 |
name: (.name // ("interface-" + (.interfaceId | tostring))), |
| 626 |
canonical_facts: { |
| 627 |
ansible_product_serial: .serial, |
| 628 |
hostname: (.interfaceIp // "") |
| 629 |
}, |
| 630 |
facts: { |
| 631 |
device_type: "switch", |
| 632 |
interface_id: (.interfaceId | tostring), |
| 633 |
vlan_id: .vlanId, |
| 634 |
interface_ip: .interfaceIp, |
| 635 |
vrf: ( |
| 636 |
if .vrf then |
| 637 |
{ |
| 638 |
name: .vrf.name |
| 639 |
} |
| 640 |
else |
| 641 |
{} |
| 642 |
end |
| 643 |
) |
| 644 |
} |
| 645 |
}) |
| 646 |
else [] |
| 647 |
end |
| 648 |
|
| 649 |
# createDeviceSwitchRoutingInterface / updateDeviceSwitchRoutingInterface / deleteDeviceSwitchRoutingInterface |
| 650 |
cisco.meraki.devices_switch_routing_interfaces: |
| 651 |
query: >- |
| 652 |
if .meraki_response then |
| 653 |
[.meraki_response] | |
| 654 |
map({ |
| 655 |
name: (.name // ("interface-" + (.interfaceId | tostring))), |
| 656 |
canonical_facts: { |
| 657 |
ansible_product_serial: .serial, |
| 658 |
hostname: (.interfaceIp // "") |
| 659 |
}, |
| 660 |
facts: { |
| 661 |
device_type: "switch", |
| 662 |
interface_id: (.interfaceId | tostring), |
| 663 |
vlan_id: .vlanId, |
| 664 |
interface_ip: .interfaceIp, |
| 665 |
vrf: ( |
| 666 |
if .vrf then |
| 667 |
{ |
| 668 |
name: .vrf.name |
| 669 |
} |
| 670 |
else |
| 671 |
{} |
| 672 |
end |
| 673 |
) |
| 674 |
} |
| 675 |
}) |
| 676 |
else [] |
| 677 |
end |
| 678 |
|
| 679 |
# updateNetworkSwitchAccessControlLists - no good |
| 680 |
cisco.meraki.networks_switch_access_control_lists: |
| 681 |
query: >- |
| 682 |
if .meraki_response then |
| 683 |
(.meraki_response.rules // []) | |
| 684 |
to_entries | |
| 685 |
map({ |
| 686 |
name: (.value.comment // ("acl-rule-" + (.key | tostring))), |
| 687 |
canonical_facts: { |
| 688 |
ansible_machine_id: ( |
| 689 |
(.value.srcCidr // "") + "-" + |
| 690 |
(.value.dstCidr // "") + "-" + |
| 691 |
(.key | tostring) |
| 692 |
) |
| 693 |
}, |
| 694 |
facts: { |
| 695 |
device_type: "switch", |
| 696 |
acl_rule: { |
| 697 |
comment: .value.comment, |
| 698 |
policy: .value.policy, |
| 699 |
ip_version: .value.ipVersion, |
| 700 |
protocol: .value.protocol, |
| 701 |
src_cidr: .value.srcCidr, |
| 702 |
src_port: .value.srcPort, |
| 703 |
dst_cidr: .value.dstCidr, |
| 704 |
dst_port: .value.dstPort, |
| 705 |
vlan: .value.vlan, |
| 706 |
rule_index: .key |
| 707 |
} |
| 708 |
} |
| 709 |
}) |
| 710 |
else [] |
| 711 |
end |
| 712 |
|
| 713 |
# getNetworkSwitchRoutingMulticast |
| 714 |
cisco.meraki.networks_switch_routing_multicast_info: |
| 715 |
query: >- |
| 716 |
if .meraki_response then |
| 717 |
.meraki_response | |
| 718 |
if .overrides and (.overrides | length > 0) then |
| 719 |
. as $parent | |
| 720 |
[ |
| 721 |
$parent.overrides[] | |
| 722 |
. as $override | |
| 723 |
( |
| 724 |
# Create entries for each switch serial |
| 725 |
($override.switches // [])[] | |
| 726 |
{ |
| 727 |
name: (. | tostring), |
| 728 |
canonical_facts: { |
| 729 |
ansible_product_serial: (. | tostring) |
| 730 |
}, |
| 731 |
facts: { |
| 732 |
device_type: "switch", |
| 733 |
multicast_settings: { |
| 734 |
igmp_snooping_enabled: $override.igmpSnoopingEnabled, |
| 735 |
flood_unknown_multicast_traffic_enabled: $override.floodUnknownMulticastTrafficEnabled |
| 736 |
}, |
| 737 |
default_settings: { |
| 738 |
igmp_snooping_enabled: ($parent.defaultSettings.igmpSnoopingEnabled // false), |
| 739 |
flood_unknown_multicast_traffic_enabled: ($parent.defaultSettings.floodUnknownMulticastTrafficEnabled // false) |
| 740 |
} |
| 741 |
} |
| 742 |
} |
| 743 |
) |
| 744 |
] | flatten |
| 745 |
else |
| 746 |
[] |
| 747 |
end |
| 748 |
else [] |
| 749 |
end |
| 750 |
|
| 751 |
# getNetworkSwitchRoutingOspf - not good |
| 752 |
cisco.meraki.networks_switch_routing_ospf_info: |
| 753 |
query: >- |
| 754 |
if .meraki_response then |
| 755 |
.meraki_response | |
| 756 |
. as $parent | |
| 757 |
[ |
| 758 |
( |
| 759 |
# Create entries for each OSPFv2 area |
| 760 |
($parent.areas // [])[] | |
| 761 |
{ |
| 762 |
name: (.areaName // ("ospf-area-" + (.areaId | tostring))), |
| 763 |
canonical_facts: { |
| 764 |
ansible_machine_id: (.areaId | tostring) |
| 765 |
}, |
| 766 |
facts: { |
| 767 |
device_type: "switch", |
| 768 |
ospf_version: "v2", |
| 769 |
ospf_area: { |
| 770 |
area_id: (.areaId | tostring), |
| 771 |
area_name: .areaName, |
| 772 |
area_type: .areaType |
| 773 |
}, |
| 774 |
ospf_config: { |
| 775 |
enabled: $parent.enabled, |
| 776 |
hello_timer: $parent.helloTimerInSeconds, |
| 777 |
dead_timer: $parent.deadTimerInSeconds, |
| 778 |
md5_authentication_enabled: ($parent.md5AuthenticationEnabled // false) |
| 779 |
}, |
| 780 |
vrf: ( |
| 781 |
if $parent.vrf then |
| 782 |
{ |
| 783 |
name: $parent.vrf.name |
| 784 |
} |
| 785 |
else |
| 786 |
{} |
| 787 |
end |
| 788 |
) |
| 789 |
} |
| 790 |
} |
| 791 |
), |
| 792 |
( |
| 793 |
# Create entries for each OSPFv3 area |
| 794 |
(($parent.v3 // {}).areas // [])[] | |
| 795 |
{ |
| 796 |
name: (.areaName // ("ospfv3-area-" + (.areaId | tostring))), |
| 797 |
canonical_facts: { |
| 798 |
ansible_machine_id: ("v3-" + (.areaId | tostring)) |
| 799 |
}, |
| 800 |
facts: { |
| 801 |
device_type: "switch", |
| 802 |
ospf_version: "v3", |
| 803 |
ospf_area: { |
| 804 |
area_id: (.areaId | tostring), |
| 805 |
area_name: .areaName, |
| 806 |
area_type: .areaType |
| 807 |
}, |
| 808 |
ospf_config: { |
| 809 |
enabled: ($parent.v3.enabled // false), |
| 810 |
hello_timer: ($parent.v3.helloTimerInSeconds // 0), |
| 811 |
dead_timer: ($parent.v3.deadTimerInSeconds // 0) |
| 812 |
}, |
| 813 |
vrf: ( |
| 814 |
if $parent.vrf then |
| 815 |
{ |
| 816 |
name: $parent.vrf.name |
| 817 |
} |
| 818 |
else |
| 819 |
{} |
| 820 |
end |
| 821 |
) |
| 822 |
} |
| 823 |
} |
| 824 |
) |
| 825 |
] |
| 826 |
else [] |
| 827 |
end |
| 828 |
|
| 829 |
# getNetworkSwitchAlternateManagementInterface |
| 830 |
cisco.meraki.networks_switch_alternate_management_interface_info: |
| 831 |
query: >- |
| 832 |
if .meraki_response then |
| 833 |
.meraki_response | |
| 834 |
. as $parent | |
| 835 |
[ |
| 836 |
# Create entries for each switch with alternate management interface |
| 837 |
($parent.switches // [])[] | |
| 838 |
{ |
| 839 |
name: .serial, |
| 840 |
canonical_facts: { |
| 841 |
ansible_product_serial: .serial, |
| 842 |
hostname: (.alternateManagementIp // "") |
| 843 |
}, |
| 844 |
facts: { |
| 845 |
device_type: "switch", |
| 846 |
alternate_management_interface: { |
| 847 |
enabled: $parent.enabled, |
| 848 |
vlan_id: $parent.vlanId, |
| 849 |
protocols: ($parent.protocols // []), |
| 850 |
alternate_management_ip: .alternateManagementIp, |
| 851 |
subnet_mask: .subnetMask, |
| 852 |
gateway: .gateway |
| 853 |
} |
| 854 |
} |
| 855 |
} |
| 856 |
] |
| 857 |
else [] |
| 858 |
end |
| 859 |
|
| 860 |
# getOrganizationConfigTemplateSwitchProfiles |
| 861 |
cisco.meraki.organizations_config_templates_switch_profiles_info: |
| 862 |
query: >- |
| 863 |
if .meraki_response then |
| 864 |
(.meraki_response | if type == "array" then . else [.] end) | |
| 865 |
map({ |
| 866 |
name: (.name // ("switch-profile-" + (.switchProfileId | tostring))), |
| 867 |
canonical_facts: { |
| 868 |
ansible_machine_id: (.switchProfileId | tostring) |
| 869 |
}, |
| 870 |
facts: { |
| 871 |
device_type: "switch", |
| 872 |
switch_profile: { |
| 873 |
profile_id: (.switchProfileId | tostring), |
| 874 |
name: .name, |
| 875 |
model: .model |
| 876 |
} |
| 877 |
} |
| 878 |
}) |
| 879 |
else [] |
| 880 |
end |
| 881 |
|
| 882 |
# updateNetworkSwitchRoutingOspf - not good |
| 883 |
cisco.meraki.networks_switch_routing_ospf: |
| 884 |
query: >- |
| 885 |
if .meraki_response then |
| 886 |
.meraki_response | |
| 887 |
. as $parent | |
| 888 |
[ |
| 889 |
( |
| 890 |
# Create entries for each OSPFv2 area |
| 891 |
($parent.areas // [])[] | |
| 892 |
{ |
| 893 |
name: (.areaName // ("ospf-area-" + (.areaId | tostring))), |
| 894 |
canonical_facts: { |
| 895 |
ansible_machine_id: (.areaId | tostring) |
| 896 |
}, |
| 897 |
facts: { |
| 898 |
device_type: "switch", |
| 899 |
ospf_version: "v2", |
| 900 |
ospf_area: { |
| 901 |
area_id: (.areaId | tostring), |
| 902 |
area_name: .areaName, |
| 903 |
area_type: .areaType |
| 904 |
}, |
| 905 |
ospf_config: { |
| 906 |
enabled: $parent.enabled, |
| 907 |
hello_timer: $parent.helloTimerInSeconds, |
| 908 |
dead_timer: $parent.deadTimerInSeconds, |
| 909 |
md5_authentication_enabled: ($parent.md5AuthenticationEnabled // false) |
| 910 |
}, |
| 911 |
vrf: ( |
| 912 |
if $parent.vrf then |
| 913 |
{ |
| 914 |
name: $parent.vrf.name |
| 915 |
} |
| 916 |
else |
| 917 |
{} |
| 918 |
end |
| 919 |
) |
| 920 |
} |
| 921 |
} |
| 922 |
), |
| 923 |
( |
| 924 |
# Create entries for each OSPFv3 area |
| 925 |
(($parent.v3 // {}).areas // [])[] | |
| 926 |
{ |
| 927 |
name: (.areaName // ("ospfv3-area-" + (.areaId | tostring))), |
| 928 |
canonical_facts: { |
| 929 |
ansible_machine_id: ("v3-" + (.areaId | tostring)) |
| 930 |
}, |
| 931 |
facts: { |
| 932 |
device_type: "switch", |
| 933 |
ospf_version: "v3", |
| 934 |
ospf_area: { |
| 935 |
area_id: (.areaId | tostring), |
| 936 |
area_name: .areaName, |
| 937 |
area_type: .areaType |
| 938 |
}, |
| 939 |
ospf_config: { |
| 940 |
enabled: ($parent.v3.enabled // false), |
| 941 |
hello_timer: ($parent.v3.helloTimerInSeconds // 0), |
| 942 |
dead_timer: ($parent.v3.deadTimerInSeconds // 0) |
| 943 |
}, |
| 944 |
vrf: ( |
| 945 |
if $parent.vrf then |
| 946 |
{ |
| 947 |
name: $parent.vrf.name |
| 948 |
} |
| 949 |
else |
| 950 |
{} |
| 951 |
end |
| 952 |
) |
| 953 |
} |
| 954 |
} |
| 955 |
) |
| 956 |
] |
| 957 |
else [] |
| 958 |
end |
| 959 |
|
| 960 |
# getNetworkSwitchDhcpServerPolicyArpInspectionTrustedServers |
| 961 |
cisco.meraki.networks_switch_dhcp_server_policy_arp_inspection_trusted_servers_info: |
| 962 |
query: >- |
| 963 |
if .meraki_response then |
| 964 |
(.meraki_response | if type == "array" then . else [.] end) | |
| 965 |
map({ |
| 966 |
name: ("trusted-server-" + (.trustedServerId | tostring)), |
| 967 |
canonical_facts: { |
| 968 |
ansible_machine_id: .mac, |
| 969 |
hostname: (.ipv4.address // "") |
| 970 |
}, |
| 971 |
facts: { |
| 972 |
device_type: "switch", |
| 973 |
trusted_server: { |
| 974 |
trusted_server_id: (.trustedServerId | tostring), |
| 975 |
mac_address: .mac, |
| 976 |
vlan: .vlan, |
| 977 |
ipv4_address: (.ipv4.address // "") |
| 978 |
} |
| 979 |
} |
| 980 |
}) |
| 981 |
else [] |
| 982 |
end |
| 983 |
|
| 984 |
# getNetworkSwitchDhcpServerPolicyArpInspectionWarningsByDevice |
| 985 |
cisco.meraki.networks_switch_dhcp_server_policy_arp_inspection_warnings_by_device_info: |
| 986 |
query: >- |
| 987 |
if .meraki_response then |
| 988 |
(.meraki_response | if type == "array" then . else [.] end) | |
| 989 |
map({ |
| 990 |
name: (.name // .serial), |
| 991 |
canonical_facts: { |
| 992 |
ansible_product_serial: .serial |
| 993 |
}, |
| 994 |
facts: { |
| 995 |
device_type: "switch", |
| 996 |
arp_inspection_warning: { |
| 997 |
supports_inspection: .supportsInspection, |
| 998 |
has_trusted_port: .hasTrustedPort, |
| 999 |
url: .url |
| 1000 |
} |
| 1001 |
} |
| 1002 |
}) |
| 1003 |
else [] |
| 1004 |
end |
| 1005 |
|
| 1006 |
# getNetworkSwitchDhcpV4ServersSeen |
| 1007 |
cisco.meraki.networks_switch_dhcp_v4_servers_seen_info: |
| 1008 |
query: >- |
| 1009 |
if .meraki_response then |
| 1010 |
(.meraki_response | if type == "array" then . else [.] end) | |
| 1011 |
[ |
| 1012 |
.[] | |
| 1013 |
. as $dhcp_server | |
| 1014 |
( |
| 1015 |
# Create entry for the device serial (if device exists) |
| 1016 |
if $dhcp_server.device and $dhcp_server.device.serial then |
| 1017 |
{ |
| 1018 |
name: $dhcp_server.device.serial, |
| 1019 |
canonical_facts: { |
| 1020 |
ansible_product_serial: $dhcp_server.device.serial |
| 1021 |
}, |
| 1022 |
facts: { |
| 1023 |
device_type: "switch", |
| 1024 |
dhcp_server_seen: { |
| 1025 |
mac_address: $dhcp_server.mac, |
| 1026 |
vlan: $dhcp_server.vlan, |
| 1027 |
ipv4: { |
| 1028 |
address: ($dhcp_server.ipv4.address // ""), |
| 1029 |
subnet: ($dhcp_server.ipv4.subnet // ""), |
| 1030 |
gateway: ($dhcp_server.ipv4.gateway // "") |
| 1031 |
}, |
| 1032 |
device_name: ($dhcp_server.device.name // ""), |
| 1033 |
} |
| 1034 |
} |
| 1035 |
} |
| 1036 |
else |
| 1037 |
empty |
| 1038 |
end |
| 1039 |
), |
| 1040 |
( |
| 1041 |
# Create entries for each switch serial in seenBy |
| 1042 |
($dhcp_server.seenBy // [])[] | |
| 1043 |
{ |
| 1044 |
name: .serial, |
| 1045 |
canonical_facts: { |
| 1046 |
ansible_product_serial: .serial |
| 1047 |
}, |
| 1048 |
facts: { |
| 1049 |
device_type: "switch", |
| 1050 |
dhcp_server_seen: { |
| 1051 |
mac_address: $dhcp_server.mac, |
| 1052 |
vlan: $dhcp_server.vlan, |
| 1053 |
client_id: $dhcp_server.clientId, |
| 1054 |
type: $dhcp_server.type, |
| 1055 |
ipv4: { |
| 1056 |
address: ($dhcp_server.ipv4.address // ""), |
| 1057 |
subnet: ($dhcp_server.ipv4.subnet // ""), |
| 1058 |
gateway: ($dhcp_server.ipv4.gateway // "") |
| 1059 |
}, |
| 1060 |
} |
| 1061 |
} |
| 1062 |
} |
| 1063 |
) |
| 1064 |
] | flatten |
| 1065 |
else [] |
| 1066 |
end |
| 1067 |
|
| 1068 |
# getNetworkSwitchLinkAggregations |
| 1069 |
cisco.meraki.networks_switch_link_aggregations_info: |
| 1070 |
query: >- |
| 1071 |
if .meraki_response then |
| 1072 |
(.meraki_response | if type == "array" then . else [.] end) | |
| 1073 |
[ |
| 1074 |
.[] | |
| 1075 |
. as $aggregation | |
| 1076 |
($aggregation.switchPorts // [])[] | |
| 1077 |
{ |
| 1078 |
name: (.serial + "-port-" + (.portId | tostring)), |
| 1079 |
canonical_facts: { |
| 1080 |
ansible_product_serial: .serial |
| 1081 |
}, |
| 1082 |
facts: { |
| 1083 |
device_type: "switch", |
| 1084 |
link_aggregation: { |
| 1085 |
aggregation_id: ($aggregation.id | tostring), |
| 1086 |
port_id: (.portId | tostring), |
| 1087 |
serial: .serial |
| 1088 |
} |
| 1089 |
} |
| 1090 |
} |
| 1091 |
] |
| 1092 |
else [] |
| 1093 |
end |
| 1094 |
|
| 1095 |
# getNetworkSwitchQosRules / getNetworkSwitchQosRule |
| 1096 |
cisco.meraki.networks_switch_qos_rules_order_info: |
| 1097 |
query: >- |
| 1098 |
if .meraki_response then |
| 1099 |
(.meraki_response | if type == "array" then . else [.] end) | |
| 1100 |
map({ |
| 1101 |
name: ("qos-rule-" + (.id | tostring)), |
| 1102 |
canonical_facts: { |
| 1103 |
ansible_machine_id: (.id | tostring) |
| 1104 |
}, |
| 1105 |
facts: { |
| 1106 |
device_type: "switch", |
| 1107 |
qos_rule: { |
| 1108 |
id: (.id | tostring), |
| 1109 |
vlan: .vlan, |
| 1110 |
protocol: .protocol, |
| 1111 |
src_port: .srcPort, |
| 1112 |
src_port_range: .srcPortRange, |
| 1113 |
dst_port: .dstPort, |
| 1114 |
dst_port_range: .dstPortRange, |
| 1115 |
dscp: .dscp |
| 1116 |
} |
| 1117 |
} |
| 1118 |
}) |
| 1119 |
else [] |
| 1120 |
end |
| 1121 |
|
| 1122 |
# getNetworkSwitchRoutingMulticastRendezvousPoints / getNetworkSwitchRoutingMulticastRendezvousPoint |
| 1123 |
cisco.meraki.networks_switch_routing_multicast_rendezvous_points_info: |
| 1124 |
query: >- |
| 1125 |
if .meraki_response then |
| 1126 |
(.meraki_response | if type == "array" then . else [.] end) | |
| 1127 |
map({ |
| 1128 |
name: ("rendezvous-point-" + (.rendezvousPointId | tostring)), |
| 1129 |
canonical_facts: { |
| 1130 |
ansible_product_serial: .serial, |
| 1131 |
hostname: (.interfaceIp // "") |
| 1132 |
}, |
| 1133 |
facts: { |
| 1134 |
device_type: "switch", |
| 1135 |
multicast_rendezvous_point: { |
| 1136 |
rendezvous_point_id: (.rendezvousPointId | tostring), |
| 1137 |
serial: .serial, |
| 1138 |
interface_name: .interfaceName, |
| 1139 |
interface_ip: .interfaceIp, |
| 1140 |
multicast_group: .multicastGroup |
| 1141 |
} |
| 1142 |
} |
| 1143 |
}) |
| 1144 |
else [] |
| 1145 |
end |
| 1146 |
|
| 1147 |
# getDeviceSwitchRoutingStaticRoutes / getDeviceSwitchRoutingStaticRoute - not good |
| 1148 |
cisco.meraki.devices_switch_routing_static_routes_info: |
| 1149 |
query: >- |
| 1150 |
if .meraki_response then |
| 1151 |
(.meraki_response | if type == "array" then . else [.] end) | |
| 1152 |
map({ |
| 1153 |
name: (.name // ("static-route-" + (.staticRouteId | tostring))), |
| 1154 |
canonical_facts: { |
| 1155 |
ansible_machine_id: (.staticRouteId | tostring) |
| 1156 |
}, |
| 1157 |
facts: { |
| 1158 |
device_type: "switch", |
| 1159 |
static_route: { |
| 1160 |
route_id: (.staticRouteId | tostring), |
| 1161 |
name: .name, |
| 1162 |
subnet: .subnet, |
| 1163 |
next_hop_ip: .nextHopIp, |
| 1164 |
management_next_hop: .managementNextHop, |
| 1165 |
advertise_via_ospf_enabled: .advertiseViaOspfEnabled, |
| 1166 |
prefer_over_ospf_routes_enabled: .preferOverOspfRoutesEnabled, |
| 1167 |
vrf: ( |
| 1168 |
if .vrf then |
| 1169 |
{ |
| 1170 |
name: .vrf.name, |
| 1171 |
leak_route_to_default_vrf: .vrf.leakRouteToDefaultVrf |
| 1172 |
} |
| 1173 |
else |
| 1174 |
{} |
| 1175 |
end |
| 1176 |
) |
| 1177 |
} |
| 1178 |
} |
| 1179 |
}) |
| 1180 |
else [] |
| 1181 |
end |
| 1182 |
|
| 1183 |
# removeNetworkSwitchStack |
| 1184 |
cisco.meraki.networks_switch_stacks_remove: |
| 1185 |
query: >- |
| 1186 |
if .meraki_response then |
| 1187 |
.meraki_response | |
| 1188 |
. as $parent | |
| 1189 |
[ |
| 1190 |
# Create entries for each switch serial in the stack |
| 1191 |
($parent.serials // [])[] | |
| 1192 |
{ |
| 1193 |
name: ., |
| 1194 |
canonical_facts: { |
| 1195 |
ansible_product_serial: . |
| 1196 |
}, |
| 1197 |
facts: { |
| 1198 |
device_type: "switch", |
| 1199 |
stack_id: ($parent.id | tostring), |
| 1200 |
stack_name: $parent.name, |
| 1201 |
is_monitor_only: $parent.isMonitorOnly, |
| 1202 |
virtual_mac: $parent.virtualMac |
| 1203 |
} |
| 1204 |
} |
| 1205 |
] |
| 1206 |
else [] |
| 1207 |
end |
| 1208 |
|
| 1209 |
# getDeviceSwitchWarmSpare |
| 1210 |
cisco.meraki.devices_switch_warm_spare_info: |
| 1211 |
query: >- |
| 1212 |
if .meraki_response then |
| 1213 |
.meraki_response | |
| 1214 |
if .enabled then |
| 1215 |
. as $parent | |
| 1216 |
[ |
| 1217 |
# Create entry for primary switch |
| 1218 |
{ |
| 1219 |
name: $parent.primarySerial, |
| 1220 |
canonical_facts: { |
| 1221 |
ansible_product_serial: $parent.primarySerial |
| 1222 |
}, |
| 1223 |
facts: { |
| 1224 |
device_type: "switch", |
| 1225 |
warm_spare: { |
| 1226 |
enabled: $parent.enabled, |
| 1227 |
role: "primary", |
| 1228 |
spare_serial: $parent.spareSerial |
| 1229 |
} |
| 1230 |
} |
| 1231 |
}, |
| 1232 |
# Create entry for spare switch |
| 1233 |
{ |
| 1234 |
name: $parent.spareSerial, |
| 1235 |
canonical_facts: { |
| 1236 |
ansible_product_serial: $parent.spareSerial |
| 1237 |
}, |
| 1238 |
facts: { |
| 1239 |
device_type: "switch", |
| 1240 |
warm_spare: { |
| 1241 |
enabled: $parent.enabled, |
| 1242 |
role: "spare", |
| 1243 |
primary_serial: $parent.primarySerial |
| 1244 |
} |
| 1245 |
} |
| 1246 |
} |
| 1247 |
] |
| 1248 |
else |
| 1249 |
[] |
| 1250 |
end |
| 1251 |
else [] |
| 1252 |
end |
| 1253 |
|
| 1254 |
# getOrganizationSummaryTopSwitchesByEnergyUsage - not good |
| 1255 |
cisco.meraki.organizations_summary_top_switches_by_energy_usage_info: |
| 1256 |
query: >- |
| 1257 |
if .meraki_response then |
| 1258 |
(.meraki_response | if type == "array" then . else [.] end) | |
| 1259 |
map({ |
| 1260 |
name: (.name // .mac), |
| 1261 |
canonical_facts: { |
| 1262 |
ansible_machine_id: .mac |
| 1263 |
}, |
| 1264 |
facts: { |
| 1265 |
device_type: "switch", |
| 1266 |
switch_info: { |
| 1267 |
name: .name, |
| 1268 |
model: .model, |
| 1269 |
mac_address: .mac |
| 1270 |
}, |
| 1271 |
network: ( |
| 1272 |
if .network then |
| 1273 |
{ |
| 1274 |
id: .network.id, |
| 1275 |
name: .network.name |
| 1276 |
} |
| 1277 |
else |
| 1278 |
{} |
| 1279 |
end |
| 1280 |
), |
| 1281 |
energy_usage: { |
| 1282 |
total: .usage.total |
| 1283 |
} |
| 1284 |
} |
| 1285 |
}) |
| 1286 |
else [] |
| 1287 |
end |
| 1288 |
|
| 1289 |
# addNetworkSwitchStack |
| 1290 |
cisco.meraki.networks_switch_stacks_add: |
| 1291 |
query: >- |
| 1292 |
if .meraki_response then |
| 1293 |
.meraki_response | |
| 1294 |
. as $parent | |
| 1295 |
[ |
| 1296 |
# Create entries for each switch serial in the stack |
| 1297 |
($parent.serials // [])[] | |
| 1298 |
{ |
| 1299 |
name: ., |
| 1300 |
canonical_facts: { |
| 1301 |
ansible_product_serial: . |
| 1302 |
}, |
| 1303 |
facts: { |
| 1304 |
device_type: "switch", |
| 1305 |
stack_id: ($parent.id | tostring), |
| 1306 |
stack_name: $parent.name, |
| 1307 |
is_monitor_only: $parent.isMonitorOnly, |
| 1308 |
virtual_mac: $parent.virtualMac |
| 1309 |
} |
| 1310 |
} |
| 1311 |
] |
| 1312 |
else [] |
| 1313 |
end |
| 1314 |
|
| 1315 |
# getDeviceSwitchRoutingInterfaceDhcp - not good |
| 1316 |
cisco.meraki.devices_switch_routing_interfaces_dhcp_info: |
| 1317 |
query: >- |
| 1318 |
if .meraki_response then |
| 1319 |
.meraki_response | |
| 1320 |
. as $parent | |
| 1321 |
[ |
| 1322 |
# Create entries for each device with fixed IP assignment |
| 1323 |
($parent.fixedIpAssignments // [])[] | |
| 1324 |
{ |
| 1325 |
name: (.name // .mac), |
| 1326 |
canonical_facts: { |
| 1327 |
hostname: .ip, |
| 1328 |
ansible_machine_id: .mac |
| 1329 |
}, |
| 1330 |
facts: { |
| 1331 |
device_type: "switch", |
| 1332 |
fixed_ip_assignment: { |
| 1333 |
mac: .mac, |
| 1334 |
ip: .ip, |
| 1335 |
name: .name |
| 1336 |
}, |
| 1337 |
dhcp_config: { |
| 1338 |
dhcp_mode: $parent.dhcpMode, |
| 1339 |
dhcp_lease_time: $parent.dhcpLeaseTime, |
| 1340 |
dns_nameservers_option: $parent.dnsNameserversOption, |
| 1341 |
boot_options_enabled: $parent.bootOptionsEnabled |
| 1342 |
} |
| 1343 |
} |
| 1344 |
} |
| 1345 |
] |
| 1346 |
else [] |
| 1347 |
end |
| 1348 |
|
| 1349 |
# getDeviceSwitchRoutingInterfaceDhcp |
| 1350 |
cisco.meraki.devices_switch_routing_interfaces_dhcp: |
| 1351 |
query: >- |
| 1352 |
if .meraki_response then |
| 1353 |
.meraki_response | |
| 1354 |
. as $parent | |
| 1355 |
[ |
| 1356 |
# Create entries for each device with fixed IP assignment |
| 1357 |
($parent.fixedIpAssignments // [])[] | |
| 1358 |
{ |
| 1359 |
name: (.name // .mac), |
| 1360 |
canonical_facts: { |
| 1361 |
hostname: .ip, |
| 1362 |
ansible_machine_id: .mac |
| 1363 |
}, |
| 1364 |
facts: { |
| 1365 |
device_type: "switch", |
| 1366 |
fixed_ip_assignment: { |
| 1367 |
mac: .mac, |
| 1368 |
ip: .ip, |
| 1369 |
name: .name |
| 1370 |
}, |
| 1371 |
dhcp_config: { |
| 1372 |
dhcp_mode: $parent.dhcpMode, |
| 1373 |
dhcp_lease_time: $parent.dhcpLeaseTime, |
| 1374 |
dns_nameservers_option: $parent.dnsNameserversOption, |
| 1375 |
boot_options_enabled: $parent.bootOptionsEnabled |
| 1376 |
} |
| 1377 |
} |
| 1378 |
} |
| 1379 |
] |
| 1380 |
else [] |
| 1381 |
end |
| 1382 |
|
| 1383 |
# updateNetworkSwitchRoutingMulticast |
| 1384 |
cisco.meraki.networks_switch_routing_multicast: |
| 1385 |
query: >- |
| 1386 |
if .meraki_response then |
| 1387 |
.meraki_response | |
| 1388 |
if .overrides and (.overrides | length > 0) then |
| 1389 |
. as $parent | |
| 1390 |
[ |
| 1391 |
$parent.overrides[] | |
| 1392 |
. as $override | |
| 1393 |
( |
| 1394 |
# Create entries for each switch serial |
| 1395 |
($override.switches // [])[] | |
| 1396 |
{ |
| 1397 |
name: (. | tostring), |
| 1398 |
canonical_facts: { |
| 1399 |
ansible_product_serial: (. | tostring) |
| 1400 |
}, |
| 1401 |
facts: { |
| 1402 |
device_type: "switch", |
| 1403 |
multicast_settings: { |
| 1404 |
igmp_snooping_enabled: $override.igmpSnoopingEnabled, |
| 1405 |
flood_unknown_multicast_traffic_enabled: $override.floodUnknownMulticastTrafficEnabled |
| 1406 |
}, |
| 1407 |
default_settings: { |
| 1408 |
igmp_snooping_enabled: ($parent.defaultSettings.igmpSnoopingEnabled // false), |
| 1409 |
flood_unknown_multicast_traffic_enabled: ($parent.defaultSettings.floodUnknownMulticastTrafficEnabled // false) |
| 1410 |
} |
| 1411 |
} |
| 1412 |
} |
| 1413 |
) |
| 1414 |
] | flatten |
| 1415 |
else |
| 1416 |
[] |
| 1417 |
end |
| 1418 |
else [] |
| 1419 |
end |
| 1420 |
|
| 1421 |
# updateNetworkSwitchDhcpServerPolicy |
| 1422 |
cisco.meraki.networks_switch_dhcp_server_policy: |
| 1423 |
query: >- |
| 1424 |
if .meraki_response then |
| 1425 |
.meraki_response | |
| 1426 |
. as $parent | |
| 1427 |
[ |
| 1428 |
( |
| 1429 |
# Create entries for each blocked DHCP server |
| 1430 |
($parent.blockedServers // [])[] | |
| 1431 |
{ |
| 1432 |
name: ("blocked-dhcp-server-" + .), |
| 1433 |
canonical_facts: { |
| 1434 |
ansible_machine_id: . |
| 1435 |
}, |
| 1436 |
facts: { |
| 1437 |
device_type: "switch", |
| 1438 |
dhcp_server_policy: { |
| 1439 |
status: "blocked", |
| 1440 |
mac_address: ., |
| 1441 |
default_policy: $parent.defaultPolicy, |
| 1442 |
arp_inspection_enabled: ($parent.arpInspection.enabled // false) |
| 1443 |
} |
| 1444 |
} |
| 1445 |
} |
| 1446 |
), |
| 1447 |
( |
| 1448 |
# Create entries for each allowed DHCP server |
| 1449 |
($parent.allowedServers // [])[] | |
| 1450 |
{ |
| 1451 |
name: ("allowed-dhcp-server-" + .), |
| 1452 |
canonical_facts: { |
| 1453 |
ansible_machine_id: . |
| 1454 |
}, |
| 1455 |
facts: { |
| 1456 |
device_type: "switch", |
| 1457 |
dhcp_server_policy: { |
| 1458 |
status: "allowed", |
| 1459 |
mac_address: ., |
| 1460 |
default_policy: $parent.defaultPolicy, |
| 1461 |
arp_inspection_enabled: ($parent.arpInspection.enabled // false) |
| 1462 |
} |
| 1463 |
} |
| 1464 |
} |
| 1465 |
) |
| 1466 |
] |
| 1467 |
else [] |
| 1468 |
end |
| 1469 |
|
| 1470 |
# Networks |
| 1471 |
cisco.meraki.networks_info: |
| 1472 |
query: >- |
| 1473 |
if .meraki_response then |
| 1474 |
.meraki_response | [.] | flatten | |
| 1475 |
map({ |
| 1476 |
name: .name, |
| 1477 |
canonical_facts: { |
| 1478 |
ansible_machine_id: .id |
| 1479 |
}, |
| 1480 |
facts: { |
| 1481 |
device_type: "network", |
| 1482 |
meraki_organization_id: .organizationId |
| 1483 |
} |
| 1484 |
}) |
| 1485 |
else [] |
| 1486 |
end |
| 1487 |
|
| 1488 |
# delete operation returns "meraki_response": null |
| 1489 |
cisco.meraki.networks: |
| 1490 |
query: >- |
| 1491 |
if .meraki_response then |
| 1492 |
[.meraki_response] | |
| 1493 |
map({ |
| 1494 |
name: .name, |
| 1495 |
canonical_facts: { |
| 1496 |
ansible_machine_id: .id |
| 1497 |
}, |
| 1498 |
facts: { |
| 1499 |
device_type: "switch", |
| 1500 |
meraki_organization_id: .organizationId |
| 1501 |
} |
| 1502 |
}) |
| 1503 |
else [] |
| 1504 |
end |
| 1505 |
|
| 1506 |
# updateDevice does not seem to return productType field |
| 1507 |
cisco.meraki.devices: |
| 1508 |
query: >- |
| 1509 |
if .meraki_response then |
| 1510 |
.meraki_response | [.] | flatten | |
| 1511 |
map({ |
| 1512 |
name: ((.name | select(. != "")) // (.model + "-" + .serial)), |
| 1513 |
canonical_facts: { |
| 1514 |
ansible_product_serial: .serial, |
| 1515 |
hostname: (.lanIp // "") |
| 1516 |
}, |
| 1517 |
facts: { |
| 1518 |
device_type: (if .model | startswith("MV") then "camera" |
| 1519 |
elif .model | startswith("MR") then "wireless" |
| 1520 |
elif .model | startswith("MS") then "switch" |
| 1521 |
elif .model | startswith("MX") then "appliance" |
| 1522 |
else "unknown" |
| 1523 |
end), |
| 1524 |
meraki_network_id: .networkId, |
| 1525 |
ansible_hostname: (.lanIp // ""), |
| 1526 |
ansible_product_name: .model, |
| 1527 |
ansible_bios_version: .firmware, |
| 1528 |
macaddress: .mac |
| 1529 |
} |
| 1530 |
}) |
| 1531 |
else [] |
| 1532 |
end |