2017-07-14 16:09:21 +02:00
|
|
|
---
|
|
|
|
- debug: msg="START vyos_interface cli/basic.yaml"
|
|
|
|
|
2017-07-18 14:34:14 +02:00
|
|
|
- name: Run vyos lsmod command
|
|
|
|
vyos_command:
|
|
|
|
commands:
|
2017-07-18 17:38:52 +02:00
|
|
|
- lsmod
|
2017-07-18 14:34:14 +02:00
|
|
|
register: lsmod_out
|
|
|
|
|
2017-07-14 16:09:21 +02:00
|
|
|
- name: Set up - delete interface
|
|
|
|
vyos_interface:
|
|
|
|
name: eth1
|
|
|
|
state: absent
|
|
|
|
|
2017-07-18 18:40:08 +02:00
|
|
|
- name: Set up - Create interface
|
2017-07-14 16:09:21 +02:00
|
|
|
vyos_interface:
|
|
|
|
name: eth1
|
|
|
|
state: present
|
|
|
|
description: test-interface
|
2017-07-18 18:40:08 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- '"set interfaces ethernet eth1" in result.commands'
|
|
|
|
- '"set interfaces ethernet eth1 description test-interface" in result.commands'
|
|
|
|
|
|
|
|
- name: Configure interface params
|
|
|
|
vyos_interface:
|
|
|
|
name: eth1
|
|
|
|
state: present
|
|
|
|
description: test-interface-1
|
2017-07-14 16:09:21 +02:00
|
|
|
speed: 100
|
|
|
|
duplex: half
|
|
|
|
mtu: 256
|
2017-07-18 17:38:52 +02:00
|
|
|
when: "'virtio_net' not in lsmod_out.stdout[0]"
|
2017-07-14 16:09:21 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2017-07-18 18:40:08 +02:00
|
|
|
- '"set interfaces ethernet eth1 description test-interface-1" in result.commands'
|
2017-07-14 16:09:21 +02:00
|
|
|
- '"set interfaces ethernet eth1 speed 100" in result.commands'
|
|
|
|
- '"set interfaces ethernet eth1 duplex half" in result.commands'
|
|
|
|
- '"set interfaces ethernet eth1 mtu 256" in result.commands'
|
2017-07-18 17:38:52 +02:00
|
|
|
when: "'virtio_net' not in lsmod_out.stdout[0]"
|
2017-07-14 16:09:21 +02:00
|
|
|
|
|
|
|
- name: Configure interface params (idempotent)
|
|
|
|
vyos_interface:
|
|
|
|
name: eth1
|
|
|
|
state: present
|
2017-07-19 09:31:56 +02:00
|
|
|
description: test-interface-1
|
2017-07-14 16:09:21 +02:00
|
|
|
speed: 100
|
|
|
|
duplex: half
|
|
|
|
mtu: 256
|
|
|
|
register: result
|
2017-07-18 17:38:52 +02:00
|
|
|
when: "'virtio_net' not in lsmod_out.stdout[0]"
|
2017-07-14 16:09:21 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|
2017-07-18 17:38:52 +02:00
|
|
|
when: "'virtio' not in lsmod_out.stdout[0]"
|
2017-07-14 16:09:21 +02:00
|
|
|
|
|
|
|
- name: Change interface params
|
|
|
|
vyos_interface:
|
|
|
|
name: eth1
|
|
|
|
state: present
|
2017-07-19 09:31:56 +02:00
|
|
|
description: test-interface-2
|
2017-07-14 16:09:21 +02:00
|
|
|
speed: 1000
|
|
|
|
duplex: full
|
|
|
|
mtu: 512
|
|
|
|
register: result
|
2017-07-18 17:38:52 +02:00
|
|
|
when: "'virtio_net' not in lsmod_out.stdout[0]"
|
2017-07-14 16:09:21 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2017-07-19 09:31:56 +02:00
|
|
|
- '"set interfaces ethernet eth1 description test-interface-2" in result.commands'
|
2017-07-14 16:09:21 +02:00
|
|
|
- '"set interfaces ethernet eth1 speed 1000" in result.commands'
|
|
|
|
- '"set interfaces ethernet eth1 duplex full" in result.commands'
|
|
|
|
- '"set interfaces ethernet eth1 mtu 512" in result.commands'
|
2017-07-18 17:38:52 +02:00
|
|
|
when: "'virtio_net' not in lsmod_out.stdout[0]"
|
2017-07-14 16:09:21 +02:00
|
|
|
|
|
|
|
- name: Disable interface
|
|
|
|
vyos_interface:
|
|
|
|
name: eth1
|
2017-08-14 06:47:41 +02:00
|
|
|
enabled: False
|
2017-07-14 16:09:21 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- '"set interfaces ethernet eth1 disable" in result.commands'
|
|
|
|
|
|
|
|
- name: Enable interface
|
|
|
|
vyos_interface:
|
|
|
|
name: eth1
|
2017-08-14 06:47:41 +02:00
|
|
|
enabled: True
|
2017-07-14 16:09:21 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- '"delete interfaces ethernet eth1 disable" in result.commands'
|
|
|
|
|
|
|
|
- name: Delete interface
|
|
|
|
vyos_interface:
|
|
|
|
name: eth1
|
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- '"delete interfaces ethernet eth1" in result.commands'
|
|
|
|
|
|
|
|
- name: Delete interface (idempotent)
|
|
|
|
vyos_interface:
|
|
|
|
name: eth1
|
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|
|
|
|
|
|
|
|
- name: Aggregate setup- delete interface
|
|
|
|
vyos_interface:
|
|
|
|
name: eth2
|
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- name: Set interface on aggregate
|
|
|
|
vyos_interface:
|
|
|
|
aggregate:
|
|
|
|
- { name: eth1, description: test-interface-1, speed: 100, duplex: half, mtu: 512}
|
|
|
|
- { name: eth2, description: test-interface-2, speed: 1000, duplex: full, mtu: 256}
|
|
|
|
register: result
|
2017-07-18 17:38:52 +02:00
|
|
|
when: "'virtio_net' not in lsmod_out.stdout[0]"
|
2017-07-14 16:09:21 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- '"set interfaces ethernet eth1 description test-interface-1" in result.commands'
|
|
|
|
- '"set interfaces ethernet eth1 speed 100" in result.commands'
|
|
|
|
- '"set interfaces ethernet eth1 duplex half" in result.commands'
|
|
|
|
- '"set interfaces ethernet eth1 mtu 512" in result.commands'
|
|
|
|
- '"set interfaces ethernet eth2 description test-interface-2" in result.commands'
|
|
|
|
- '"set interfaces ethernet eth2 speed 1000" in result.commands'
|
|
|
|
- '"set interfaces ethernet eth2 duplex full" in result.commands'
|
|
|
|
- '"set interfaces ethernet eth2 mtu 256" in result.commands'
|
2017-07-18 17:38:52 +02:00
|
|
|
when: "'virtio_net' not in lsmod_out.stdout[0]"
|
2017-07-14 16:09:21 +02:00
|
|
|
|
|
|
|
- name: Set interface on aggregate (idempotent)
|
|
|
|
vyos_interface:
|
|
|
|
aggregate:
|
|
|
|
- { name: eth1, description: test-interface-1, speed: 100, duplex: half, mtu: 512}
|
|
|
|
- { name: eth2, description: test-interface-2, speed: 1000, duplex: full, mtu: 256}
|
|
|
|
register: result
|
2017-07-18 17:38:52 +02:00
|
|
|
when: "'virtio_net' not in lsmod_out.stdout[0]"
|
2017-07-14 16:09:21 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|
2017-07-18 17:38:52 +02:00
|
|
|
when: "'virtio_net' not in lsmod_out.stdout[0]"
|
2017-07-14 16:09:21 +02:00
|
|
|
|
|
|
|
- name: Disable interface on aggregate
|
|
|
|
vyos_interface:
|
|
|
|
aggregate:
|
2017-08-14 06:47:41 +02:00
|
|
|
- { name: eth1, description: test-interface-1, enabled: False}
|
|
|
|
- { name: eth2, description: test-interface-2, enabled: False}
|
2017-07-14 16:09:21 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- '"set interfaces ethernet eth1 disable" in result.commands'
|
|
|
|
- '"set interfaces ethernet eth2 disable" in result.commands'
|
|
|
|
|
|
|
|
- name: Enable interface on aggregate
|
|
|
|
vyos_interface:
|
|
|
|
aggregate:
|
2017-08-14 06:47:41 +02:00
|
|
|
- { name: eth1, description: test-interface-1, enabled: True}
|
|
|
|
- { name: eth2, description: test-interface-2, enabled: True}
|
2017-07-14 16:09:21 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- '"delete interfaces ethernet eth1 disable" in result.commands'
|
|
|
|
- '"delete interfaces ethernet eth2 disable" in result.commands'
|
|
|
|
|
|
|
|
- name: Delete interface aggregate
|
|
|
|
vyos_interface:
|
|
|
|
aggregate:
|
|
|
|
- { name: eth1, state: absent}
|
|
|
|
- { name: eth2, state: absent}
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- '"delete interfaces ethernet eth1" in result.commands'
|
|
|
|
- '"delete interfaces ethernet eth2" in result.commands'
|
|
|
|
|
|
|
|
- name: Delete interface aggregate (idempotent)
|
|
|
|
vyos_interface:
|
|
|
|
aggregate:
|
|
|
|
- { name: eth1, state: absent}
|
|
|
|
- { name: eth2, state: absent}
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|