mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Rel240/fix nxos interface ospf (#28898)
* Fixes 28897 nxos_interface_ospf idempotence * Handle all characters upper or lower with tests
This commit is contained in:
parent
ae2e84146e
commit
fb1aa54341
2 changed files with 126 additions and 2 deletions
|
@ -394,7 +394,15 @@ def main():
|
|||
'message_digest_password']],
|
||||
supports_check_mode=True)
|
||||
|
||||
if not module.params['interface'].startswith('loopback') and not module.params['interface'].startswith('port-channel'):
|
||||
# Normalize interface input data.
|
||||
#
|
||||
# * For port-channel and loopback interfaces expection is all lower case names.
|
||||
# * All other interfaces the expectation is an uppercase leading character
|
||||
# followed by lower case characters.
|
||||
#
|
||||
if re.match(r'(port-channel|loopback)', module.params['interface'], re.I):
|
||||
module.params['interface'] = module.params['interface'].lower()
|
||||
else:
|
||||
module.params['interface'] = module.params['interface'].capitalize()
|
||||
|
||||
warnings = list()
|
||||
|
|
|
@ -33,10 +33,20 @@
|
|||
provider: "{{ connection }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Remove possibly existing port-channel and loopback ints"
|
||||
nxos_config: &removepcandlb
|
||||
commands:
|
||||
- no interface port-channel10
|
||||
- no interface port-channel11
|
||||
- no interface loopback55
|
||||
- no interface loopback77
|
||||
provider: "{{ connection }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- block:
|
||||
- name: configure ospf interface
|
||||
nxos_interface_ospf: &configure
|
||||
interface: "{{ testint }}"
|
||||
interface: "{{ nxos_int1|upper }}"
|
||||
ospf: 1
|
||||
area: 1
|
||||
cost: 55
|
||||
|
@ -80,6 +90,109 @@
|
|||
|
||||
- assert: *false
|
||||
|
||||
- name: create port-channel and loopback interfaces
|
||||
nxos_config:
|
||||
commands:
|
||||
- interface port-channel10
|
||||
- interface port-channel11
|
||||
- interface loopback55
|
||||
- interface loopback77
|
||||
match: none
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- name: "Ensure port-channels are layer3"
|
||||
nxos_config:
|
||||
commands:
|
||||
- no switchport
|
||||
parents:
|
||||
- "interface {{ item }}"
|
||||
provider: "{{ connection }}"
|
||||
with_items:
|
||||
- port-channel10
|
||||
- port-channel11
|
||||
|
||||
- name: configure ospf interface port-channel10
|
||||
nxos_interface_ospf: &configurepc
|
||||
interface: Port-channel10
|
||||
ospf: 1
|
||||
area: 1
|
||||
cost: 55
|
||||
passive_interface: true
|
||||
hello_interval: 15
|
||||
dead_interval: 75
|
||||
state: present
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: "Check Idempotence for port-channel10"
|
||||
nxos_interface_ospf: *configurepc
|
||||
register: result
|
||||
|
||||
- assert: *false
|
||||
|
||||
- name: configure ospf interface port-channel11 using lower case name
|
||||
nxos_interface_ospf: &configurepclower
|
||||
interface: port-channel11
|
||||
ospf: 1
|
||||
area: 1
|
||||
cost: 55
|
||||
passive_interface: true
|
||||
hello_interval: 15
|
||||
dead_interval: 75
|
||||
state: present
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: "Check Idempotence for port-channel11"
|
||||
nxos_interface_ospf: *configurepclower
|
||||
register: result
|
||||
|
||||
- assert: *false
|
||||
|
||||
- name: configure ospf interface loopback55
|
||||
nxos_interface_ospf: &configurelb
|
||||
interface: LOOPBACK55
|
||||
ospf: 1
|
||||
area: 1
|
||||
cost: 55
|
||||
hello_interval: 15
|
||||
dead_interval: 75
|
||||
state: present
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: "Check Idempotence for loopback55"
|
||||
nxos_interface_ospf: *configurelb
|
||||
register: result
|
||||
|
||||
- assert: *false
|
||||
|
||||
- name: configure ospf interface loopback77 using lower case name
|
||||
nxos_interface_ospf: &configurelblower
|
||||
interface: loopback77
|
||||
ospf: 1
|
||||
area: 1
|
||||
cost: 77
|
||||
hello_interval: 45
|
||||
dead_interval: 75
|
||||
state: present
|
||||
provider: "{{ connection }}"
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: "Check Idempotence for loopback77"
|
||||
nxos_interface_ospf: *configurelblower
|
||||
register: result
|
||||
|
||||
- assert: *false
|
||||
|
||||
- name: remove ospf interface config
|
||||
nxos_interface_ospf: &removeconfig
|
||||
interface: "{{ testint }}"
|
||||
|
@ -115,5 +228,8 @@
|
|||
- name: "Interface cleanup"
|
||||
nxos_config: *intdefault
|
||||
|
||||
- name: "Remove port-channel and loopback ints"
|
||||
nxos_config: *removepcandlb
|
||||
|
||||
always:
|
||||
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_interface_ospf sanity test"
|
||||
|
|
Loading…
Reference in a new issue