|
|
|
---
|
|
|
|
- debug: msg="START connection={{ ansible_connection }} nxos_hsrp sanity test"
|
|
|
|
- debug: msg="Using provider={{ connection.transport }}"
|
|
|
|
when: ansible_connection == "local"
|
|
|
|
|
|
|
|
# Select interface for test
|
|
|
|
- set_fact: intname1="{{ nxos_int1 }}"
|
|
|
|
- set_fact: intname2="{{ nxos_int2 }}"
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: "Enable feature hsrp"
|
|
|
|
nxos_feature:
|
|
|
|
feature: hsrp
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
state: enabled
|
|
|
|
|
|
|
|
- name: "change int1 mode"
|
|
|
|
nxos_config:
|
|
|
|
commands:
|
|
|
|
- no switchport
|
|
|
|
parents:
|
|
|
|
- "interface {{ intname1 }}"
|
|
|
|
match: none
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
|
|
|
|
- name: "change int2 mode"
|
|
|
|
nxos_config:
|
|
|
|
commands:
|
|
|
|
- no switchport
|
|
|
|
parents:
|
|
|
|
- "interface {{ intname2 }}"
|
|
|
|
match: none
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
|
|
|
|
- name: "configure nxos_hsrp"
|
|
|
|
nxos_hsrp: &conf1000
|
|
|
|
group: 1000
|
|
|
|
version: 2
|
|
|
|
vip: 10.1.1.1
|
|
|
|
priority: 150
|
|
|
|
interface: "{{ intname1 }}"
|
|
|
|
preempt: enabled
|
|
|
|
auth_type: md5
|
|
|
|
auth_string: "7 1234"
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: &true
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
|
|
|
|
- name: "Conf Idempotence"
|
|
|
|
nxos_hsrp: *conf1000
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: &false
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
|
|
|
|
- name: "configure group 100"
|
|
|
|
nxos_hsrp: &conf100
|
|
|
|
group: 100
|
|
|
|
version: 2
|
|
|
|
vip: 192.0.2.2
|
|
|
|
priority: 25
|
|
|
|
interface: "{{ intname1 }}"
|
|
|
|
preempt: enabled
|
|
|
|
auth_type: md5
|
|
|
|
auth_string: "0 1234"
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Conf Idempotence"
|
|
|
|
nxos_hsrp: *conf100
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
|
|
|
|
|
|
|
- name: "change group 100"
|
|
|
|
nxos_hsrp: &chg100
|
|
|
|
group: 100
|
|
|
|
version: 2
|
|
|
|
vip: default
|
|
|
|
priority: default
|
|
|
|
interface: "{{ intname1 }}"
|
|
|
|
preempt: disabled
|
|
|
|
auth_type: md5
|
|
|
|
auth_string: "0 1234"
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Conf Idempotence"
|
|
|
|
nxos_hsrp: *chg100
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
|
|
|
|
|
|
|
- name: "configure group 200"
|
|
|
|
nxos_hsrp: &conf200
|
|
|
|
group: 200
|
|
|
|
vip: 192.0.2.3
|
|
|
|
version: 1
|
|
|
|
interface: "{{ intname2 }}"
|
|
|
|
auth_type: text
|
|
|
|
auth_string: "1234"
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Conf Idempotence"
|
|
|
|
nxos_hsrp: *conf200
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
|
|
|
|
|
|
|
- name: "change group 200"
|
|
|
|
nxos_hsrp: &chg200
|
|
|
|
group: 200
|
|
|
|
vip: 192.0.2.3
|
|
|
|
version: 2
|
|
|
|
interface: "{{ intname2 }}"
|
|
|
|
auth_type: text
|
|
|
|
auth_string: default
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Conf Idempotence"
|
|
|
|
nxos_hsrp: *chg200
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
|
|
|
|
|
|
|
- name: "remove nxos_hsrp"
|
|
|
|
nxos_hsrp: &remove
|
|
|
|
group: 1000
|
|
|
|
interface: "{{ intname1 }}"
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Remove Idempotence"
|
|
|
|
nxos_hsrp: *remove
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
|
|
|
|
|
|
|
always:
|
|
|
|
- name: "Disable feature hsrp"
|
|
|
|
nxos_feature:
|
|
|
|
feature: hsrp
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
state: disabled
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- debug: msg="END connection={{ ansible_connection }} nxos_hsrp sanity test"
|