2017-08-07 19:54:31 +02:00
|
|
|
---
|
2018-01-05 18:39:04 +01:00
|
|
|
- debug: msg="START connection={{ ansible_connection }} nxos_interface_ospf sanity test"
|
|
|
|
- debug: msg="Using provider={{ connection.transport }}"
|
|
|
|
when: ansible_connection == "local"
|
2017-08-07 19:54:31 +02:00
|
|
|
|
|
|
|
- set_fact: testint="{{ nxos_int1 }}"
|
|
|
|
|
|
|
|
- name: "Setup - Disable feature OSPF"
|
|
|
|
nxos_feature: &disable
|
|
|
|
feature: ospf
|
|
|
|
state: disabled
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: "Setup - Enable feature OSPF"
|
|
|
|
nxos_feature: &enable
|
|
|
|
feature: ospf
|
|
|
|
state: enabled
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: "Put interface into default state"
|
|
|
|
nxos_config: &intdefault
|
|
|
|
lines:
|
|
|
|
- "default interface {{ testint }}"
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: "Remove switchport config"
|
|
|
|
nxos_config: &removeswitchport
|
|
|
|
commands:
|
|
|
|
- no switchport
|
|
|
|
parents:
|
|
|
|
- "interface {{ testint }}"
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
ignore_errors: yes
|
|
|
|
|
2017-09-01 17:07:18 +02:00
|
|
|
- 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
|
|
|
|
|
2017-08-07 19:54:31 +02:00
|
|
|
- block:
|
|
|
|
- name: configure ospf interface
|
|
|
|
nxos_interface_ospf: &configure
|
2017-09-01 17:07:18 +02:00
|
|
|
interface: "{{ nxos_int1|upper }}"
|
2017-08-07 19:54:31 +02:00
|
|
|
ospf: 1
|
2018-02-13 04:57:22 +01:00
|
|
|
area: 12345678
|
2017-08-07 19:54:31 +02:00
|
|
|
cost: 55
|
|
|
|
passive_interface: true
|
|
|
|
hello_interval: 15
|
|
|
|
dead_interval: 75
|
|
|
|
state: present
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: &true
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
|
|
|
|
- name: "Check Idempotence"
|
|
|
|
nxos_interface_ospf: *configure
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: &false
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
|
|
|
|
- name: Modify properties
|
|
|
|
nxos_interface_ospf: &modify
|
|
|
|
interface: "{{ testint }}"
|
|
|
|
ospf: 1
|
2018-02-13 04:57:22 +01:00
|
|
|
area: 12345678
|
2017-08-07 19:54:31 +02:00
|
|
|
cost: 66
|
|
|
|
passive_interface: false
|
|
|
|
hello_interval: 17
|
|
|
|
dead_interval: 70
|
|
|
|
state: present
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Check Idempotence"
|
|
|
|
nxos_interface_ospf: *modify
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
|
|
|
|
2018-02-13 04:57:22 +01:00
|
|
|
- name: default properties
|
|
|
|
nxos_interface_ospf: &def
|
|
|
|
interface: "{{ testint }}"
|
|
|
|
ospf: 1
|
|
|
|
area: 12345678
|
|
|
|
cost: default
|
|
|
|
hello_interval: 10
|
|
|
|
dead_interval: default
|
|
|
|
state: present
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Check Idempotence"
|
|
|
|
nxos_interface_ospf: *def
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
|
|
|
|
|
|
|
- name: Message_digest properties
|
|
|
|
nxos_interface_ospf: &md
|
|
|
|
interface: "{{ testint }}"
|
|
|
|
ospf: 1
|
|
|
|
area: 12345678
|
|
|
|
message_digest: True
|
|
|
|
message_digest_key_id: 10
|
|
|
|
message_digest_algorithm_type: md5
|
|
|
|
message_digest_encryption_type: 3des
|
|
|
|
message_digest_password: b69f7bc54725b1bfd1ea93afa7b09400
|
|
|
|
state: present
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Check Idempotence"
|
|
|
|
nxos_interface_ospf: *md
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
|
|
|
|
|
|
|
- name: Message_digest defaults
|
|
|
|
nxos_interface_ospf: &mdd
|
|
|
|
interface: "{{ testint }}"
|
|
|
|
ospf: 1
|
|
|
|
area: 12345678
|
|
|
|
message_digest: False
|
|
|
|
message_digest_key_id: default
|
|
|
|
message_digest_algorithm_type: default
|
|
|
|
message_digest_encryption_type: default
|
|
|
|
message_digest_password: default
|
|
|
|
state: present
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Check Idempotence"
|
|
|
|
nxos_interface_ospf: *mdd
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
|
|
|
|
2017-09-01 17:07:18 +02:00
|
|
|
- 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
|
2018-02-13 04:57:22 +01:00
|
|
|
area: 429496729
|
2017-09-01 17:07:18 +02:00
|
|
|
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
|
2018-02-13 04:57:22 +01:00
|
|
|
area: 42949672
|
2017-09-01 17:07:18 +02:00
|
|
|
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
|
2018-02-13 04:57:22 +01:00
|
|
|
area: 4.4.4.4
|
2017-09-01 17:07:18 +02:00
|
|
|
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
|
2018-02-13 04:57:22 +01:00
|
|
|
area: 429496
|
2017-09-01 17:07:18 +02:00
|
|
|
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
|
|
|
|
|
2017-08-07 19:54:31 +02:00
|
|
|
- name: remove ospf interface config
|
|
|
|
nxos_interface_ospf: &removeconfig
|
|
|
|
interface: "{{ testint }}"
|
|
|
|
ospf: 1
|
2018-02-13 04:57:22 +01:00
|
|
|
area: 12345678
|
2017-08-07 19:54:31 +02:00
|
|
|
cost: 55
|
|
|
|
passive_interface: true
|
|
|
|
hello_interval: 15
|
|
|
|
dead_interval: 75
|
|
|
|
state: absent
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Check Idempotence"
|
|
|
|
nxos_interface_ospf: *removeconfig
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
|
|
|
|
|
|
|
- name: "Disable feature OSPF"
|
|
|
|
nxos_feature: *disable
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: "Interface cleanup"
|
|
|
|
nxos_config: *intdefault
|
|
|
|
|
|
|
|
rescue:
|
|
|
|
- name: "Disable feature OSPF"
|
|
|
|
nxos_feature: *disable
|
|
|
|
|
|
|
|
- name: "Interface cleanup"
|
|
|
|
nxos_config: *intdefault
|
|
|
|
|
2017-09-01 17:07:18 +02:00
|
|
|
- name: "Remove port-channel and loopback ints"
|
|
|
|
nxos_config: *removepcandlb
|
|
|
|
|
2017-08-07 19:54:31 +02:00
|
|
|
always:
|
2018-01-05 18:39:04 +01:00
|
|
|
- debug: msg="END connection={{ ansible_connection }} nxos_interface_ospf sanity test"
|