2017-10-26 15:27:55 +00:00
|
|
|
---
|
2018-01-05 17:39:04 +00:00
|
|
|
- debug: msg="START connection={{ ansible_connection }} nxos_hsrp sanity test"
|
|
|
|
- debug: msg="Using provider={{ connection.transport }}"
|
|
|
|
when: ansible_connection == "local"
|
2017-10-26 15:27:55 +00:00
|
|
|
|
|
|
|
# Select interface for test
|
2018-04-10 05:51:41 +00:00
|
|
|
- set_fact: intname1="{{ nxos_int1 }}"
|
|
|
|
- set_fact: intname2="{{ nxos_int2 }}"
|
2017-10-26 15:27:55 +00:00
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: "Enable feature hsrp"
|
|
|
|
nxos_feature:
|
|
|
|
feature: hsrp
|
|
|
|
state: enabled
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
|
2018-04-10 05:51:41 +00:00
|
|
|
- name: "change int1 mode"
|
2017-10-26 15:27:55 +00:00
|
|
|
nxos_config:
|
|
|
|
commands:
|
|
|
|
- no switchport
|
|
|
|
parents:
|
2018-04-10 05:51:41 +00:00
|
|
|
- "interface {{ intname1 }}"
|
|
|
|
match: none
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
|
|
|
|
- name: "change int2 mode"
|
|
|
|
nxos_config:
|
|
|
|
commands:
|
|
|
|
- no switchport
|
|
|
|
parents:
|
|
|
|
- "interface {{ intname2 }}"
|
2017-10-26 15:27:55 +00:00
|
|
|
match: none
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
|
|
|
|
- name: "configure nxos_hsrp"
|
2018-04-10 05:51:41 +00:00
|
|
|
nxos_hsrp: &conf1000
|
|
|
|
group: 1000
|
2017-10-26 15:27:55 +00:00
|
|
|
version: 2
|
|
|
|
vip: 10.1.1.1
|
|
|
|
priority: 150
|
2018-04-10 05:51:41 +00:00
|
|
|
interface: "{{ intname1 }}"
|
2017-10-26 15:27:55 +00:00
|
|
|
preempt: enabled
|
2018-04-10 05:51:41 +00:00
|
|
|
auth_type: md5
|
|
|
|
auth_string: "7 1234"
|
2017-10-26 15:27:55 +00:00
|
|
|
provider: "{{ connection }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: &true
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
|
|
|
|
- name: "Conf Idempotence"
|
2018-04-10 05:51:41 +00:00
|
|
|
nxos_hsrp: *conf1000
|
2017-10-26 15:27:55 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: &false
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
|
2018-04-10 05:51:41 +00:00
|
|
|
- name: "configure group 100"
|
|
|
|
nxos_hsrp: &conf100
|
|
|
|
group: 100
|
2017-10-26 15:27:55 +00:00
|
|
|
version: 2
|
2018-04-10 05:51:41 +00:00
|
|
|
vip: 2.2.2.2
|
|
|
|
priority: 25
|
|
|
|
interface: "{{ intname1 }}"
|
2017-10-26 15:27:55 +00:00
|
|
|
preempt: enabled
|
2018-04-10 05:51:41 +00:00
|
|
|
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: 3.3.3.3
|
|
|
|
version: 1
|
|
|
|
interface: "{{ intname2 }}"
|
2017-10-26 15:27:55 +00:00
|
|
|
auth_type: text
|
2018-04-10 05:51:41 +00:00
|
|
|
auth_string: "1234"
|
2017-10-26 15:27:55 +00:00
|
|
|
provider: "{{ connection }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
2018-04-10 05:51:41 +00:00
|
|
|
- name: "Conf Idempotence"
|
|
|
|
nxos_hsrp: *conf200
|
2017-10-26 15:27:55 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
|
|
|
|
2018-04-10 05:51:41 +00:00
|
|
|
- name: "change group 200"
|
|
|
|
nxos_hsrp: &chg200
|
|
|
|
group: 200
|
|
|
|
vip: 3.3.3.3
|
2017-10-26 15:27:55 +00:00
|
|
|
version: 2
|
2018-04-10 05:51:41 +00:00
|
|
|
interface: "{{ intname2 }}"
|
2017-10-26 15:27:55 +00:00
|
|
|
auth_type: text
|
2018-04-10 05:51:41 +00:00
|
|
|
auth_string: default
|
2017-10-26 15:27:55 +00:00
|
|
|
provider: "{{ connection }}"
|
2018-04-10 05:51:41 +00:00
|
|
|
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 }}"
|
2017-10-26 15:27:55 +00:00
|
|
|
state: absent
|
2018-04-10 05:51:41 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Remove Idempotence"
|
|
|
|
nxos_hsrp: *remove
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
2017-10-26 15:27:55 +00:00
|
|
|
|
2018-04-10 05:51:41 +00:00
|
|
|
always:
|
2017-10-26 15:27:55 +00:00
|
|
|
- name: "Disable feature hsrp"
|
|
|
|
nxos_feature:
|
|
|
|
feature: hsrp
|
|
|
|
state: disabled
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
ignore_errors: yes
|
|
|
|
|
2018-01-05 17:39:04 +00:00
|
|
|
- debug: msg="END connection={{ ansible_connection }} nxos_hsrp sanity test"
|