| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
""" |
| 8 |
The module file for iosxr_bgp_neighbor_address_family |
| 9 |
""" |
| 10 |
|
| 11 |
from __future__ import absolute_import, division, print_function |
| 12 |
|
| 13 |
|
| 14 |
__metaclass__ = type |
| 15 |
|
| 16 |
DOCUMENTATION = """ |
| 17 |
module: iosxr_bgp_neighbor_address_family |
| 18 |
short_description: Resource module to configure BGP Neighbor Address family. |
| 19 |
description: |
| 20 |
- This module configures and manages the attributes of BGP global on Cisco IOS-XR platforms. |
| 21 |
version_added: 2.0.0 |
| 22 |
author: Ashwini Mhatre (@amhatre) |
| 23 |
notes: |
| 24 |
- This module works with connection C(network_cli). |
| 25 |
options: |
| 26 |
config: |
| 27 |
description: BGP neighbor address family configurations. |
| 28 |
type: dict |
| 29 |
suboptions: |
| 30 |
as_number: |
| 31 |
description: Autonomous system number. |
| 32 |
type: str |
| 33 |
neighbors: |
| 34 |
description: A list of BGP neighbor address family configurations. |
| 35 |
type: list |
| 36 |
elements: dict |
| 37 |
suboptions: |
| 38 |
neighbor_address: |
| 39 |
description: |
| 40 |
- Neighbor router address. |
| 41 |
type: str |
| 42 |
required: true |
| 43 |
address_family: |
| 44 |
description: Enable address family and enter its config mode |
| 45 |
type: list |
| 46 |
elements: dict |
| 47 |
suboptions: |
| 48 |
afi: |
| 49 |
description: address family. |
| 50 |
type: str |
| 51 |
choices: [ 'ipv4', 'ipv6', 'l2vpn', 'link-state', 'vpnv4', 'vpnv6'] |
| 52 |
safi: |
| 53 |
description: Address Family modifier |
| 54 |
type: str |
| 55 |
choices: [ 'flowspec', 'mdt', 'multicast', 'mvpn', 'rt-filter', 'tunnel', 'unicast', 'labeled-unicast' ] |
| 56 |
aigp: &aigp |
| 57 |
description: AIGP attribute |
| 58 |
type: dict |
| 59 |
suboptions: |
| 60 |
disable: |
| 61 |
description: Ignore AIGP attribute. |
| 62 |
type: bool |
| 63 |
set: |
| 64 |
description: Set AIGP attribute. |
| 65 |
type: bool |
| 66 |
send_cost_community_disable: |
| 67 |
description: send AIGP attribute. |
| 68 |
type: bool |
| 69 |
send_med: |
| 70 |
description: send med options. |
| 71 |
type: dict |
| 72 |
suboptions: |
| 73 |
set: |
| 74 |
type: bool |
| 75 |
description: set Send AIGP value in MED. |
| 76 |
disable: |
| 77 |
description: disable Send AIGP value in MED. |
| 78 |
type: bool |
| 79 |
allowas_in: &allowas_in |
| 80 |
type: dict |
| 81 |
description: Allow as-path with my AS present in it. |
| 82 |
suboptions: |
| 83 |
value: |
| 84 |
type: int |
| 85 |
description: Number of occurences of AS number 1-10. |
| 86 |
set: |
| 87 |
type: bool |
| 88 |
description: set allowas_in |
| 89 |
as_override: &as_override |
| 90 |
type: dict |
| 91 |
description: Override matching AS-number while sending update |
| 92 |
suboptions: |
| 93 |
set: |
| 94 |
type: bool |
| 95 |
description: set as_override |
| 96 |
inheritance_disable: |
| 97 |
type: bool |
| 98 |
description: Prevent as-override from being inherited from the parent. |
| 99 |
bestpath_origin_as_allow_invalid: |
| 100 |
type: bool |
| 101 |
description: Change default route selection criteria.Allow BGP origin-AS knobs. |
| 102 |
capability_orf_prefix: &capability |
| 103 |
type: str |
| 104 |
description: Advertise address prefix ORF capability to this neighbor. |
| 105 |
choices: ['both', 'send', 'none', 'receive'] |
| 106 |
default_originate: &default_originate |
| 107 |
type: dict |
| 108 |
description: Originate default route to this neighbor. |
| 109 |
suboptions: |
| 110 |
set: |
| 111 |
type: bool |
| 112 |
description: set default route. |
| 113 |
route_policy: |
| 114 |
type: str |
| 115 |
description: Route policy to specify criteria to originate default |
| 116 |
inheritance_disable: |
| 117 |
type: bool |
| 118 |
description: Prevent default-originate from being inherited from the parent. |
| 119 |
long_lived_graceful_restart: &long_lived_graceful_restart |
| 120 |
type: dict |
| 121 |
description: Enable long lived graceful restart support. |
| 122 |
suboptions: |
| 123 |
capable: |
| 124 |
type: bool |
| 125 |
description: Treat neighbor as LLGR capable. |
| 126 |
stale_time: |
| 127 |
type: dict |
| 128 |
description: Maximum time to wait before purging long-lived stale routes. |
| 129 |
suboptions: |
| 130 |
send: |
| 131 |
type: int |
| 132 |
description: max send time |
| 133 |
accept: |
| 134 |
type: int |
| 135 |
description: max accept time |
| 136 |
maximum_prefix: &maximum_prefix |
| 137 |
type: dict |
| 138 |
description: Maximum number of prefixes to accept from this peer. |
| 139 |
suboptions: |
| 140 |
max_limit: |
| 141 |
type: int |
| 142 |
description: maximum no. of prefix limit.<1-4294967295. |
| 143 |
threshold_value: |
| 144 |
type: int |
| 145 |
description: hreshold value (%) at which to generate a warning msg <1-100>. |
| 146 |
restart: |
| 147 |
type: int |
| 148 |
description: Restart time interval. |
| 149 |
warning_only: |
| 150 |
type: bool |
| 151 |
description: Only give warning message when limit is exceeded. |
| 152 |
discard_extra_paths: |
| 153 |
description: Discard extra paths when limit is exceeded. |
| 154 |
type: bool |
| 155 |
multipath: &multipath |
| 156 |
type: bool |
| 157 |
description: Paths from this neighbor is eligible for multipath. |
| 158 |
next_hop_self: &next_hop_self |
| 159 |
type: dict |
| 160 |
description: Disable the next hop calculation for this neighbor. |
| 161 |
suboptions: |
| 162 |
set: |
| 163 |
type: bool |
| 164 |
description: set next hop self. |
| 165 |
inheritance_disable: |
| 166 |
type: bool |
| 167 |
description: Prevent next_hop_self from being inherited from the parent. |
| 168 |
next_hop_unchanged: &next_hop_unchanged |
| 169 |
type: dict |
| 170 |
description: Disable the next hop calculation for this neighbor. |
| 171 |
suboptions: |
| 172 |
set: |
| 173 |
type: bool |
| 174 |
description: set next hop unchanged. |
| 175 |
inheritance_disable: |
| 176 |
type: bool |
| 177 |
description: Prevent next_hop_unchanged from being inherited from the parent. |
| 178 |
multipath: |
| 179 |
type: bool |
| 180 |
description: Do not overwrite nexthop before advertising multipaths. |
| 181 |
optimal_route_reflection_group_name: &optimal_route_reflection |
| 182 |
type: str |
| 183 |
description: Configure optimal-route-reflection group. |
| 184 |
orf_route_policy: &orf_rp |
| 185 |
type: str |
| 186 |
description: Specify ORF and inbound filtering criteria.' |
| 187 |
origin_as: |
| 188 |
description: BGP origin-AS knobs. |
| 189 |
type: dict |
| 190 |
suboptions: |
| 191 |
validation: |
| 192 |
description: BGP origin-AS validation knobs. |
| 193 |
type: dict |
| 194 |
suboptions: |
| 195 |
disable: |
| 196 |
description: Disable RPKI origin-AS validation. |
| 197 |
type: bool |
| 198 |
remove_private_AS: &remove_private_AS |
| 199 |
type: dict |
| 200 |
description: Remove private AS number from outbound updates. |
| 201 |
suboptions: |
| 202 |
set: |
| 203 |
type: bool |
| 204 |
description: set remove private As. |
| 205 |
inbound: |
| 206 |
type: bool |
| 207 |
description: Remove private AS number from inbound updates. |
| 208 |
entire_aspath: |
| 209 |
type: bool |
| 210 |
description: remove only if all ASes in the path are private. |
| 211 |
inheritance_disable: |
| 212 |
type: bool |
| 213 |
description: Prevent remove-private-AS from being inherited from the parent. |
| 214 |
route_policy: &route_policy |
| 215 |
type: dict |
| 216 |
description: Apply route policy to neighbor. |
| 217 |
suboptions: |
| 218 |
inbound: |
| 219 |
type: str |
| 220 |
description: Apply route policy to inbound routes. |
| 221 |
outbound: |
| 222 |
type: str |
| 223 |
description: Apply route policy to outbound routes. |
| 224 |
route_reflector_client: &route_reflector_client |
| 225 |
type: dict |
| 226 |
description: Configure a neighbor as Route Reflector client. |
| 227 |
suboptions: |
| 228 |
set: |
| 229 |
type: bool |
| 230 |
description: set route-reflector-client. |
| 231 |
inheritance_disable: |
| 232 |
type: bool |
| 233 |
description: Prevent route-reflector-client from being inherited from the parent. |
| 234 |
send_community_ebgp: &send_community_ebgp |
| 235 |
description: Send community attribute to this external neighbor. |
| 236 |
type: dict |
| 237 |
suboptions: |
| 238 |
set: |
| 239 |
type: bool |
| 240 |
description: set send_community_ebgp. |
| 241 |
inheritance_disable: |
| 242 |
type: bool |
| 243 |
description: Prevent send_community_ebgp from being inherited from the parent. |
| 244 |
send_community_gshut_ebgp: &send_community_gshut_ebgp |
| 245 |
description: Allow the g-shut community to be sent to this external neighbor. |
| 246 |
type: dict |
| 247 |
suboptions: |
| 248 |
set: |
| 249 |
type: bool |
| 250 |
description: set send_community_gshut_ebgp. |
| 251 |
inheritance_disable: |
| 252 |
type: bool |
| 253 |
description: Prevent send_community_gshut_ebgp from being inherited from the parent. |
| 254 |
send_extended_community_ebgp: &send_extended_community_ebgp |
| 255 |
description: Send extended community attribute to this external neighbor. |
| 256 |
type: dict |
| 257 |
suboptions: |
| 258 |
set: |
| 259 |
type: bool |
| 260 |
description: set send_extended_community_ebgp. |
| 261 |
inheritance_disable: |
| 262 |
type: bool |
| 263 |
description: Prevent send_extended_community_ebgp from being inherited from the parent. |
| 264 |
send_multicast_attributes: |
| 265 |
description: Send multicast attributes to this neighbor . |
| 266 |
type: dict |
| 267 |
suboptions: |
| 268 |
set: |
| 269 |
type: bool |
| 270 |
description: set send_multicast_attributes. |
| 271 |
disable: |
| 272 |
type: bool |
| 273 |
description: Disable send multicast attributes. |
| 274 |
soft_reconfiguration: &soft_reconfiguration |
| 275 |
description: Per neighbor soft reconfiguration. |
| 276 |
type: dict |
| 277 |
suboptions: |
| 278 |
inbound: |
| 279 |
type: dict |
| 280 |
description: inbound soft reconfiguration |
| 281 |
suboptions: |
| 282 |
set: |
| 283 |
type: bool |
| 284 |
description: set inbound |
| 285 |
always: |
| 286 |
type: bool |
| 287 |
description: Allow inbound soft reconfiguration for this neighbor. Always use soft reconfig, even if route refresh is supported. |
| 288 |
inheritance_disable: |
| 289 |
type: bool |
| 290 |
description: Prevent soft_reconfiguration from being inherited from the parent. |
| 291 |
weight: &wt |
| 292 |
type: int |
| 293 |
description: Set default weight for routes from this neighbor. |
| 294 |
validation: &validation |
| 295 |
type: dict |
| 296 |
description: Flowspec Validation for this neighbor. |
| 297 |
suboptions: |
| 298 |
set: |
| 299 |
type: bool |
| 300 |
description: set validation. |
| 301 |
redirect: |
| 302 |
type: bool |
| 303 |
description: Flowspec Redirect nexthop Validation. |
| 304 |
disable: |
| 305 |
type: bool |
| 306 |
description: disable validation. |
| 307 |
vrfs: |
| 308 |
description: Configure BGP neighbor afin a VRF. |
| 309 |
type: list |
| 310 |
elements: dict |
| 311 |
suboptions: |
| 312 |
vrf: |
| 313 |
description: VRF name. |
| 314 |
type: str |
| 315 |
neighbors: |
| 316 |
description: A list of BGP neighbor address family configurations. |
| 317 |
type: list |
| 318 |
elements: dict |
| 319 |
suboptions: |
| 320 |
neighbor_address: |
| 321 |
description: |
| 322 |
- Neighbor router address. |
| 323 |
type: str |
| 324 |
required: true |
| 325 |
address_family: |
| 326 |
description: Enable address family and enter its config mode |
| 327 |
type: list |
| 328 |
elements: dict |
| 329 |
suboptions: |
| 330 |
afi: |
| 331 |
description: address family. |
| 332 |
type: str |
| 333 |
choices: [ 'ipv4', 'ipv6'] |
| 334 |
safi: |
| 335 |
description: Address Family modifier |
| 336 |
type: str |
| 337 |
choices: [ 'flowspec', 'multicast', 'mvpn', 'unicast', 'labeled-unicast' ] |
| 338 |
aigp: *aigp |
| 339 |
allowas_in: *allowas_in |
| 340 |
as_override: |
| 341 |
type: dict |
| 342 |
description: Override matching AS-number while sending update |
| 343 |
aliases: |
| 344 |
- as_overrride |
| 345 |
suboptions: |
| 346 |
set: |
| 347 |
type: bool |
| 348 |
description: set as_override |
| 349 |
inheritance_disable: |
| 350 |
type: bool |
| 351 |
description: Prevent as-override from being inherited from the parent. |
| 352 |
capability_orf_prefix: *capability |
| 353 |
default_originate: *default_originate |
| 354 |
long_lived_graceful_restart: *long_lived_graceful_restart |
| 355 |
maximum_prefix: *maximum_prefix |
| 356 |
multipath: *multipath |
| 357 |
next_hop_self: *next_hop_self |
| 358 |
next_hop_unchanged: *next_hop_unchanged |
| 359 |
optimal_route_reflection_group_name: *optimal_route_reflection |
| 360 |
orf_route_policy: *orf_rp |
| 361 |
remove_private_AS: *remove_private_AS |
| 362 |
route_policy: *route_policy |
| 363 |
route_reflector_client: *route_reflector_client |
| 364 |
send_community_ebgp: *send_community_ebgp |
| 365 |
send_community_gshut_ebgp: *send_community_gshut_ebgp |
| 366 |
send_extended_community_ebgp: *send_extended_community_ebgp |
| 367 |
soft_reconfiguration: *soft_reconfiguration |
| 368 |
site_of_origin: |
| 369 |
description: Site-of-Origin extended community associated with the neighbor. |
| 370 |
type: str |
| 371 |
weight: *wt |
| 372 |
validation: *validation |
| 373 |
|
| 374 |
running_config: |
| 375 |
description: |
| 376 |
- This option is used only with state I(parsed). |
| 377 |
- The value of this option should be the output received from the Iosxr device by |
| 378 |
executing the command B(show running-config router bgp). |
| 379 |
- The state I(parsed) reads the configuration from C(running_config) option and |
| 380 |
transforms it into Ansible structured data as per the resource module's argspec |
| 381 |
and the value is then returned in the I(parsed) key within the result. |
| 382 |
type: str |
| 383 |
state: |
| 384 |
description: |
| 385 |
- The state the configuration should be left in. |
| 386 |
type: str |
| 387 |
choices: [deleted, merged, overridden, replaced, gathered, rendered, parsed] |
| 388 |
default: merged |
| 389 |
""" |
| 390 |
EXAMPLES = """ |
| 391 |
# Using merged |
| 392 |
# Before state: |
| 393 |
# ------------- |
| 394 |
# RP/0/0/CPU0:iosxr-02#show running-config router bgp |
| 395 |
# Sat Feb 20 03:49:43.618 UTC |
| 396 |
# router bgp 65536 |
| 397 |
# bgp router-id 192.0.2.1 |
| 398 |
# address-family ipv4 unicast |
| 399 |
# address-family vpnv4 unicast |
| 400 |
# neighbor 192.0.2.2 |
| 401 |
# remote-as 65537 |
| 402 |
# neighbor 192.0.2.3 |
| 403 |
# remote-as 65538 |
| 404 |
# vrf vrf1 |
| 405 |
# rd auto |
| 406 |
# neighbor 192.0.2.4 |
| 407 |
# remote-as 65539 |
| 408 |
# vrf vrf2 |
| 409 |
# rd auto |
| 410 |
# neighbor 192.0.2.5 |
| 411 |
# remote-as 65540 |
| 412 |
|
| 413 |
- name: Merge the provided configuration with the existing running configuration |
| 414 |
cisco.iosxr.iosxr_bgp_neighbor_address_family: |
| 415 |
state: merged |
| 416 |
config: |
| 417 |
as_number: 65536 |
| 418 |
neighbors: |
| 419 |
- neighbor_address: 192.0.2.2 |
| 420 |
address_family: |
| 421 |
- afi: ipv4 |
| 422 |
safi: unicast |
| 423 |
multipath: true |
| 424 |
default_originate: |
| 425 |
set: true |
| 426 |
weight: 5 |
| 427 |
- neighbor_address: 192.0.2.3 |
| 428 |
address_family: |
| 429 |
- afi: ipv4 |
| 430 |
safi: unicast |
| 431 |
multipath: true |
| 432 |
default_originate: |
| 433 |
set: true |
| 434 |
weight: 4 |
| 435 |
vrfs: |
| 436 |
- vrf: vrf1 |
| 437 |
neighbors: |
| 438 |
- neighbor_address: 192.0.2.4 |
| 439 |
address_family: |
| 440 |
- afi: ipv4 |
| 441 |
safi: unicast |
| 442 |
multipath: true |
| 443 |
default_originate: |
| 444 |
set: true |
| 445 |
capability_orf_prefix: both |
| 446 |
- vrf: vrf2 |
| 447 |
neighbors: |
| 448 |
- neighbor_address: 192.0.2.5 |
| 449 |
address_family: |
| 450 |
- afi: ipv4 |
| 451 |
safi: unicast |
| 452 |
multipath: true |
| 453 |
default_originate: |
| 454 |
set: true |
| 455 |
capability_orf_prefix: both |
| 456 |
# Task output |
| 457 |
# ------------- |
| 458 |
# commands: |
| 459 |
# - router bgp 65536 |
| 460 |
# - neighbor 192.0.2.2 |
| 461 |
# - address-family ipv4 unicast |
| 462 |
# - default-originate |
| 463 |
# - multipath |
| 464 |
# - weight 5 |
| 465 |
# - neighbor 192.0.2.3 |
| 466 |
# - address-family ipv4 unicast |
| 467 |
# - default-originate |
| 468 |
# - multipath |
| 469 |
# - weight 4 |
| 470 |
# - vrf vrf1 |
| 471 |
# - neighbor 192.0.2.4 |
| 472 |
# - address-family ipv4 unicast |
| 473 |
# - capability orf prefix both |
| 474 |
# - default-originate |
| 475 |
# - multipath |
| 476 |
# - vrf vrf2 |
| 477 |
# - neighbor 192.0.2.5 |
| 478 |
# - address-family ipv4 unicast |
| 479 |
# - capability orf prefix both |
| 480 |
# - default-originate |
| 481 |
# - multipath |
| 482 |
# |
| 483 |
# |
| 484 |
# after: |
| 485 |
# as_number: 65536 |
| 486 |
# neighbors: |
| 487 |
# - neighbor_address: 192.0.2.2 |
| 488 |
# address_family: |
| 489 |
# - afi: "ipv4" |
| 490 |
# safi: "unicast" |
| 491 |
# multipath: true |
| 492 |
# default_originate: |
| 493 |
# set: true |
| 494 |
# weight: 5 |
| 495 |
# - neighbor_address: 192.0.2.3 |
| 496 |
# address_family: |
| 497 |
# - afi: "ipv4" |
| 498 |
# safi: "unicast" |
| 499 |
# multipath: true |
| 500 |
# default_originate: |
| 501 |
# set: true |
| 502 |
# weight: 4 |
| 503 |
# vrfs: |
| 504 |
# - vrf: vrf1 |
| 505 |
# neighbors: |
| 506 |
# - neighbor_address: 192.0.2.4 |
| 507 |
# address_family: |
| 508 |
# - afi: "ipv4" |
| 509 |
# safi: "unicast" |
| 510 |
# multipath: true |
| 511 |
# default_originate: |
| 512 |
# set: true |
| 513 |
# capability_orf_prefix: both |
| 514 |
# - vrf: vrf2 |
| 515 |
# neighbors: |
| 516 |
# - neighbor_address: 192.0.2.5 |
| 517 |
# address_family: |
| 518 |
# - afi: "ipv4" |
| 519 |
# safi: "unicast" |
| 520 |
# multipath: true |
| 521 |
# default_originate: |
| 522 |
# set: true |
| 523 |
# capability_orf_prefix: both |
| 524 |
# |
| 525 |
# |
| 526 |
# After state: |
| 527 |
# ------------- |
| 528 |
# RP/0/0/CPU0:iosxr-02#show running-config router bgp |
| 529 |
# Sat Feb 20 03:49:43.618 UTC |
| 530 |
# router bgp 65536 |
| 531 |
# bgp router-id 192.0.1.1 |
| 532 |
# address-family ipv4 unicast |
| 533 |
# address-family vpnv4 unicast |
| 534 |
# neighbor 192.0.2.2 |
| 535 |
# remote-as 65537 |
| 536 |
# address-family ipv4 unicast |
| 537 |
# multipath |
| 538 |
# weight 5 |
| 539 |
# default-originate |
| 540 |
# neighbor 1.1.1.2 |
| 541 |
# remote-as 65538 |
| 542 |
# address-family ipv4 unicast |
| 543 |
# multipath |
| 544 |
# weight 5 |
| 545 |
# default-originate |
| 546 |
# vrf vrf1 |
| 547 |
# rd auto |
| 548 |
# neighbor 192.0.2.4 |
| 549 |
# remote-as 65539 |
| 550 |
# address-family ipv4 unicast |
| 551 |
# multipath |
| 552 |
# capability orf prefix both |
| 553 |
# default-originate |
| 554 |
# vrf vrf2 |
| 555 |
# rd auto |
| 556 |
# neighbor 192.0.2.5 |
| 557 |
# remote-as 65540 |
| 558 |
# address-family ipv4 unicast |
| 559 |
# multipath |
| 560 |
# capability orf prefix both |
| 561 |
# default-originate |
| 562 |
# |
| 563 |
# |
| 564 |
# Using delete |
| 565 |
# Before state: |
| 566 |
# ------------- |
| 567 |
# |
| 568 |
# RP/0/0/CPU0:iosxr-02#show running-config router bgp |
| 569 |
# Sat Feb 20 03:49:43.618 UTC |
| 570 |
# router bgp 65536 |
| 571 |
# bgp router-id 192.0.1.1 |
| 572 |
# address-family ipv4 unicast |
| 573 |
# address-family vpnv4 unicast |
| 574 |
# neighbor 192.0.2.2 |
| 575 |
# remote-as 65537 |
| 576 |
# address-family ipv4 unicast |
| 577 |
# multipath |
| 578 |
# weight 5 |
| 579 |
# default-originate |
| 580 |
# neighbor 192.0.2.3 |
| 581 |
# remote-as 65538 |
| 582 |
# address-family ipv4 unicast |
| 583 |
# multipath |
| 584 |
# weight 5 |
| 585 |
# default-originate |
| 586 |
# vrf vrf1 |
| 587 |
# rd auto |
| 588 |
# neighbor 192.0.2.4 |
| 589 |
# remote-as 65539 |
| 590 |
# address-family ipv4 unicast |
| 591 |
# multipath |
| 592 |
# capability orf prefix both |
| 593 |
# default-originate |
| 594 |
# vrf vrf2 |
| 595 |
# rd auto |
| 596 |
# neighbor 192.0.2.5 |
| 597 |
# remote-as 65540 |
| 598 |
# address-family ipv4 unicast |
| 599 |
# multipath |
| 600 |
# capability orf prefix both |
| 601 |
# default-originate |
| 602 |
|
| 603 |
- name: Delete the provided configuration |
| 604 |
cisco.iosxr.iosxr_bgp_neighbor_address_family: |
| 605 |
state: deleted |
| 606 |
config: |
| 607 |
as_number: 65536 |
| 608 |
neighbors: |
| 609 |
- neighbor_address: 192.0.2.2 |
| 610 |
address_family: |
| 611 |
- afi: ipv4 |
| 612 |
safi: unicast |
| 613 |
multipath: true |
| 614 |
default_originate: |
| 615 |
set: true |
| 616 |
weight: 5 |
| 617 |
|
| 618 |
# Task output |
| 619 |
# ------------- |
| 620 |
# |
| 621 |
# commands: |
| 622 |
# - router bgp 65536 |
| 623 |
# - neighbor 192.0.2.2 |
| 624 |
# - no address-family ipv4 unicast |
| 625 |
# |
| 626 |
# |
| 627 |
# after: |
| 628 |
# as_number: 65536 |
| 629 |
# neighbors: |
| 630 |
# - neighbor_address: 192.0.2.3 |
| 631 |
# address_family: |
| 632 |
# - afi: "ipv4" |
| 633 |
# safi: "unicast" |
| 634 |
# multipath: true |
| 635 |
# default_originate: |
| 636 |
# set: true |
| 637 |
# weight: 4 |
| 638 |
# vrfs: |
| 639 |
# - vrf: vrf1 |
| 640 |
# neighbors: |
| 641 |
# - neighbor_address: 192.0.2.4 |
| 642 |
# address_family: |
| 643 |
# - afi: "ipv4" |
| 644 |
# safi: "unicast" |
| 645 |
# multipath: true |
| 646 |
# default_originate: |
| 647 |
# set: true |
| 648 |
# capability_orf_prefix: both |
| 649 |
# - neighbor_address: 192.0.2.5 |
| 650 |
# address_family: |
| 651 |
# - afi: "ipv4" |
| 652 |
# safi: "unicast" |
| 653 |
# multipath: true |
| 654 |
# default_originate: |
| 655 |
# set: true |
| 656 |
# capability_orf_prefix: both |
| 657 |
# |
| 658 |
# |
| 659 |
# Using Replaced |
| 660 |
# Before state: |
| 661 |
# ------------- |
| 662 |
# |
| 663 |
# RP/0/0/CPU0:iosxr-02#show running-config router bgp |
| 664 |
# Sat Feb 20 03:49:43.618 UTC |
| 665 |
# router bgp 65536 |
| 666 |
# bgp router-id 192.0.1.1 |
| 667 |
# address-family ipv4 unicast |
| 668 |
# address-family vpnv4 unicast |
| 669 |
# neighbor 192.0.2.2 |
| 670 |
# remote-as 65537 |
| 671 |
# address-family ipv4 unicast |
| 672 |
# multipath |
| 673 |
# weight 5 |
| 674 |
# default-originate |
| 675 |
# neighbor 192.0.2.3 |
| 676 |
# remote-as 65538 |
| 677 |
# address-family ipv4 unicast |
| 678 |
# multipath |
| 679 |
# weight 5 |
| 680 |
# default-originate |
| 681 |
# vrf vrf1 |
| 682 |
# rd auto |
| 683 |
# neighbor 192.0.2.4 |
| 684 |
# remote-as 65539 |
| 685 |
# address-family ipv4 unicast |
| 686 |
# multipath |
| 687 |
# capability orf prefix both |
| 688 |
# default-originate |
| 689 |
# vrf vrf2 |
| 690 |
# rd auto |
| 691 |
# neighbor 192.0.2.5 |
| 692 |
# remote-as 65540 |
| 693 |
# address-family ipv4 unicast |
| 694 |
# multipath |
| 695 |
# capability orf prefix both |
| 696 |
# default-originate |
| 697 |
|
| 698 |
- name: Replace the provided configuration with the existing running configuration |
| 699 |
cisco.iosxr.iosxr_bgp_neighbor_address_family: |
| 700 |
state: replaced |
| 701 |
config: |
| 702 |
as_number: 65536 |
| 703 |
neighbors: |
| 704 |
- neighbor_address: 192.0.2.2 |
| 705 |
address_family: |
| 706 |
- afi: ipv4 |
| 707 |
safi: unicast |
| 708 |
default_originate: |
| 709 |
set: true |
| 710 |
weight: 4 |
| 711 |
# Task output |
| 712 |
# ------------- |
| 713 |
# commands: |
| 714 |
# - router bgp 65536 |
| 715 |
# - neighbor 192.0.2.2 |
| 716 |
# - address-family ipv4 unicast |
| 717 |
# - no multipath |
| 718 |
# - weight 4 |
| 719 |
# |
| 720 |
# after: |
| 721 |
# as_number: 65536 |
| 722 |
# neighbors: |
| 723 |
# - neighbor_address: 192.0.2.2 |
| 724 |
# address_family: |
| 725 |
# - afi: "ipv4" |
| 726 |
# safi: "unicast" |
| 727 |
# multipath: true |
| 728 |
# default_originate: |
| 729 |
# set: true |
| 730 |
# weight: 4 |
| 731 |
# - neighbor_address: 192.0.2.3 |
| 732 |
# address_family: |
| 733 |
# - afi: "ipv4" |
| 734 |
# safi: "unicast" |
| 735 |
# multipath: true |
| 736 |
# default_originate: |
| 737 |
# set: true |
| 738 |
# weight: 5 |
| 739 |
# vrfs: |
| 740 |
# - vrf: vrf1 |
| 741 |
# neighbors: |
| 742 |
# - neighbor_address: 192.0.2.4 |
| 743 |
# address_family: |
| 744 |
# - afi: "ipv4" |
| 745 |
# safi: "unicast" |
| 746 |
# multipath: true |
| 747 |
# default_originate: |
| 748 |
# set: true |
| 749 |
# capability_orf_prefix: both |
| 750 |
# - neighbor_address: 192.0.2.5 |
| 751 |
# address_family: |
| 752 |
# - afi: "ipv4" |
| 753 |
# safi: "unicast" |
| 754 |
# multipath: true |
| 755 |
# default_originate: |
| 756 |
# set: true |
| 757 |
# capability_orf_prefix: both |
| 758 |
# |
| 759 |
# After state: |
| 760 |
# ------------- |
| 761 |
# Nexus9000v# show running-config router bgp |
| 762 |
# router bgp 65536 |
| 763 |
# bgp router-id 192.0.1.1 |
| 764 |
# address-family ipv4 unicast |
| 765 |
# address-family vpnv4 unicast |
| 766 |
# neighbor 192.0.2.2 |
| 767 |
# remote-as 65537 |
| 768 |
# address-family ipv4 unicast |
| 769 |
# multipath |
| 770 |
# weight 4 |
| 771 |
# default-originate |
| 772 |
# neighbor 192.0.2.3 |
| 773 |
# remote-as 65538 |
| 774 |
# address-family ipv4 unicast |
| 775 |
# multipath |
| 776 |
# weight 5 |
| 777 |
# default-originate |
| 778 |
# vrf vrf1 |
| 779 |
# rd auto |
| 780 |
# neighbor 192.0.2.4 |
| 781 |
# remote-as 65539 |
| 782 |
# address-family ipv4 unicast |
| 783 |
# multipath |
| 784 |
# capability orf prefix both |
| 785 |
# default-originate |
| 786 |
# vrf vrf2 |
| 787 |
# rd auto |
| 788 |
# neighbor 192.0.2.5 |
| 789 |
# remote-as 65540 |
| 790 |
# address-family ipv4 unicast |
| 791 |
# multipath |
| 792 |
# capability orf prefix both |
| 793 |
# default-originate |
| 794 |
# |
| 795 |
# |
| 796 |
# Using overridden |
| 797 |
# Before state: |
| 798 |
# ------------- |
| 799 |
# RP/0/0/CPU0:iosxr-02#show running-config router bgp |
| 800 |
# Sat Feb 20 03:49:43.618 UTC |
| 801 |
# router bgp 65536 |
| 802 |
# bgp router-id 192.0.1.1 |
| 803 |
# address-family ipv4 unicast |
| 804 |
# address-family vpnv4 unicast |
| 805 |
# neighbor 192.0.2.2 |
| 806 |
# remote-as 65537 |
| 807 |
# address-family ipv4 unicast |
| 808 |
# multipath |
| 809 |
# weight 5 |
| 810 |
# default-originate |
| 811 |
# neighbor 192.0.2.3 |
| 812 |
# remote-as 65538 |
| 813 |
# address-family ipv4 unicast |
| 814 |
# multipath |
| 815 |
# weight 5 |
| 816 |
# default-originate |
| 817 |
# vrf vrf1 |
| 818 |
# rd auto |
| 819 |
# neighbor 192.0.2.4 |
| 820 |
# remote-as 65539 |
| 821 |
# address-family ipv4 unicast |
| 822 |
# multipath |
| 823 |
# capability orf prefix both |
| 824 |
# default-originate |
| 825 |
# vrf vrf2 |
| 826 |
# rd auto |
| 827 |
# neighbor 192.0.2.5 |
| 828 |
# remote-as 65540 |
| 829 |
# address-family ipv4 unicast |
| 830 |
# multipath |
| 831 |
# capability orf prefix both |
| 832 |
# default-originate |
| 833 |
|
| 834 |
- name: override the provided configuration |
| 835 |
cisco.iosxr.iosxr_bgp_neighbor_address_family: |
| 836 |
state: overridden |
| 837 |
config: |
| 838 |
as_number: 65536 |
| 839 |
neighbors: |
| 840 |
- neighbor_address: 192.0.2.2 |
| 841 |
address_family: |
| 842 |
- afi: ipv4 |
| 843 |
safi: unicast |
| 844 |
multipath: true |
| 845 |
default_originate: |
| 846 |
set: true |
| 847 |
weight: 5 |
| 848 |
# Task output |
| 849 |
# ------------- |
| 850 |
# |
| 851 |
# commands: |
| 852 |
# - router bgp 65536 |
| 853 |
# - neighbor 192.0.2.3 |
| 854 |
# - no address-family ipv4 unicast |
| 855 |
# - vrf vrf1 |
| 856 |
# - neighbor 192.0.2.4 |
| 857 |
# - no address-family ipv4 unicast |
| 858 |
# - vrf vrf1 |
| 859 |
# - neighbor 192.0.2.5 |
| 860 |
# - no address-family ipv4 unicast |
| 861 |
# |
| 862 |
# |
| 863 |
# |
| 864 |
# after: |
| 865 |
# as_number: 65536 |
| 866 |
# neighbors: |
| 867 |
# - neighbor_address: 192.0.2.2 |
| 868 |
# address_family: |
| 869 |
# - afi: "ipv4" |
| 870 |
# safi: "unicast" |
| 871 |
# multipath: true |
| 872 |
# default_originate: |
| 873 |
# set: true |
| 874 |
# weight: 5 |
| 875 |
# |
| 876 |
# After state: |
| 877 |
# ------------- |
| 878 |
# RP/0/0/CPU0:iosxr-02#show running-config router bgp |
| 879 |
# Sat Feb 20 03:49:43.618 UTC |
| 880 |
# router bgp 65536 |
| 881 |
# bgp router-id 192.0.1.1 |
| 882 |
# address-family ipv4 unicast |
| 883 |
# address-family vpnv4 unicast |
| 884 |
# neighbor 192.0.2.2 |
| 885 |
# remote-as 65537 |
| 886 |
# address-family ipv4 unicast |
| 887 |
# multipath |
| 888 |
# weight 5 |
| 889 |
# default-originate |
| 890 |
# |
| 891 |
# |
| 892 |
# |
| 893 |
# Using rendered |
| 894 |
# Before state: |
| 895 |
# ------------- |
| 896 |
# RP/0/0/CPU0:iosxr-02#show running-config router bgp |
| 897 |
# Sat Feb 20 03:49:43.618 UTC |
| 898 |
# router bgp 65536 |
| 899 |
# bgp router-id 192.0.2.1 |
| 900 |
# address-family ipv4 unicast |
| 901 |
# address-family vpnv4 unicast |
| 902 |
# neighbor 192.0.2.2 |
| 903 |
# remote-as 65537 |
| 904 |
# neighbor 192.0.2.3 |
| 905 |
# remote-as 65538 |
| 906 |
# vrf vrf1 |
| 907 |
# rd auto |
| 908 |
# neighbor 192.0.2.4 |
| 909 |
# remote-as 65539 |
| 910 |
# vrf vrf2 |
| 911 |
# rd auto |
| 912 |
# neighbor 192.0.2.5 |
| 913 |
# remote-as 65540 |
| 914 |
|
| 915 |
- name: >- |
| 916 |
Render platform specific configuration lines with state rendered (without |
| 917 |
connecting to the device) |
| 918 |
cisco.iosxr.iosxr_bgp_neighbor_address_family: |
| 919 |
state: rendered |
| 920 |
config: |
| 921 |
as_number: 65536 |
| 922 |
neighbors: |
| 923 |
- neighbor_address: 192.0.2.2 |
| 924 |
address_family: |
| 925 |
- afi: ipv4 |
| 926 |
safi: unicast |
| 927 |
multipath: true |
| 928 |
default_originate: |
| 929 |
set: true |
| 930 |
weight: 5 |
| 931 |
- neighbor_address: 192.0.2.3 |
| 932 |
address_family: |
| 933 |
- afi: ipv4 |
| 934 |
safi: unicast |
| 935 |
multipath: true |
| 936 |
default_originate: |
| 937 |
set: true |
| 938 |
weight: 4 |
| 939 |
vrfs: |
| 940 |
- vrf: vrf1 |
| 941 |
neighbors: |
| 942 |
- neighbor_address: 192.0.2.4 |
| 943 |
address_family: |
| 944 |
- afi: ipv4 |
| 945 |
safi: unicast |
| 946 |
multipath: true |
| 947 |
default_originate: |
| 948 |
set: true |
| 949 |
capability_orf_prefix: both |
| 950 |
- vrf: vrf2 |
| 951 |
neighbors: |
| 952 |
- neighbor_address: 192.0.2.5 |
| 953 |
address_family: |
| 954 |
- afi: ipv4 |
| 955 |
safi: unicast |
| 956 |
multipath: true |
| 957 |
default_originate: |
| 958 |
set: true |
| 959 |
capability_orf_prefix: both |
| 960 |
# Task output |
| 961 |
# ------------- |
| 962 |
# commands: |
| 963 |
# - router bgp 65536 |
| 964 |
# - neighbor 192.0.2.2 |
| 965 |
# - address-family ipv4 unicast |
| 966 |
# - default-originate |
| 967 |
# - multipath |
| 968 |
# - weight 5 |
| 969 |
# - neighbor 192.0.2.3 |
| 970 |
# - address-family ipv4 unicast |
| 971 |
# - default-originate |
| 972 |
# - multipath |
| 973 |
# - weight 4 |
| 974 |
# - vrf vrf1 |
| 975 |
# - neighbor 192.0.2.4 |
| 976 |
# - address-family ipv4 unicast |
| 977 |
# - capability orf prefix both |
| 978 |
# - default-originate |
| 979 |
# - multipath |
| 980 |
# - vrf vrf2 |
| 981 |
# - neighbor 192.0.2.5 |
| 982 |
# - address-family ipv4 unicast |
| 983 |
# - capability orf prefix both |
| 984 |
# - default-originate |
| 985 |
# - multipath |
| 986 |
# |
| 987 |
# Using parsed |
| 988 |
# |
| 989 |
# parsed.cfg |
| 990 |
# ------------ |
| 991 |
# router bgp 65536 |
| 992 |
# bgp router-id 192.0.1.1 |
| 993 |
# address-family ipv4 unicast |
| 994 |
# address-family vpnv4 unicast |
| 995 |
# neighbor 192.0.2.2 |
| 996 |
# remote-as 65537 |
| 997 |
# address-family ipv4 unicast |
| 998 |
# multipath |
| 999 |
# weight 5 |
| 1000 |
# default-originate |
| 1001 |
# neighbor 1.1.1.2 |
| 1002 |
# remote-as 65538 |
| 1003 |
# address-family ipv4 unicast |
| 1004 |
# multipath |
| 1005 |
# weight 5 |
| 1006 |
# default-originate |
| 1007 |
# vrf vrf1 |
| 1008 |
# rd auto |
| 1009 |
# neighbor 192.0.2.4 |
| 1010 |
# remote-as 65539 |
| 1011 |
# address-family ipv4 unicast |
| 1012 |
# multipath |
| 1013 |
# capability orf prefix both |
| 1014 |
# default-originate |
| 1015 |
# vrf vrf2 |
| 1016 |
# rd auto |
| 1017 |
# neighbor 192.0.2.5 |
| 1018 |
# remote-as 65540 |
| 1019 |
# address-family ipv4 unicast |
| 1020 |
# multipath |
| 1021 |
# capability orf prefix both |
| 1022 |
# default-originate |
| 1023 |
|
| 1024 |
- name: Parse externally provided BGP neighbor AF config |
| 1025 |
cisco.iosxr.iosxr_bgp_neighbor_address_family: |
| 1026 |
running_config: "{{ lookup('file', 'parsed.cfg') }}" |
| 1027 |
state: parsed |
| 1028 |
# Task output (redacted) |
| 1029 |
# ----------------------- |
| 1030 |
# parsed: |
| 1031 |
# as_number: 65536 |
| 1032 |
# neighbors: |
| 1033 |
# - neighbor_address: 192.0.2.2 |
| 1034 |
# address_family: |
| 1035 |
# - afi: "ipv4" |
| 1036 |
# safi: "unicast" |
| 1037 |
# multipath: true |
| 1038 |
# default_originate: |
| 1039 |
# set: true |
| 1040 |
# weight: 5 |
| 1041 |
# - neighbor_address: 192.0.2.3 |
| 1042 |
# address_family: |
| 1043 |
# - afi: "ipv4" |
| 1044 |
# safi: "unicast" |
| 1045 |
# multipath: true |
| 1046 |
# default_originate: |
| 1047 |
# set: true |
| 1048 |
# weight: 4 |
| 1049 |
# vrfs: |
| 1050 |
# - vrf: vrf1 |
| 1051 |
# neighbors: |
| 1052 |
# - neighbor_address: 192.0.2.4 |
| 1053 |
# address_family: |
| 1054 |
# - afi: "ipv4" |
| 1055 |
# safi: "unicast" |
| 1056 |
# multipath: true |
| 1057 |
# default_originate: |
| 1058 |
# set: true |
| 1059 |
# capability_orf_prefix: both |
| 1060 |
# - vrf: vrf2 |
| 1061 |
# neighbors: |
| 1062 |
# - neighbor_address: 192.0.2.5 |
| 1063 |
# address_family: |
| 1064 |
# - afi: "ipv4" |
| 1065 |
# safi: "unicast" |
| 1066 |
# multipath: true |
| 1067 |
# default_originate: |
| 1068 |
# set: true |
| 1069 |
# capability_orf_prefix: both |
| 1070 |
# |
| 1071 |
# |
| 1072 |
# Using Gathered |
| 1073 |
# ----------------- |
| 1074 |
# Before state state: |
| 1075 |
# ------------- |
| 1076 |
# RP/0/0/CPU0:iosxr-02#show running-config router bgp |
| 1077 |
# Sat Feb 20 03:49:43.618 UTC |
| 1078 |
# router bgp 65536 |
| 1079 |
# bgp router-id 192.0.1.1 |
| 1080 |
# address-family ipv4 unicast |
| 1081 |
# address-family vpnv4 unicast |
| 1082 |
# neighbor 192.0.2.2 |
| 1083 |
# remote-as 65537 |
| 1084 |
# address-family ipv4 unicast |
| 1085 |
# multipath |
| 1086 |
# weight 5 |
| 1087 |
# default-originate |
| 1088 |
# neighbor 1.1.1.2 |
| 1089 |
# remote-as 65538 |
| 1090 |
# address-family ipv4 unicast |
| 1091 |
# multipath |
| 1092 |
# weight 5 |
| 1093 |
# default-originate |
| 1094 |
# vrf vrf1 |
| 1095 |
# rd auto |
| 1096 |
# neighbor 192.0.2.4 |
| 1097 |
# remote-as 65539 |
| 1098 |
# address-family ipv4 unicast |
| 1099 |
# multipath |
| 1100 |
# capability orf prefix both |
| 1101 |
# default-originate |
| 1102 |
# vrf vrf2 |
| 1103 |
# rd auto |
| 1104 |
# neighbor 192.0.2.5 |
| 1105 |
# remote-as 65540 |
| 1106 |
# address-family ipv4 unicast |
| 1107 |
# multipath |
| 1108 |
# capability orf prefix both |
| 1109 |
# default-originate |
| 1110 |
# |
| 1111 |
# |
| 1112 |
# |
| 1113 |
- name: Gathered the provided configuration with the existing running configuration |
| 1114 |
cisco.iosxr.iosxr_bgp_neighbor_address_family: |
| 1115 |
config: |
| 1116 |
state: gathered |
| 1117 |
|
| 1118 |
|
| 1119 |
# Task output |
| 1120 |
# ----------------------- |
| 1121 |
# gathered: |
| 1122 |
# as_number: 65536 |
| 1123 |
# neighbors: |
| 1124 |
# - neighbor_address: 192.0.2.2 |
| 1125 |
# address_family: |
| 1126 |
# - afi: "ipv4" |
| 1127 |
# safi: "unicast" |
| 1128 |
# multipath: true |
| 1129 |
# default_originate: |
| 1130 |
# set: true |
| 1131 |
# weight: 5 |
| 1132 |
# - neighbor_address: 192.0.2.3 |
| 1133 |
# address_family: |
| 1134 |
# - afi: "ipv4" |
| 1135 |
# safi: "unicast" |
| 1136 |
# multipath: true |
| 1137 |
# default_originate: |
| 1138 |
# set: true |
| 1139 |
# weight: 4 |
| 1140 |
# vrfs: |
| 1141 |
# - vrf: vrf1 |
| 1142 |
# neighbors: |
| 1143 |
# - neighbor_address: 192.0.2.4 |
| 1144 |
# address_family: |
| 1145 |
# - afi: "ipv4" |
| 1146 |
# safi: "unicast" |
| 1147 |
# multipath: true |
| 1148 |
# default_originate: |
| 1149 |
# set: true |
| 1150 |
# capability_orf_prefix: both |
| 1151 |
# - vrf: vrf2 |
| 1152 |
# neighbors: |
| 1153 |
# - neighbor_address: 192.0.2.5 |
| 1154 |
# address_family: |
| 1155 |
# - afi: "ipv4" |
| 1156 |
# safi: "unicast" |
| 1157 |
# multipath: true |
| 1158 |
# default_originate: |
| 1159 |
# set: true |
| 1160 |
# capability_orf_prefix: both |
| 1161 |
# |
| 1162 |
""" |
| 1163 |
|
| 1164 |
from ansible.module_utils.basic import AnsibleModule |
| 1165 |
|
| 1166 |
from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.argspec.bgp_neighbor_address_family.bgp_neighbor_address_family import ( |
| 1167 |
Bgp_neighbor_address_familyArgs, |
| 1168 |
) |
| 1169 |
from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.config.bgp_neighbor_address_family.bgp_neighbor_address_family import ( |
| 1170 |
Bgp_neighbor_address_family, |
| 1171 |
) |
| 1172 |
|
| 1173 |
|
| 1174 |
def main(): |
| 1175 |
""" |
| 1176 |
Main entry point for module execution |
| 1177 |
|
| 1178 |
:returns: the result form module invocation |
| 1179 |
""" |
| 1180 |
module = AnsibleModule( |
| 1181 |
argument_spec=Bgp_neighbor_address_familyArgs.argument_spec, |
| 1182 |
mutually_exclusive=[["config", "running_config"]], |
| 1183 |
required_if=[ |
| 1184 |
["state", "merged", ["config"]], |
| 1185 |
["state", "replaced", ["config"]], |
| 1186 |
["state", "overridden", ["config"]], |
| 1187 |
["state", "rendered", ["config"]], |
| 1188 |
["state", "parsed", ["running_config"]], |
| 1189 |
], |
| 1190 |
supports_check_mode=True, |
| 1191 |
) |
| 1192 |
|
| 1193 |
result = Bgp_neighbor_address_family(module).execute_module() |
| 1194 |
module.exit_json(**result) |
| 1195 |
|
| 1196 |
|
| 1197 |
if __name__ == "__main__": |
| 1198 |
main() |