ansible/test/integration/targets/eos_vlan/tests/cli/basic.yaml
Ganesh Nalawade d60eac9bc4
Decouple config and state check in vlan and vrf network modules (#36386) (#36704)
* Decouple config and state check in {network_os }_vlan and { network_os }_vrf modules

Fixes #35567
Fixes #34754

`interfaces` option is used for configuration as well as operational state
check. If interface is configured to given vlan or vrf but if
operational state of interface is disabled it results in module failure.

Fix is to decouple same option usage for config and state.
With this fix `interfaces` is used as config option and a new
option named `associated_interfaces` will be used for intent check
for assigned interfaces.

* Fix CI failures

* Fix review comment

* Fixed integration test failure

(cherry picked from commit 5a6b893240)
2018-02-26 10:16:39 +05:30

299 lines
7.4 KiB
YAML

---
- name: setup - remove vlans used in test
eos_config:
lines:
- no vlan 4000
- no vlan 4001
- no vlan 4002
authorize: yes
provider: "{{ cli }}"
become: yes
- 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 }}"
become: yes
- name: setup - remove switchport settings on interface Ethernet2 used in test
eos_config:
lines:
- switchport
- no switchport access vlan 4000
parents: interface Ethernet2
authorize: yes
provider: "{{ cli }}"
become: yes
- name: Create vlan
eos_vlan:
vlan_id: 4000
name: vlan-4000
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
that:
- "result.changed == true"
- "'vlan 4000' in result.commands"
- "'name vlan-4000' in result.commands"
# 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
name: vlan-4000
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
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
name: vlan-4000-new
state: suspend
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
that:
- "result.changed == true"
- "'vlan 4000' in result.commands"
- "'name vlan-4000-new' in result.commands"
- "'state suspend' in result.commands"
# Ensure sessions contains epoc. Will fail after 18th May 2033
- "'ansible_1' in result.session_name"
- name: Change vlan name and state again (idempotent)
eos_vlan:
vlan_id: 4000
name: vlan-4000-new
state: suspend
authorize: yes
provider: "{{ cli }}"
become: yes
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 }}"
become: yes
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"
- name: Add interfaces to vlan and check state
eos_vlan:
vlan_id: 4000
state: present
interfaces:
- Ethernet1
- Ethernet2
associated_interfaces:
- Ethernet1
- Ethernet2
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
that:
- "result.changed == true"
- "'vlan 4000' in result.commands"
- "'interface ethernet1' in result.commands"
- "'switchport access vlan 4000' in result.commands"
- "'interface ethernet2' in result.commands"
- "'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:
- ethernet 1 # interface name modified to test case insensitive and space scenario
- ethernet 2 # interface name modified to test case insensitive and space scenario
authorize: yes
provider: "{{ cli }}"
become: yes
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: 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"
- name: Remove interface from vlan
eos_vlan:
vlan_id: 4000
state: present
interfaces:
- Ethernet1
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
that:
- "result.changed == true"
- "'vlan 4000' in result.commands"
- "'interface ethernet2' in result.commands"
- "'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:
- ethernet 1 # interface name modified to handle case insensitive and space scenario
authorize: yes
provider: "{{ cli }}"
become: yes
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 }}"
become: yes
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 }}"
become: yes
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 }}"
become: yes
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 }}"
become: yes
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"
# FIXME add in tests for everything defined in docs
# FIXME Test state:absent + test:
# FIXME Without powers ensure "privileged mode required"