261 lines
6.2 KiB
YAML
261 lines
6.2 KiB
YAML
---
|
|
- debug: msg="START eos_interface cli/basic.yaml on connection={{ ansible_connection }}"
|
|
|
|
- name: Set test interface
|
|
set_fact:
|
|
test_interface_1: ethernet1
|
|
test_interface_2: ethernet2
|
|
|
|
- name: Configure interface (setup)
|
|
eos_interface:
|
|
name: "{{ test_interface_1 }}"
|
|
description: test-interface-1
|
|
mtu: 1800
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
become: yes
|
|
register: result
|
|
|
|
- name: Configure interface
|
|
eos_interface:
|
|
name: "{{ test_interface_1 }}"
|
|
description: test-interface-initial
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
become: yes
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- '"interface {{ test_interface_1 }}" in result.commands'
|
|
- '"description test-interface-initial" in result.commands'
|
|
|
|
- name: Confgure interface (idempotent)
|
|
eos_interface:
|
|
name: "{{ test_interface_1 }}"
|
|
description: test-interface-initial
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
become: yes
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == false'
|
|
|
|
- name: Confgure interface parameters
|
|
eos_interface:
|
|
name: "{{ test_interface_1 }}"
|
|
description: test-interface
|
|
mtu: 2000
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
become: yes
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- '"interface {{ test_interface_1 }}" in result.commands'
|
|
- '"description test-interface" in result.commands'
|
|
- '"mtu 2000" in result.commands'
|
|
|
|
- name: Change interface parameters
|
|
eos_interface:
|
|
name: "{{ test_interface_1 }}"
|
|
description: test-interface-1
|
|
mtu: 1800
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
become: yes
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- '"interface {{ test_interface_1 }}" in result.commands'
|
|
- '"description test-interface-1" in result.commands'
|
|
- '"mtu 1800" in result.commands'
|
|
|
|
- name: Disable interface
|
|
eos_interface:
|
|
name: "{{ test_interface_1 }}"
|
|
enabled: False
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
become: yes
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- '"interface {{ test_interface_1 }}" in result.commands'
|
|
- '"shutdown" in result.commands'
|
|
|
|
- name: Enable interface
|
|
eos_interface:
|
|
name: "{{ test_interface_1 }}"
|
|
enabled: True
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
become: yes
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- '"interface {{ test_interface_1 }}" in result.commands'
|
|
- '"no shutdown" in result.commands'
|
|
|
|
- name: Confgure second interface (setup)
|
|
eos_interface:
|
|
name: "{{ test_interface_2 }}"
|
|
description: test-interface-initial
|
|
mtu: 1800
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
become: yes
|
|
register: result
|
|
|
|
- name: Add interface aggregate
|
|
eos_interface:
|
|
aggregate:
|
|
- { name: "{{ test_interface_1 }}", mtu: 2000, description: test-interface-1 }
|
|
- { name: "{{ test_interface_2 }}", mtu: 2000, description: test-interface-2 }
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
become: yes
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- '"interface {{ test_interface_1 }}" in result.commands'
|
|
- '"mtu 2000" in result.commands'
|
|
- '"interface {{ test_interface_2 }}" in result.commands'
|
|
- '"description test-interface-2" in result.commands'
|
|
- '"mtu 2000" in result.commands'
|
|
|
|
- name: Add interface aggregate (idempotent)
|
|
eos_interface:
|
|
aggregate:
|
|
- { name: "{{ test_interface_1 }}", mtu: 2000, description: test-interface-1 }
|
|
- { name: "{{ test_interface_2 }}", mtu: 2000, description: test-interface-2 }
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
become: yes
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == false'
|
|
|
|
- name: Disable interface aggregate
|
|
eos_interface:
|
|
aggregate:
|
|
- { name: "{{ test_interface_1 }}" }
|
|
- { name: "{{ test_interface_2 }}" }
|
|
enabled: False
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
become: yes
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- '"interface {{ test_interface_1 }}" in result.commands'
|
|
- '"shutdown" in result.commands'
|
|
- '"interface {{ test_interface_2 }}" in result.commands'
|
|
- '"shutdown" in result.commands'
|
|
|
|
- name: Enable interface aggregate
|
|
eos_interface:
|
|
aggregate:
|
|
- { name: "{{ test_interface_1 }}" }
|
|
- { name: "{{ test_interface_2 }}" }
|
|
enabled: True
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
become: yes
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- '"interface {{ test_interface_1 }}" in result.commands'
|
|
- '"no shutdown" in result.commands'
|
|
- '"interface {{ test_interface_2 }}" in result.commands'
|
|
- '"no shutdown" in result.commands'
|
|
|
|
- name: loopback interface setup
|
|
eos_interface:
|
|
aggregate:
|
|
- name: loopback9
|
|
- name: loopback10
|
|
state: absent
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
become: yes
|
|
|
|
- name: Create loopback interface aggregate
|
|
eos_interface:
|
|
aggregate:
|
|
- name: loopback9
|
|
- name: loopback10
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
become: yes
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- '"interface loopback9" in result.commands'
|
|
- '"interface loopback10" in result.commands'
|
|
|
|
- name: Delete loopback interface aggregate
|
|
eos_interface:
|
|
aggregate:
|
|
- name: loopback9
|
|
- name: loopback10
|
|
state: absent
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
become: yes
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- '"no interface loopback9" in result.commands'
|
|
- '"no interface loopback10" in result.commands'
|
|
|
|
- name: Delete loopback interface aggregate (idempotent)
|
|
eos_interface:
|
|
aggregate:
|
|
- name: loopback9
|
|
- name: loopback10
|
|
state: absent
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
become: yes
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == false'
|
|
|
|
- debug: msg="END eos_interface cli/basic.yaml on connection={{ ansible_connection }}"
|