2017-06-07 21:47:28 +00:00
|
|
|
---
|
|
|
|
|
2017-08-17 07:45:50 +00:00
|
|
|
- name: setup - remove vlans used in test
|
|
|
|
eos_config:
|
|
|
|
lines:
|
|
|
|
- no vlan 4000
|
|
|
|
- no vlan 4001
|
|
|
|
- no vlan 4002
|
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 20:49:49 +00:00
|
|
|
become: yes
|
2017-08-17 07:45:50 +00:00
|
|
|
|
|
|
|
- name: setup - remove switchport settings on interface Ethernet1 used in test
|
|
|
|
eos_config:
|
|
|
|
lines:
|
|
|
|
- switchport
|
|
|
|
- no switchport access vlan 4000
|
|
|
|
parents: interface Ethernet1
|
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 20:49:49 +00:00
|
|
|
become: yes
|
2017-08-17 07:45:50 +00:00
|
|
|
|
|
|
|
- name: setup - remove switchport settings on interface Ethernet2 used in test
|
|
|
|
eos_config:
|
|
|
|
lines:
|
|
|
|
- switchport
|
|
|
|
- no switchport access vlan 4000
|
|
|
|
parents: interface Ethernet2
|
2017-06-07 21:47:28 +00:00
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 20:49:49 +00:00
|
|
|
become: yes
|
2017-06-07 21:47:28 +00:00
|
|
|
|
|
|
|
- name: Create vlan
|
|
|
|
eos_vlan:
|
|
|
|
vlan_id: 4000
|
2017-08-17 07:45:50 +00:00
|
|
|
name: vlan-4000
|
2017-06-07 21:47:28 +00:00
|
|
|
state: present
|
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 20:49:49 +00:00
|
|
|
become: yes
|
2017-06-07 21:47:28 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
- "'vlan 4000' in result.commands"
|
2017-08-17 07:45:50 +00:00
|
|
|
- "'name vlan-4000' in result.commands"
|
2017-06-07 21:47:28 +00:00
|
|
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
|
|
|
- "'ansible_1' in result.session_name"
|
|
|
|
|
|
|
|
- name: Create vlan again (idempotent)
|
|
|
|
eos_vlan:
|
|
|
|
vlan_id: 4000
|
2017-08-17 07:45:50 +00:00
|
|
|
name: vlan-4000
|
2017-06-07 21:47:28 +00:00
|
|
|
state: present
|
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 20:49:49 +00:00
|
|
|
become: yes
|
2017-06-07 21:47:28 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
- "result.commands | length == 0"
|
|
|
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
|
|
|
- "result.session_name is not defined"
|
|
|
|
|
|
|
|
- name: Change vlan name and state
|
|
|
|
eos_vlan:
|
|
|
|
vlan_id: 4000
|
2017-08-17 07:45:50 +00:00
|
|
|
name: vlan-4000-new
|
2017-06-07 21:47:28 +00:00
|
|
|
state: suspend
|
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 20:49:49 +00:00
|
|
|
become: yes
|
2017-06-07 21:47:28 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
- "'vlan 4000' in result.commands"
|
2017-08-17 07:45:50 +00:00
|
|
|
- "'name vlan-4000-new' in result.commands"
|
2017-06-07 21:47:28 +00:00
|
|
|
- "'state suspend' in result.commands"
|
|
|
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
|
|
|
- "'ansible_1' in result.session_name"
|
|
|
|
|
2017-08-17 07:45:50 +00:00
|
|
|
- name: Change vlan name and state again (idempotent)
|
|
|
|
eos_vlan:
|
|
|
|
vlan_id: 4000
|
|
|
|
name: vlan-4000-new
|
|
|
|
state: suspend
|
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 20:49:49 +00:00
|
|
|
become: yes
|
2017-08-17 07:45:50 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
- "result.commands | length == 0"
|
|
|
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
|
|
|
- "result.session_name is not defined"
|
|
|
|
|
|
|
|
- name: Unsuspend vlan
|
|
|
|
eos_vlan:
|
|
|
|
vlan_id: 4000
|
|
|
|
state: active
|
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 20:49:49 +00:00
|
|
|
become: yes
|
2017-08-17 07:45:50 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
- "'vlan 4000' in result.commands"
|
|
|
|
- "'state active' in result.commands"
|
|
|
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
|
|
|
- "'ansible_1' in result.session_name"
|
|
|
|
|
2018-02-26 04:46:39 +00:00
|
|
|
- name: Add interfaces to vlan and check state
|
2017-08-17 07:45:50 +00:00
|
|
|
eos_vlan:
|
|
|
|
vlan_id: 4000
|
|
|
|
state: present
|
|
|
|
interfaces:
|
|
|
|
- Ethernet1
|
|
|
|
- Ethernet2
|
2018-02-26 04:46:39 +00:00
|
|
|
associated_interfaces:
|
|
|
|
- Ethernet1
|
|
|
|
- Ethernet2
|
2017-08-17 07:45:50 +00:00
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 20:49:49 +00:00
|
|
|
become: yes
|
2017-08-17 07:45:50 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
- "'vlan 4000' in result.commands"
|
2018-01-16 12:16:14 +00:00
|
|
|
- "'interface ethernet1' in result.commands"
|
2017-08-17 07:45:50 +00:00
|
|
|
- "'switchport access vlan 4000' in result.commands"
|
2018-01-16 12:16:14 +00:00
|
|
|
- "'interface ethernet2' in result.commands"
|
2017-08-17 07:45:50 +00:00
|
|
|
- "'switchport access vlan 4000' in result.commands"
|
|
|
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
|
|
|
- "'ansible_1' in result.session_name"
|
|
|
|
|
|
|
|
- name: Add interfaces to vlan again (idempotent)
|
|
|
|
eos_vlan:
|
|
|
|
vlan_id: 4000
|
|
|
|
state: present
|
|
|
|
interfaces:
|
2018-01-16 12:16:14 +00:00
|
|
|
- ethernet 1 # interface name modified to test case insensitive and space scenario
|
|
|
|
- ethernet 2 # interface name modified to test case insensitive and space scenario
|
2017-08-17 07:45:50 +00:00
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 20:49:49 +00:00
|
|
|
become: yes
|
2017-08-17 07:45:50 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
- "result.commands | length == 0"
|
|
|
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
|
|
|
- "result.session_name is not defined"
|
|
|
|
|
2018-02-26 04:46:39 +00:00
|
|
|
- name: vlan interface intent fail
|
|
|
|
eos_vlan:
|
|
|
|
vlan_id: 4000
|
|
|
|
state: present
|
|
|
|
associated_interfaces:
|
|
|
|
- test
|
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
|
|
|
become: yes
|
|
|
|
register: result
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.failed == True"
|
|
|
|
|
2017-08-17 07:45:50 +00:00
|
|
|
- name: Remove interface from vlan
|
|
|
|
eos_vlan:
|
|
|
|
vlan_id: 4000
|
|
|
|
state: present
|
|
|
|
interfaces:
|
|
|
|
- Ethernet1
|
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 20:49:49 +00:00
|
|
|
become: yes
|
2017-08-17 07:45:50 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
- "'vlan 4000' in result.commands"
|
2018-01-16 12:16:14 +00:00
|
|
|
- "'interface ethernet2' in result.commands"
|
2017-08-17 07:45:50 +00:00
|
|
|
- "'no switchport access vlan 4000' in result.commands"
|
|
|
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
|
|
|
- "'ansible_1' in result.session_name"
|
|
|
|
|
|
|
|
- name: Remove interface from vlan again (idempotent)
|
|
|
|
eos_vlan:
|
|
|
|
vlan_id: 4000
|
|
|
|
state: present
|
|
|
|
interfaces:
|
2018-01-16 12:16:14 +00:00
|
|
|
- ethernet 1 # interface name modified to handle case insensitive and space scenario
|
2017-08-17 07:45:50 +00:00
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 20:49:49 +00:00
|
|
|
become: yes
|
2017-08-17 07:45:50 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
- "result.commands | length == 0"
|
|
|
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
|
|
|
- "result.session_name is not defined"
|
|
|
|
|
|
|
|
- name: Create aggregate of vlans
|
|
|
|
eos_vlan:
|
|
|
|
aggregate:
|
|
|
|
- {vlan_id: 4000, state: absent}
|
|
|
|
- {vlan_id: 4001, name: vlan-4001}
|
|
|
|
state: present
|
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 20:49:49 +00:00
|
|
|
become: yes
|
2017-08-17 07:45:50 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
- "'no vlan 4000' in result.commands"
|
|
|
|
- "'vlan 4001' in result.commands"
|
|
|
|
- "'name vlan-4001' in result.commands"
|
|
|
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
|
|
|
- "'ansible_1' in result.session_name"
|
|
|
|
|
|
|
|
- name: Create aggregate of vlans again (idempotent)
|
|
|
|
eos_vlan:
|
|
|
|
aggregate:
|
|
|
|
- {vlan_id: 4000, state: absent}
|
|
|
|
- {vlan_id: 4001, name: vlan-4001}
|
|
|
|
state: present
|
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 20:49:49 +00:00
|
|
|
become: yes
|
2017-08-17 07:45:50 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
- "result.commands | length == 0"
|
|
|
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
|
|
|
- "result.session_name is not defined"
|
|
|
|
|
|
|
|
- name: Create vlan with purge
|
|
|
|
eos_vlan:
|
|
|
|
aggregate:
|
|
|
|
- {vlan_id: 4002, name: vlan-4002}
|
|
|
|
name: vlan-4002
|
|
|
|
state: present
|
|
|
|
purge: yes
|
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 20:49:49 +00:00
|
|
|
become: yes
|
2017-08-17 07:45:50 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
- "'no vlan 4001' in result.commands"
|
|
|
|
- "'vlan 4002' in result.commands"
|
|
|
|
- "'name vlan-4002' in result.commands"
|
|
|
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
|
|
|
- "'ansible_1' in result.session_name"
|
|
|
|
|
|
|
|
- name: Create vlan with purge
|
|
|
|
eos_vlan:
|
|
|
|
aggregate:
|
|
|
|
- {vlan_id: 4002, name: vlan-4002}
|
|
|
|
name: vlan-4002
|
|
|
|
state: present
|
|
|
|
purge: yes
|
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 20:49:49 +00:00
|
|
|
become: yes
|
2017-08-17 07:45:50 +00:00
|
|
|
register: result
|
2017-06-07 21:47:28 +00:00
|
|
|
|
2017-08-17 07:45:50 +00:00
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
- "result.commands | length == 0"
|
|
|
|
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
|
|
|
- "result.session_name is not defined"
|
2017-06-07 21:47:28 +00:00
|
|
|
# FIXME add in tests for everything defined in docs
|
|
|
|
# FIXME Test state:absent + test:
|
|
|
|
# FIXME Without powers ensure "privileged mode required"
|