mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 10:25:28 +00:00
Add simple test for bridges
This commit is contained in:
parent
7d44710f44
commit
9b3d2d3ad8
4 changed files with 93 additions and 0 deletions
14
tests/tasks/assert-profile_absent.yml
Normal file
14
tests/tasks/assert-profile_absent.yml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
---
|
||||
- name: set variable
|
||||
set_fact:
|
||||
profile_path: /etc/sysconfig/network-scripts/ifcfg-{{ profile }}
|
||||
- name: stat profile file
|
||||
stat:
|
||||
path: "{{ profile_path }}"
|
||||
register: profile_stat
|
||||
|
||||
- assert:
|
||||
name: "assert that {{ profile }} is absent"
|
||||
that: not profile_stat.stat.exists
|
||||
msg: "profile {{ profile_path }} does exist"
|
||||
14
tests/tasks/assert-profile_present.yml
Normal file
14
tests/tasks/assert-profile_present.yml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
---
|
||||
- name: set variable
|
||||
set_fact:
|
||||
profile_path: /etc/sysconfig/network-scripts/ifcfg-{{ profile }}
|
||||
- name: stat profile file
|
||||
stat:
|
||||
path: "{{ profile_path }}"
|
||||
register: profile_stat
|
||||
|
||||
- assert:
|
||||
name: "assert that {{ profile }} is present"
|
||||
that: profile_stat.stat.exists
|
||||
msg: "profile {{ profile_path }} does not exist"
|
||||
55
tests/tests_bridge.yml
Normal file
55
tests/tests_bridge.yml
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
---
|
||||
- name: Test configuring bridges
|
||||
hosts: all
|
||||
vars:
|
||||
interface: LSR-TST-br31
|
||||
|
||||
tasks:
|
||||
- name: "set interface={{ interface }}"
|
||||
set_fact:
|
||||
interface: "{{ interface }}"
|
||||
- include_tasks: tasks/show-interfaces.yml
|
||||
- include_tasks: tasks/assert-device_absent.yml
|
||||
|
||||
- name: Add test bridge
|
||||
hosts: all
|
||||
vars:
|
||||
network_connections:
|
||||
- name: "{{ interface }}"
|
||||
interface_name: "{{ interface }}"
|
||||
state: up
|
||||
type: bridge
|
||||
ip:
|
||||
dhcp4: no
|
||||
auto6: yes
|
||||
roles:
|
||||
- linux-system-roles.network
|
||||
|
||||
- import_playbook: run-tasks.yml
|
||||
vars:
|
||||
task: tasks/assert-device_present.yml
|
||||
|
||||
- import_playbook: run-tasks.yml
|
||||
vars:
|
||||
profile: "{{ interface }}"
|
||||
task: tasks/assert-profile_present.yml
|
||||
|
||||
- import_playbook: down-profile.yml
|
||||
vars:
|
||||
profile: "{{ interface }}"
|
||||
# FIXME: assert profile/device down
|
||||
|
||||
- import_playbook: remove-profile.yml
|
||||
vars:
|
||||
profile: "{{ interface }}"
|
||||
|
||||
- import_playbook: run-tasks.yml
|
||||
vars:
|
||||
profile: "{{ interface }}"
|
||||
task: tasks/assert-profile_absent.yml
|
||||
|
||||
# FIXME: Devices might still be left when profile is absent
|
||||
#- import_playbook: run-tasks.yml
|
||||
# vars:
|
||||
# task: tasks/assert-device_absent.yml
|
||||
10
tests/tests_bridge_initscripts.yml
Normal file
10
tests/tests_bridge_initscripts.yml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
---
|
||||
# empty play to gather facts
|
||||
- hosts: all
|
||||
|
||||
- import_playbook: tests_bridge.yml
|
||||
vars:
|
||||
network_provider: initscripts
|
||||
when:
|
||||
- ansible_distribution_major_version != '6'
|
||||
Loading…
Add table
Add a link
Reference in a new issue