Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions plugins/modules/aci_l3out_bgp_peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,19 @@
- Name of the Route Control Profile direction.
type: str
required: true
local_as_number_config:
description:
- The local Autonomous System Number (ASN) configuration of the L3Out BGP Peer.
- The APIC defaults to C(none) when unset during creation.
type: str
choices: [ dual-as, no-prepend, none, replace-as ]
aliases: [ local_as_num_config ]
local_as_number:
description:
- The local Autonomous System Number (ASN) of the L3Out BGP Peer.
- The APIC defaults to 0 when unset during creation.
type: int
aliases: [ local_as_num ]
state:
description:
- Use C(present) or C(absent) for adding or removing.
Expand Down Expand Up @@ -439,6 +452,8 @@ def main():
elements="dict",
options=route_control_profile_spec(),
),
local_as_number_config=dict(type="str", choices=["dual-as", "no-prepend", "none", "replace-as"], aliases=["local_as_num_config"]),
local_as_number=dict(type="int", aliases=["local_as_num"]),
)

module = AnsibleModule(
Expand Down Expand Up @@ -470,6 +485,8 @@ def main():
admin_state = module.params.get("admin_state")
allow_self_as_count = module.params.get("allow_self_as_count")
route_control_profiles = module.params.get("route_control_profiles")
local_as_number_config = module.params.get("local_as_number_config")
local_as_number = module.params.get("local_as_number")

aci = ACIModule(module)
if node_id:
Expand All @@ -492,6 +509,15 @@ def main():
)
)

if local_as_number_config or local_as_number:
child_configs.append(
dict(
bgpLocalAsnP=dict(
attributes=dict(asnPropagate=local_as_number_config, localAsn=local_as_number),
),
)
)

if route_control_profiles:
child_classes.append("bgpRsPeerToProfile")
for profile in route_control_profiles:
Expand Down
19 changes: 15 additions & 4 deletions tests/integration/targets/aci_l3out_bgp_peer/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
address_type_controls:
- af-ucast
ttl: 2
local_as_number_config: "replace-as"
state: present
register: add_eth_bgp_peer
when: version.current.0.topSystem.attributes.version is version('4', '>=')
Expand Down Expand Up @@ -239,6 +240,8 @@
- add_eth_bgp_peer.current.0.bgpPeerP.attributes.peerCtrl == "bfd"
- add_eth_bgp_peer.current.0.bgpPeerP.attributes.ttl == "2"
- add_eth_bgp_peer.current.0.bgpPeerP.attributes.annotation == 'orchestrator:ansible'
- add_eth_bgp_peer.current.0.bgpPeerP.children.0.bgpLocalAsnP.attributes.asnPropagate == "replace-as"
- add_eth_bgp_peer.current.0.bgpPeerP.children.0.bgpLocalAsnP.attributes.localAsn == "0"
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: verify BGP peer has been created with correct attributes (version < 4)
Expand All @@ -255,7 +258,7 @@
- name: verify remote AS object has been created correctly
assert:
that:
- add_eth_bgp_peer.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65456"
- add_eth_bgp_peer.current.0.bgpPeerP.children.2.bgpAsP.attributes.asn == "65456"
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: verify remote AS object has been created correctly
Expand Down Expand Up @@ -340,7 +343,7 @@
- name: verify remote AS object is still correct (version >= 4)
assert:
that:
- add_eth_bgp_peer_again.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65456"
- add_eth_bgp_peer_again.current.0.bgpPeerP.children.2.bgpAsP.attributes.asn == "65456"
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: verify remote AS object his still correct (version < 4)
Expand Down Expand Up @@ -376,6 +379,8 @@
allow_self_as_count: 3
ttl: 4
admin_state: disabled
local_as_number: 101
local_as_number_config: "dual-as"
state: present
register: update_eth_bgp_peer
when: version.current.0.topSystem.attributes.version is version('4', '>=')
Expand Down Expand Up @@ -419,6 +424,8 @@
- update_eth_bgp_peer.current.0.bgpPeerP.attributes.ttl == "4"
- update_eth_bgp_peer.current.0.bgpPeerP.attributes.allowedSelfAsCnt == "3"
- update_eth_bgp_peer.current.0.bgpPeerP.attributes.privateASctrl == "remove-exclusive"
- update_eth_bgp_peer.current.0.bgpPeerP.children.0.bgpLocalAsnP.attributes.asnPropagate == "dual-as"
- update_eth_bgp_peer.current.0.bgpPeerP.children.0.bgpLocalAsnP.attributes.localAsn == "101"
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: verify BGP peer has been updated with correct attributes (version < 4)
Expand All @@ -437,7 +444,7 @@
- name: verify remote AS object has been updated correctly (version >= 4)
assert:
that:
- update_eth_bgp_peer.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65457"
- update_eth_bgp_peer.current.0.bgpPeerP.children.2.bgpAsP.attributes.asn == "65457"
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: verify remote AS object has been updated correctly (version < 4)
Expand Down Expand Up @@ -508,7 +515,7 @@
- name: verify BGP remote AS (version >= 4)
assert:
that:
- query_eth_bgp_peer.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65457"
- query_eth_bgp_peer.current.0.bgpPeerP.children.2.bgpAsP.attributes.asn == "65457"
when: version.current.0.topSystem.attributes.version is version('4', '>=')

- name: verify BGP remote AS (version < 4)
Expand Down Expand Up @@ -641,6 +648,8 @@
profile: "anstest_export"
direction: "export"
l3out: "anstest_l3out"
local_as_number_config: "dual-as"
local_as_number: 100
state: present
check_mode: true
register: cm_ln_rtctrl_present
Expand Down Expand Up @@ -668,6 +677,8 @@
- nm_ln_rtctrl_present.previous | length == 0
- nm_ln_rtctrl_present.current.0.bgpPeerP.attributes.addr == "192.168.50.3"
- nm_ln_rtctrl_present.current.0.bgpPeerP.children | length >= 2
- nm_ln_rtctrl_present.current.0.bgpPeerP.children.2.bgpLocalAsnP.attributes.asnPropagate == "dual-as"
- nm_ln_rtctrl_present.current.0.bgpPeerP.children.2.bgpLocalAsnP.attributes.localAsn == "100"

- name: Add BGP Peer to the Node Profile level (version >= 4) - normal mode - idempotency works
aci_l3out_bgp_peer:
Expand Down