Build Windows Templates in RHV

This commit is contained in:
2021-05-03 13:47:44 -04:00
parent 595021d449
commit 28c9375b0d
290 changed files with 10931 additions and 159 deletions

View File

@@ -0,0 +1,227 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
""" Check that there is a playbook to run all role tests with both providers
"""
# vim: fileencoding=utf8
import glob
import os
import sys
GET_NM_VERSION = """
- block:
- name: Install NetworkManager
package:
name: NetworkManager
state: present
- name: Get NetworkManager version
command: rpm -q --qf "%{version}" NetworkManager
args:
warn: false
register: NetworkManager_version
when: true
when:
- ansible_distribution_major_version != '6'
tags:
- always
"""
MINIMUM_NM_VERSION_CHECK = """
- NetworkManager_version.stdout is version({minimum_nm_version}, '>=')
"""
EXTRA_RUN_CONDITION_PREFIX = " - "
RUN_PLAYBOOK_WITH_NM = """# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
# set network provider and gather facts
- hosts: all
name: Run playbook '{test_playbook}' with nm as provider
tasks:
- name: Set network provider to 'nm'
set_fact:
network_provider: nm
tags:
- always
{get_nm_version}
# The test requires or should run with NetworkManager, therefore it cannot run
# on RHEL/CentOS 6
- import_playbook: {test_playbook}
when:
- ansible_distribution_major_version != '6'
{minimum_nm_version_check}{extra_run_condition}"""
MINIMUM_VERSION = "minimum_version"
EXTRA_RUN_CONDITION = "extra_run_condition"
NM_ONLY_TESTS = {
"playbooks/tests_802_1x_updated.yml": {},
"playbooks/tests_802_1x.yml": {},
"playbooks/tests_eth_dns_support.yml": {},
"playbooks/tests_dummy.yml": {},
"playbooks/tests_ethtool_features.yml": {
MINIMUM_VERSION: "'1.20.0'",
"comment": "# NetworkManager 1.20.0 introduced ethtool settings support",
},
"playbooks/tests_ipv6_disabled.yml": {
EXTRA_RUN_CONDITION: "ansible_distribution_major_version == '8'",
},
"playbooks/tests_provider.yml": {
MINIMUM_VERSION: "'1.20.0'",
"comment": "# NetworKmanager 1.20.0 added support for forgetting profiles",
},
"playbooks/tests_ethtool_coalesce.yml": {
MINIMUM_VERSION: "'1.25.1'",
"comment": "# NetworkManager 1.25.1 introduced ethtool coalesce support",
},
"playbooks/tests_802_1x_updated.yml": {},
"playbooks/tests_802_1x.yml": {},
"playbooks/tests_reapply.yml": {},
# team interface is not supported on Fedora
"playbooks/tests_team.yml": {
EXTRA_RUN_CONDITION: "ansible_distribution != 'Fedora'",
},
"playbooks/tests_team_plugin_installation.yml": {},
# mac80211_hwsim (used for tests_wireless) only seems to be available
# and working on RHEL/CentOS 7
"playbooks/tests_wireless.yml": {
EXTRA_RUN_CONDITION: "ansible_distribution_major_version == '7'",
},
"playbooks/tests_wireless_plugin_installation.yml": {},
}
IGNORE = [
# checked by tests_regression_nm.yml
"playbooks/tests_checkpoint_cleanup.yml",
]
RUN_PLAYBOOK_WITH_INITSCRIPTS = """# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
- hosts: all
name: Run playbook '{test_playbook}' with initscripts as provider
tasks:
- name: Set network provider to 'initscripts'
set_fact:
network_provider: initscripts
tags:
- always
- import_playbook: {test_playbook}
"""
def create_nm_playbook(test_playbook):
fileroot = os.path.splitext(os.path.basename(test_playbook))[0]
nm_testfile = fileroot + "_nm.yml"
minimum_nm_version = NM_ONLY_TESTS.get(test_playbook, {}).get(MINIMUM_VERSION)
extra_run_condition = NM_ONLY_TESTS.get(test_playbook, {}).get(
EXTRA_RUN_CONDITION, ""
)
if extra_run_condition:
extra_run_condition = "{}{}\n".format(
EXTRA_RUN_CONDITION_PREFIX, extra_run_condition
)
nm_version_check = ""
if minimum_nm_version:
nm_version_check = MINIMUM_NM_VERSION_CHECK.format(
minimum_nm_version=minimum_nm_version
)
nominal_nm_testfile_data = RUN_PLAYBOOK_WITH_NM.format(
test_playbook=test_playbook,
get_nm_version=minimum_nm_version and GET_NM_VERSION or "",
minimum_nm_version_check=nm_version_check,
extra_run_condition=extra_run_condition,
)
return nm_testfile, nominal_nm_testfile_data
def create_initscripts_playbook(test_playbook):
fileroot = os.path.splitext(os.path.basename(test_playbook))[0]
init_testfile = fileroot + "_initscripts.yml"
nominal_data = RUN_PLAYBOOK_WITH_INITSCRIPTS.format(test_playbook=test_playbook)
return init_testfile, nominal_data
def check_playbook(generate, testfile, test_playbook, nominal_data):
is_missing = False
returncode = None
if generate:
print(testfile)
with open(testfile, "w") as ofile:
ofile.write(nominal_data)
if not os.path.isfile(testfile) and not generate:
is_missing = True
else:
with open(testfile) as ifile:
testdata = ifile.read()
if testdata != nominal_data:
print(f"ERROR: Playbook does not match nominal value: {testfile}")
returncode = 1
return is_missing, returncode
def main():
testsfiles = glob.glob("playbooks/tests_*.yml")
missing = []
returncode = 0
# Generate files when specified
generate = bool(len(sys.argv) > 1 and sys.argv[1] == "generate")
if not testsfiles:
print("ERROR: No tests found")
returncode = 1
for test_playbook in testsfiles:
if test_playbook in IGNORE:
continue
nm_testfile, nominal_nm_testfile_data = create_nm_playbook(test_playbook)
is_missing, new_returncode = check_playbook(
generate=generate,
testfile=nm_testfile,
test_playbook=test_playbook,
nominal_data=nominal_nm_testfile_data,
)
if is_missing:
missing.append(test_playbook)
if new_returncode:
returncode = new_returncode
if test_playbook not in NM_ONLY_TESTS:
init_testfile, nominal_init_testfile_data = create_initscripts_playbook(
test_playbook
)
is_missing, new_returncode = check_playbook(
generate=generate,
testfile=init_testfile,
test_playbook=test_playbook,
nominal_data=nominal_init_testfile_data,
)
if is_missing:
missing.append(test_playbook)
if new_returncode:
returncode = new_returncode
if missing:
print("ERROR: No NM or initscripts tests found for:\n" + ", \n".join(missing))
print("Try to generate them with '{} generate'".format(sys.argv[0]))
returncode = 1
return returncode
if __name__ == "__main__":
sys.exit(main())

View File

@@ -0,0 +1,30 @@
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,B773C37C13C791B1B2F735A7D6D22F1D
KcpCACKK2i/zLDkH/e2bM/3hzyuC7UkSJ32Vn2xvH6ukKzOpt71PJjtzucY3TgB7
T8f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eN5BDsotrHbrZ/PZhlZgN1ou3gapXqM12TkXdzaj//vRd
CORjwO1ubpzb17PFUNOLWaDf3ohfoMCG08UkGwIGK0mouJ1yflda27MCcLzmDxV8
4dfI//R/6WtN1hzWSW9ae99VwSjlACH2go/0fDD+K9jvKkEVRZAqBEnM3voQCOah
P9NMJ30R9Sh8B/D2KXGyIU0CAwEAAaNTMFEwHQYDVR0OBBYEFDUKdAwDiWpUpayU
mjiWEcMcXjQdMB8GA1UdIwQYMBaAFDUKdAwDiWpUpayUmjiWEcMcXjQdMA8GA1Ud
EwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAKEyNiDawDJeaauDUmHgdNlG
WuBlvn4Lph/+J27njmAoIbKv3aDw+kndxI02ryCZTJOm8a1NqHfkNct4ny+Cj4cz
rNoZIyMucVoKGgCMYb5zwYtW3W7RshUZoBdQDBLiIuktNsWTyqss3yVPPq8Q1JJY
89dtjCNydL6dunFSrGjVJ2K5HaTyidti2IN9g2Sbxmxgoz71ZP09xmBxaY+O738M
z5nRdrb2DX0flmv5pcqSzn7063t9FGKOp2bF9NTpcEWkultsCOvsVcsO4X/18L4J
3W8FVltyCvunv4GQecWqlNHTRT+QI2h48EVEzHQnOGEe9q1C8WVGeQ3cZXMei8k=
-----END CERTIFICATE-----

View File

@@ -0,0 +1,31 @@
# password=test
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,C4A5E9A189773AB0F3CE3DCC98F208AE
LPNSExpEERS+/qHJxd8puT+EaZ/dZ20gkU/C2eaNNJerzr4moSXG4ioh5ggz4utQ
w57fD5OYqPiloNIawi/Ta5Opo3zU+iMZPVQALLbemXWXmNMxqxNCGdonc4enxMoN
auLxpdYPW+infFmf0UPwZjWkrLnK8XFapTGDaNesfgMNSRVSt+DQL3xeKUjcuXfh
rYvF26/Ls8NHB0tCU449vCa5ta1fHPT78B0cWgCmhcg/L8/0veBYfwxnyu6l3E6Q
RXWcyaJo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C6uRf8be/WKHPKu3i0irrVtZdMsKNkRiD5UUK
S4Y0WnoVu/DWSR8h9iPGSFKMkUcjFI8hgc4YQ6G4Odc=
-----END CERTIFICATE-----

View File

@@ -0,0 +1,8 @@
-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEAjbYPkANn2XGqDGCzse9wAfM0I5WJpp+Xl+iNJFmaKXBguo0BPYQt
hZOpJbKL3aNaFsRxhdAJ8UXzBP6oIzCejcGti+jw+xtVk8ietWEK6e91yi+Ak2g2
/Xtt9hoYQkeoe5hkcv35NcJ0xdQwlSvMbY/j8HtKamx/A3zu+YPQAe/3AOe3L+JT
iEL5Gw00NPVnyEWKX4fVchAbMUkRsQKeXtsyOyDc4/RccjfLa1toyj8PRommK5UH
dkSqi04FTOUIx6aTwt21EehJuggLVDShoQdxGV+FzXmdtelLmerGMtVPBbf8DSkN
MKMBEg4d28DzjXPAWUHMD+JGPzAlvf87EwIBAg==
-----END DH PARAMETERS-----

View File

@@ -0,0 +1,31 @@
# password=test
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,ED349A8B098E2D1DB70C30F77EF599AB
j1rzje2sWFk3B9kD6eE7WrqVDynFEJ3t3kdOv0iUvH5Ybll1C7Qx3EFEdoM4z2OV
E6q3nr2DOvpMPox1DvBdIipWOQWJxkZyBHqNn4v4GR4c0uxLswsk7XSBQLUclRsn
QBGO6x8pcEA9u/O3PSrTt+pVozWrXWmR2UHNM//9WUsRpWF4Lv0EINzsfwmD7aJQ
nRcSfXsCggXP6wnJX5dgo5PlRm6R+bodgzePr0QRlh8TT6wnixZfWalYM5iUKlEF
GcE+VejZuBL69byl2AcRt8I5tQ+UZxmzhKPSsYN0NKD8vbcVVnp2sre/rbdTzWz5
laF386g1M8QBimDE/V3Bw5b9Bg1ZP3arlpugVXGVNA+HFti8PVdkaMqLgkFIC2Xu
OwmNKffAPIItuB8leg5A76oLoIlllRqjWO9M/O+MqAlrJ96xLRiUe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xxeNB0wDQYJ
KoZIhvcNAQELBQADggEBAKtTPl4WJuxfMeut+aEw7vVRU+z5A7D35nlZPQI5nBTt
ybgqMNIjdcYT/JwT2GhbzcObc3STNEo582clVN9gTpK7mYKzBBf69nTsWeZzPuNt
JQbVbK4RHwFvyosJcw6NfzxE9OxeXhTcKQDQSGKP338sAWoapEZlXNrYOIJac6HX
Xo3dQqx/8BdO9hSv1u0/zClnL5lbk1RBylS24wIe8wLoiy4ftLjL4aOYOlonj7HU
hknTY6L30oOpG5VtH8SEv3xveH/5GNKwfoGltTzemCgVfb9IhyVTLB3tIv8OW6k1
y3+YEzVniVB4gtJ5UniLN1V4lBf6t7MGn0ybAEbOxPI=
-----END CERTIFICATE-----

View File

@@ -0,0 +1,65 @@
#! /bin/bash
# SPDX-License-Identifier: BSD-3-Clause
if [ -n "${DEBUG}" ]
then
set -x
fi
set -e
if [ "$#" -lt 2 ]
then
echo "USAGE: ${0} host playbook"
echo "Get coverage info from host for playbook"
exit 1
fi
host="${1}"
shift
playbook="${1}"
coverage_data="remote-coveragedata-${host}-${playbook%.yml}"
coverage="/root/.local/bin/coverage"
echo "Getting coverage for ${playbook} on ${host}" >&2
call_ansible() {
local module="${1}"
shift
local args="${1}"
shift
ansible -m "${module}" -i "${host}", -a "${args}" all "${@}"
}
remote_coverage_dir="$(mktemp -d /tmp/remote_coverage-XXXXXX)"
trap "rm -rf '${remote_coverage_dir}'" EXIT
ansible-playbook -i "${host}", get_coverage.yml -e "test_playbook=${playbook} destdir=${remote_coverage_dir}"
#COVERAGE_FILE=remote-coverage coverage combine remote-coverage/tests_*/*/root/.coverage
./merge_coverage.sh coverage "${coverage_data}"-tmp $(find "${remote_coverage_dir}" -type f | tr , _)
cat > tmp_merge_coveragerc <<EOF
[paths]
source =
.
EOF
# example path with Ansible 2.9.6:
# /tmp/ansible_network_connections_payload_psugdf6r/ansible_network_connections_payload.zip/ansible/modules/network_connections.py
# /tmp/ansible_network_connections_payload_psugdf6r/ansible_network_connections_payload.zip/ansible/module_utils/network_lsr/__init__.py
# /tmp/ansible_network_connections_payload_psugdf6r/ansible_network_connections_payload.zip/ansible/module_utils/network_lsr/argument_validator.py
# /tmp/ansible_network_connections_payload_psugdf6r/ansible_network_connections_payload.zip/ansible/module_utils/network_lsr/utils.py
# /tmp/ansible_network_connections_payload_psugdf6r/ansible_network_connections_payload.zip/ansible/module_utils/network_lsr/nm_provider.py
for file in $(echo 'SELECT path FROM file;' | sqlite3 "${coverage_data}"-tmp | sed s,/module.*.py,, | sort -u)
do
echo " ${file}" >> tmp_merge_coveragerc
done
COVERAGE_FILE="${coverage_data}" coverage combine --rcfile tmp_merge_coveragerc "${coverage_data}"-tmp
test -n "${DEBUG}" && cat tmp_merge_coveragerc
rm tmp_merge_coveragerc
COVERAGE_FILE="${coverage_data}" coverage report ||:
COVERAGE_FILE="${coverage_data}" coverage html --directory "htmlcov-${coverage_data}" ||:
echo "Coverage collected in: ${coverage_data}"

View File

@@ -0,0 +1,82 @@
# SPDX-License-Identifier: BSD-3-Clause
---
# This expects the variable test_playbook to be set from the outside
- name: Prepare for coverage extraction
hosts: all
tasks:
# Use set_fact to set variables to make them available in all plays
# 'vars:' Would only set variables for the current play
- name: set facts
set_fact:
coverage_module: network_connections
coverage: /root/.local/bin/coverage
destdir: "remote_coverage/{{ test_playbook }}"
# This uses variables from the other set_fact task, therefore it needs to
# be its own task
- name: set more facts
set_fact:
coverage_file:
# yamllint disable-line rule:line-length
ansible-coverage-{{ coverage_module }}-{{ test_playbook|replace('.yml', '') }}
- name: debug info
debug:
msg:
# yamllint disable-line rule:line-length
Getting coverage for '{{ coverage_module }}' with '{{ test_playbook }}'
# combine data in case old data is left there
- command: "{{ coverage }} combine"
environment:
COVERAGE_FILE: "{{ coverage_file }}"
ignore_errors: yes
- name: remove old data
file:
state: absent
path: "{{ coverage_file }}"
- name: find coverage files to delete
find:
path: "{{ ansible_env.HOME }}"
patterns: ".coverage.*"
hidden: yes
register: files_to_delete
- name: remove old data
file:
path: "{{ item.path }}"
state: absent
with_items: "{{ files_to_delete.files }}"
- name: copy coveragerc
copy:
content: "[run]\ndisable_warnings = no-data-collected\n"
dest: .coveragerc
- name: install latest pip
pip:
name: coverage
extra_args: --user --upgrade
- import_playbook: "{{ test_playbook }}"
vars:
ansible_python_interpreter:
# yamllint disable-line rule:line-length
"{{ coverage }} run -p --include /*/modules/network_connections.py,/*/module_utils/network_lsr/*"
- name: Gather coverage data
hosts: all
tasks:
- shell: "{{ coverage }} combine .coverage.*"
environment:
COVERAGE_FILE: "{{ coverage_file }}"
- name: Get coverage data
hosts: all
tasks:
- fetch:
src: "{{ coverage_file }}"
dest: "{{ destdir }}"
flat: no

View File

@@ -0,0 +1,34 @@
#! /bin/bash
# SPDX-License-Identifier: BSD-3-Clause
set -e
coverage_data=total-coveragedata
testhost="${1}"
if [ "$#" -lt 1 ]
then
echo "USAGE: ${0} host"
echo "Get local and all remote coverage data for host"
exit 1
fi
rm -f remote-coveragedata* "${coveragedata}"
# collect pytest coverage
tox -e py26,py27,py36,py37 -- --cov-append
for test_playbook in tests_*.yml
do
./get_coverage.sh "${testhost}" "${test_playbook}"
done
./merge_coverage.sh coverage "total-remote-coveragedata" remote-coveragedata-*
./covstats .coverage remote-coveragedata-* "total-remote-coveragedata"
./merge_coverage.sh coverage "${coverage_data}" .coverage remote-coveragedata-*
echo "Total coverage:"
COVERAGE_FILE="${coverage_data}" coverage report ||:
COVERAGE_FILE="${coverage_data}" coverage html --directory "htmlcov-${coverage_data}" ||:
echo "Open HTML report with:"
echo "xdg-open htmlcov-${coverage_data}/index.html"

View File

@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*
# SPDX-License-Identifier: BSD-3-Clause
def pytest_addoption(parser):
parser.addoption(
"--provider", action="store", default="nm", help="Network provider"
)

View File

@@ -0,0 +1,114 @@
# -*- coding: utf-8 -*
# SPDX-License-Identifier: BSD-3-Clause
import logging
import os
import subprocess
import pytest
try:
from unittest import mock
except ImportError:
import mock
parent_dir = os.path.normpath(os.path.join(os.path.dirname(__file__), "..", ".."))
with mock.patch.dict(
"sys.modules",
{
"ansible.module_utils.basic": mock.Mock(),
},
):
import network_connections as nc
class PytestRunEnvironment(nc.RunEnvironment):
def log(self, connections, idx, severity, msg, **kwargs):
if severity == nc.LogLevel.ERROR:
logging.error("Error: {}".format(connections[idx]))
raise RuntimeError(msg)
else:
logging.debug("Log: {}".format(connections[idx]))
def run_command(self, argv, encoding=None):
command = subprocess.Popen(
argv, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
return_code = command.wait()
out, err = command.communicate()
return return_code, out.decode("utf-8"), err.decode("utf-8")
def _check_mode_changed(self, *args, **kwargs):
pass
def _configure_network(connections, provider):
cmd = nc.Cmd.create(
provider,
run_env=PytestRunEnvironment(),
connections_unvalidated=connections,
connection_validator=nc.ArgValidator_ListConnections(),
)
cmd.run()
@pytest.fixture(scope="session")
def provider(request):
return request.config.getoption("--provider")
@pytest.fixture
def testnic1():
veth_name = "testeth"
try:
subprocess.call(
[
"ip",
"link",
"add",
veth_name,
"type",
"veth",
"peer",
"name",
veth_name + "peer",
],
close_fds=True,
)
yield veth_name
finally:
subprocess.call(["ip", "link", "delete", veth_name])
def _get_ip_addresses(interface):
ip_address = subprocess.check_output(["ip", "address", "show", interface])
return ip_address.decode("UTF-8")
@pytest.fixture
def network_lsr_nm_mock():
with mock.patch.dict(
"sys.modules",
{
"ansible.module_utils.basic": mock.Mock(),
},
):
yield
def test_static_ip_with_ethernet(testnic1, provider, network_lsr_nm_mock):
ip_address = "192.0.2.127/24"
connections = [
{
"name": testnic1,
"type": "ethernet",
"state": "up",
"ip": {"address": [ip_address]},
}
]
_configure_network(connections, provider)
assert ip_address in _get_ip_addresses(testnic1)
if provider == "initscripts":
assert os.path.exists("/etc/sysconfig/network-scripts/ifcfg-" + testnic1)
else:
subprocess.check_call(["nmcli", "connection", "show", testnic1])

View File

@@ -0,0 +1,35 @@
#! /bin/bash
# SPDX-License-Identifier: BSD-3-Clause
if [ -n "${DEBUG}" ]
then
set -x
fi
set -e
if [ "$#" -lt 3 ]
then
echo "USAGE: ${0} path_to_coverage_binary output_file input_files..."
echo "Merges all input_files into output file without removing input_files"
exit 1
fi
# path to coverage binary
coverage="${1}"
shift
# read by coverage binary
export COVERAGE_FILE="${1}"
shift
tempdir="$(mktemp -d /tmp/coverage_merge-XXXXXX)"
trap "rm -rf '${tempdir}'" EXIT
cp --backup=numbered -- "${@}" "${tempdir}"
# FIXME: Would not work if coverage files are not hidden but they are by
# default
shopt -s dotglob
"${coverage}" combine "${tempdir}/"*
echo "Merged data into ${COVERAGE_FILE}"
./covstats "${COVERAGE_FILE}"

View File

@@ -0,0 +1 @@
../module_utils/

View File

@@ -0,0 +1 @@
../library/

View File

@@ -0,0 +1,10 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Set {{ profile }} down
hosts: all
vars:
network_connections:
- name: "{{ profile }}"
state: down
roles:
- linux-system-roles.network

View File

@@ -0,0 +1 @@
../files

View File

@@ -0,0 +1,149 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Install dependencies for integration tests
hosts: all
vars:
- rpmdependencies:
- git
- python3-pip
- rsync
tasks:
- name: Install rpm dependencies
package:
state: present
name: "{{ rpmdependencies }}"
- name: Install Pytest
command: "pip3 install pytest"
# Import needed in order to install initscripts dependencies on the remote
# system.
- import_playbook: "../tests_default_initscripts.yml"
# Import needed in order to install Network Manager dependencies on the remote
# system.
- import_playbook: "../tests_default_nm.yml"
- name: Run Pytest tests
hosts: all
tasks:
- block:
- name: create tempdir for code to test
tempfile:
state: directory
prefix: lsrtest_
register: _rundir
- name: get tempfile for tar
tempfile:
prefix: lsrtest_
suffix: ".tar"
register: temptar
delegate_to: localhost
- include_tasks: ../tasks/get_modules_and_utils_paths.yml
- name: get tests directory
set_fact:
tests_directory: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- tests
- network
paths:
- "../.."
# TODO: using tar and copying the file is a workaround for the
# synchronize module that does not work in test-harness. Related issue:
# https://github.com/linux-system-roles/test-harness/issues/102
#
- name: Create Tar file
command: >
tar -cvf {{ temptar.path }} --exclude "*.pyc"
--exclude "__pycache__"
-C {{ tests_directory | realpath | dirname }}
{{ tests_directory | basename }}
-C {{ modules_parent_and_dir.stdout_lines[0] }}
{{ modules_parent_and_dir.stdout_lines[1] }}
-C {{ module_utils_parent_and_dir.stdout_lines[0] }}
{{ module_utils_parent_and_dir.stdout_lines[1] }}
delegate_to: localhost
- name: Copy testrepo.tar to the remote system
copy:
src: "{{ temptar.path }}"
dest: "{{ _rundir.path }}"
- name: Untar testrepo.tar
command: tar xf {{ temptar.path | basename }}
args:
chdir: "{{ _rundir.path }}"
- file:
state: directory
path: "{{ _rundir.path }}/ansible"
- name: Move module_utils to ansible directory
shell: |
if [ -d {{ _rundir.path }}/module_utils ]; then
mv {{ _rundir.path }}/module_utils {{ _rundir.path }}/ansible
fi
- name: Fake out python module directories, primarily for python2
shell: |
for dir in $(find {{ _rundir.path }} -type d -print); do
if [ ! -f "$dir/__init__.py" ]; then
touch "$dir/__init__.py"
fi
done
- set_fact:
_lsr_python_path: "{{
_rundir.path ~ '/' ~
modules_parent_and_dir.stdout_lines[1] ~ ':' ~ _rundir.path
}}"
- debug:
msg: path {{ _lsr_python_path }}
- command: ls -alrtFR {{ _rundir.path }}
- block:
- name: Run pytest with nm
command: >
pytest
{{ _rundir.path }}/{{ tests_directory | basename }}/integration/
--provider=nm
register: playbook_run
environment:
PYTHONPATH: "{{ _lsr_python_path }}"
always:
- debug:
var: playbook_run.stdout_lines
- block:
- name: Run pytest with initscripts
command: >
pytest
{{ _rundir.path }}/{{ tests_directory | basename }}/integration/
--provider=initscripts
register: playbook_run
environment:
PYTHONPATH: "{{ _lsr_python_path }}"
always:
- debug:
var: playbook_run.stdout_lines
always:
- name: remove local tar file
file:
state: absent
path: "{{ temptar.path }}"
delegate_to: localhost
- name: remove tempdir
file:
state: absent
path: "{{ _rundir.path }}"

View File

@@ -0,0 +1,115 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
vars:
interface: "{{ network_interface_name1 }}"
type: "{{ network_interface_type1 }}"
tasks:
- name: "INIT: Ethtool coalesce tests"
debug:
msg: "##################################################"
- include_tasks: tasks/show_interfaces.yml
- include_tasks: tasks/manage_test_interface.yml
vars:
state: present
- include_tasks: tasks/assert_device_present.yml
- name: Install ethtool (test dependency)
package:
name: ethtool
state: present
- block:
- name: >-
TEST: I can create a profile without changing the ethtool coalesce.
debug:
msg: "##################################################"
- name: Get current device coalesce
command: "ethtool --show-coalesce {{ interface }}"
register: original_ethtool_coalesce
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
state: up
type: ethernet
ip:
dhcp4: "no"
auto6: "no"
- name: Get current device coalesce
command: "ethtool --show-coalesce {{ interface }}"
register: ethtool_coalesce
- name: "ASSERT: The profile does not change the ethtool coalesce"
assert:
that:
- original_ethtool_coalesce.stdout == ethtool_coalesce.stdout
- name: >-
TEST: I can set rx-frames and adaptive-tx.
debug:
msg: "##################################################"
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
state: up
type: ethernet
ip:
dhcp4: "no"
auto6: "no"
ethtool:
coalesce:
rx_frames: 1
tx_frames: 1
- name: Get current device coalesce
command: "ethtool --show-coalesce {{ interface }}"
register: ethtool_coalesce
- name:
debug:
var: ethtool_coalesce.stdout_lines
- name: Assert device coalesce
assert:
that:
- >-
'rx-frames: 1' in
ethtool_coalesce.stdout_lines
- >-
'tx-frames: 1' in
ethtool_coalesce.stdout_lines
- name: "TEST: I can reset coalesce to their original value."
debug:
msg: "##################################################"
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
state: up
type: ethernet
ip:
dhcp4: "no"
auto6: "no"
- name: Get current device coalesce
command: "ethtool --show-coalesce {{ interface }}"
register: ethtool_coalesce
# Resetting the ethtools only works with NetworkManager
- name: "ASSERT: The profile does not change the ethtool coalesce"
assert:
that:
- original_ethtool_coalesce.stdout == ethtool_coalesce.stdout
when:
network_provider == 'nm'
always:
- block:
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
persistent_state: absent
state: down
ignore_errors: true
- include_tasks: tasks/manage_test_interface.yml
vars:
state: absent
tags:
- "tests::cleanup"

View File

@@ -0,0 +1,10 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Remove {{ profile }}
hosts: all
vars:
network_connections:
- name: "{{ profile }}"
persistent_state: absent
roles:
- linux-system-roles.network

View File

@@ -0,0 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Run the tasklist {{ task }}
hosts: all
tasks:
- include_tasks: "{{ task }}"

View File

@@ -0,0 +1,124 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
vars:
interface: 802-1x-test
tasks:
- name: "INIT: 802.1x tests"
debug:
msg: "##################################################"
- include_tasks: tasks/setup_802.1x.yml
- block:
- name: "TEST: 802.1x profile with private key password and ca cert"
debug:
msg: "##################################################"
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
interface_name: veth2
state: up
type: ethernet
ip:
address:
- 203.0.113.2/24
dhcp4: "no"
auto6: "no"
ieee802_1x:
identity: myhost
eap: tls
private_key: /etc/pki/tls/client.key
private_key_password: test
private_key_password_flags:
- none
client_cert: /etc/pki/tls/client.pem
ca_cert: /etc/pki/tls/cacert.pem
- name: "TEST: I can ping the EAP server"
command: ping -c1 203.0.113.1
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
persistent_state: absent
state: down
- name: >-
TEST: 802.1x profile with unencrypted private key,
domain suffix match, and system ca certs
debug:
msg: "##################################################"
- name: Copy cacert to system truststore
copy:
src: cacert.pem
dest: /etc/pki/ca-trust/source/anchors/cacert.pem
mode: 0644
- name: Update ca trust
command: update-ca-trust
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
interface_name: veth2
state: up
type: ethernet
ip:
address:
- 203.0.113.2/24
dhcp4: "no"
auto6: "no"
ieee802_1x:
identity: myhost
eap: tls
private_key: /etc/pki/tls/client.key.nocrypt
client_cert: /etc/pki/tls/client.pem
private_key_password_flags:
- not-required
system_ca_certs: True
domain_suffix_match: example.com
- name: "TEST: I can ping the EAP server"
command: ping -c1 203.0.113.1
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
persistent_state: absent
state: down
- include_tasks: tasks/test_802.1x_capath.yml
always:
- block:
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
persistent_state: absent
state: down
- name: br1
persistent_state: absent
state: down
ignore_errors: true
- include_tasks: tasks/cleanup_802_1x_server.yml
- name: Remove test certificates
file:
state: absent
path: "/etc/pki/tls/{{ item }}"
with_items:
- client.key
- client.key.nocrypt
- client.pem
- cacert.pem
- name: Remove test CA
file:
state: absent
path: "{{ item }}"
with_items:
- /etc/pki/tls/my_ca_certs
- /etc/pki/ca-trust/source/anchors/cacert.pem
- name: Update ca trust
command: update-ca-trust
tags:
- "tests::cleanup"

View File

@@ -0,0 +1,13 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
tasks:
- name: Update NetworkManager
package:
name: NetworkManager
state: latest
- name: Restart NetworkManager
service:
name: NetworkManager
state: restarted
- import_playbook: tests_802_1x.yml

View File

@@ -0,0 +1,97 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
vars:
controller_profile: bond0
controller_device: nm-bond
port1_profile: bond0.0
dhcp_interface1: test1
port2_profile: bond0.1
dhcp_interface2: test2
tasks:
- name: "INIT Prepare setup"
debug:
msg: "##################################################"
- import_tasks: tasks/create_test_interfaces_with_dhcp.yml
- import_tasks: tasks/assert_device_present.yml
vars:
interface: "{{ dhcp_interface1 }}"
- import_tasks: tasks/assert_device_present.yml
vars:
interface: "{{ dhcp_interface2 }}"
- block:
- name: "TEST Add Bond with 2 ports"
debug:
msg: "##################################################"
- import_role:
name: linux-system-roles.network
vars:
network_connections:
# Create a bond controller
- name: "{{ controller_profile }}"
state: up
type: bond
interface_name: "{{ controller_device }}"
bond:
mode: active-backup
miimon: 110
# add an ethernet to the bond
- name: "{{ port1_profile }}"
state: up
type: ethernet
interface_name: "{{ dhcp_interface1 }}"
controller: "{{ controller_profile }}"
# add a second ethernet to the bond
- name: "{{ port2_profile }}"
state: up
type: ethernet
interface_name: "{{ dhcp_interface2 }}"
controller: "{{ controller_profile }}"
- import_tasks: tasks/assert_device_present.yml
vars:
interface: "{{ controller_device }}"
- include_tasks: tasks/assert_profile_present.yml
vars:
profile: "{{ item }}"
loop:
- "{{ controller_profile }}"
- "{{ port1_profile }}"
- "{{ port2_profile }}"
- command: grep 'Polling Interval'
/proc/net/bonding/{{ controller_device }}
name: "** TEST check polling interval"
register: result
until: "'110' in result.stdout"
- command: ip -4 a s {{ controller_device }}
name: "** TEST check IPv4"
register: result
until: "'192.0.2' in result.stdout"
retries: 20
delay: 2
- command: ip -6 a s {{ controller_device }}
name: "** TEST check IPv6"
register: result
until: "'2001' in result.stdout"
retries: 20
delay: 2
always:
- block:
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ port2_profile }}"
persistent_state: absent
state: down
- name: "{{ port1_profile }}"
persistent_state: absent
state: down
- name: "{{ controller_profile }}"
persistent_state: absent
state: down
ignore_errors: true
- command: ip link del {{ controller_device }}
ignore_errors: true
- import_tasks: tasks/remove_test_interfaces_with_dhcp.yml
tags:
- "tests::cleanup"

View File

@@ -0,0 +1,97 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
vars:
controller_profile: bond0
controller_device: nm-bond
port1_profile: bond0.0
dhcp_interface1: test1
port2_profile: bond0.1
dhcp_interface2: test2
tasks:
- name: "INIT Prepare setup"
debug:
msg: "##################################################"
- import_tasks: tasks/create_test_interfaces_with_dhcp.yml
- import_tasks: tasks/assert_device_present.yml
vars:
interface: "{{ dhcp_interface1 }}"
- import_tasks: tasks/assert_device_present.yml
vars:
interface: "{{ dhcp_interface2 }}"
- block:
- name: "TEST Add Bond with 2 ports using deprecated 'master' argument"
debug:
msg: "##################################################"
- import_role:
name: linux-system-roles.network
vars:
network_connections:
# Create a bond controller
- name: "{{ controller_profile }}"
state: up
type: bond
interface_name: "{{ controller_device }}"
bond:
mode: active-backup
miimon: 110
# add an ethernet to the bond
- name: "{{ port1_profile }}"
state: up
type: ethernet
interface_name: "{{ dhcp_interface1 }}"
master: "{{ controller_profile }}"
# add a second ethernet to the bond
- name: "{{ port2_profile }}"
state: up
type: ethernet
interface_name: "{{ dhcp_interface2 }}"
master: "{{ controller_profile }}"
- import_tasks: tasks/assert_device_present.yml
vars:
interface: "{{ controller_device }}"
- include_tasks: tasks/assert_profile_present.yml
vars:
profile: "{{ item }}"
loop:
- "{{ controller_profile }}"
- "{{ port1_profile }}"
- "{{ port2_profile }}"
- command: grep 'Polling Interval'
/proc/net/bonding/{{ controller_device }}
name: "** TEST check polling interval"
register: result
until: "'110' in result.stdout"
- command: ip -4 a s {{ controller_device }}
name: "** TEST check IPv4"
register: result
until: "'192.0.2' in result.stdout"
retries: 20
delay: 2
- command: ip -6 a s {{ controller_device }}
name: "** TEST check IPv6"
register: result
until: "'2001' in result.stdout"
retries: 20
delay: 2
always:
- block:
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ port2_profile }}"
persistent_state: absent
state: down
- name: "{{ port1_profile }}"
persistent_state: absent
state: down
- name: "{{ controller_profile }}"
persistent_state: absent
state: down
ignore_errors: true
- command: ip link del {{ controller_device }}
ignore_errors: true
- import_tasks: tasks/remove_test_interfaces_with_dhcp.yml
tags:
- "tests::cleanup"

View 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

View File

@@ -0,0 +1,82 @@
# SPDX-License-Identifier: BSD-3-Clause
# This test is supposed to check that checkpoints are properly cleaned-up after
# failures in the module. This test currently uses the initscripts provider to
# mark a device as unmanaged for NM and then tries to activiate it using NM.
# This failed without removing the checkpoint.
---
- hosts: all
vars:
interface: cptstbr
profile: "{{ interface }}"
network_provider: nm
pre_tasks:
- debug:
msg: Inside states tests
- include_tasks: tasks/show_interfaces.yml
- include_tasks: tasks/assert_device_absent.yml
roles:
- linux-system-roles.network
tasks:
- block:
# Workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1832897
- package:
name: dbus-tools
state: present
# create test profile
- include_role:
name: linux-system-roles.network
vars:
network_provider: initscripts
network_connections:
- name: "{{ interface }}"
state: up
type: bridge
ip:
dhcp4: false
auto6: false
- include_tasks: tasks/assert_device_present.yml
- include_tasks: tasks/assert_profile_present.yml
# Use internal module directly for speedup
- network_connections:
provider: nm
connections:
- name: "{{ interface }}"
state: up
type: bridge
ip:
dhcp4: false
auto6: false
ignore_errors: true
register: error_trigger
- assert:
fail_msg: The module call did not fail. Therefore the test
condition was not triggered. This test needs to be adjusted or
dropped.
that: error_trigger.failed
# yamllint disable-line rule:line-length
- command: busctl --system tree --list org.freedesktop.NetworkManager
register: nm_dbus_objects
- debug:
var: nm_dbus_objects
- name: Assert that no checkpoints are left
assert:
fail_msg: Checkpoints not cleaned up
that: >
'/org/freedesktop/NetworkManager/Checkpoint/' not in
nm_dbus_objects.stdout_lines
always:
- block:
# Use internal module directly for speedup
- network_connections:
provider: nm
connections:
- name: "{{ interface }}"
persistent_state: absent
state: down
- file:
dest: "/etc/sysconfig/network-scripts/ifcfg-{{ interface }}"
state: absent
- command: ip link del "{{ interface }}"
ignore_errors: true
tags:
- "tests::cleanup"

View File

@@ -0,0 +1,30 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
vars:
interface: dummy0
profile: "{{ interface }}"
lsr_fail_debug:
- __network_connections_result
tasks:
- debug:
msg: "this is: playbooks/tests_dummy.yml"
tags:
- always
- block:
- include_tasks: tasks/run_test.yml
vars:
lsr_description: Create a dummy interface
lsr_setup:
- tasks/delete_interface.yml
- tasks/assert_device_absent.yml
lsr_test:
- tasks/create_dummy_profile.yml
lsr_assert:
- tasks/assert_profile_present.yml
- tasks/assert_device_present.yml
lsr_cleanup:
- tasks/cleanup_profile+device.yml
tags:
- tests::dummy:create

View File

@@ -0,0 +1,110 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
- name: Test configuring ethernet devices
hosts: all
vars:
type: veth
interface: ethtest0
tasks:
- name: "set type={{ type }} and interface={{ interface }}"
set_fact:
type: "{{ type }}"
interface: "{{ interface }}"
- include_tasks: tasks/show_interfaces.yml
- include_tasks: tasks/manage_test_interface.yml
vars:
state: present
- include_tasks: tasks/assert_device_present.yml
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
interface_name: "{{ interface }}"
state: up
type: ethernet
autoconnect: yes
ip:
route_metric4: 100
dhcp4: no
gateway4: 192.0.2.1
dns:
- 192.0.2.2
- 198.51.100.5
dns_search:
- example.com
- example.org
dns_options:
- rotate
- timeout:1
route_metric6: -1
auto6: no
gateway6: 2001:db8::1
address:
- 192.0.2.3/24
- 198.51.100.3/26
- 2001:db8::80/7
route:
- network: 198.51.100.128
prefix: 26
gateway: 198.51.100.1
metric: 2
- network: 198.51.100.64
prefix: 26
gateway: 198.51.100.6
metric: 4
route_append_only: no
rule_append_only: yes
- name: Verify nmcli connection DNS entry
shell: |
set -euxo pipefail
nmcli connection show {{ interface }} | grep ipv4.dns
register: ipv4_dns
ignore_errors: yes
- name: "Assert that DNS addresses are configured correctly"
assert:
that:
- "'192.0.2.2' in ipv4_dns.stdout"
- "'198.51.100.5' in ipv4_dns.stdout"
msg: "DNS addresses are configured incorrectly"
- name: "Assert that DNS search domains are configured correctly"
assert:
that:
- "'example.com' in ipv4_dns.stdout"
- "'example.org' in ipv4_dns.stdout"
msg: "DNS search domains are configured incorrectly"
- name: "Assert that DNS options are configured correctly"
assert:
that:
- "'rotate' in ipv4_dns.stdout"
- "'timeout:1' in ipv4_dns.stdout"
msg: "DNS options are configured incorrectly"
- import_playbook: down_profile.yml
vars:
profile: "{{ interface }}"
# FIXME: assert profile/device down
- import_playbook: remove_profile.yml
vars:
profile: "{{ interface }}"
# FIXME: assert profile away
- name: Remove interfaces
hosts: all
tasks:
- include_tasks: tasks/manage_test_interface.yml
vars:
state: absent
- include_tasks: tasks/assert_device_absent.yml
...

View File

@@ -0,0 +1,64 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
tasks:
- debug:
msg: Inside ethernet tests
- debug:
var: network_provider
- name: Test configuring ethernet devices
hosts: all
vars:
type: veth
interface: lsr27
tasks:
- name: "set type={{ type }} and interface={{ interface }}"
set_fact:
type: "{{ type }}"
interface: "{{ interface }}"
- include_tasks: tasks/show_interfaces.yml
- include_tasks: tasks/manage_test_interface.yml
vars:
state: present
- include_tasks: tasks/assert_device_present.yml
- name: Test static interface up
hosts: all
vars:
network_connections:
- name: "{{ interface }}"
interface_name: "{{ interface }}"
state: up
type: ethernet
autoconnect: yes
ip:
address: 192.0.2.1/24
roles:
- linux-system-roles.network
tasks:
- include_tasks: tasks/assert_output_in_stderr_without_warnings.yml
- hosts: all
tasks:
- debug:
var: network_provider
# FIXME: assert profile present
# FIXME: assert profile/device up + IP address
- import_playbook: down_profile.yml
vars:
profile: "{{ interface }}"
# FIXME: assert profile/device down
- import_playbook: remove_profile.yml
vars:
profile: "{{ interface }}"
# FIXME: assert profile away
- name: Remove interfaces
hosts: all
tasks:
- include_tasks: tasks/manage_test_interface.yml
vars:
state: absent
- include_tasks: tasks/assert_device_absent.yml

View File

@@ -0,0 +1,102 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
vars:
interface: testnic1
type: veth
tasks:
- debug:
msg: "this is: playbooks/tests_ethtool_.coalesceyml"
tags:
- always
- name: "INIT: Ethtool coalesce tests"
debug:
msg: "##################################################"
- include_tasks: tasks/show_interfaces.yml
- include_tasks: tasks/manage_test_interface.yml
vars:
state: present
- include_tasks: tasks/assert_device_present.yml
- name: Install ethtool (test dependency)
package:
name: ethtool
state: present
- block:
- name: >-
TEST: I can create a profile without any coalescing option.
debug:
msg: "##################################################"
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
type: ethernet
autoconnect: no
ip:
dhcp4: no
auto6: no
- name: Get profile's coalescing options
command: nmcli -g ethtool.coalesce-rx-frames c show {{ interface }}
register: no_coalesce
- name: "ASSERT: The profile does not contain coalescing options"
assert:
that: no_coalesce.stdout == ""
- name: >-
TEST: I can set rx-frames.
debug:
msg: "##################################################"
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
type: ethernet
autoconnect: no
ip:
dhcp4: no
auto6: no
ethtool:
coalesce:
rx_frames: 128
- name: Get profile's coalescing options
command: nmcli -g ethtool.coalesce-rx-frames c show {{ interface }}
register: with_coalesce
- name: Assert coalesce options set in profile
assert:
that: with_coalesce.stdout == '128'
- name: "TEST: I can clear coalescing options"
debug:
msg: "##################################################"
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
type: ethernet
autoconnect: no
ip:
dhcp4: no
auto6: no
- name: Get profile's coalescing options
command: nmcli -g ethtool.coalesce-rx-frames c show {{ interface }}
register: profile
- name: "ASSERT: The profile does reset coalescing options"
assert:
that: no_coalesce.stdout == ""
always:
- block:
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
persistent_state: absent
ignore_errors: true
- include_tasks: tasks/manage_test_interface.yml
vars:
state: absent
tags:
- "tests::cleanup"

View File

@@ -0,0 +1,94 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
vars:
type: veth
interface: veth0
tasks:
- include_tasks: tasks/show_interfaces.yml
- include_tasks: tasks/manage_test_interface.yml
vars:
state: present
- name: Set up gateway ip on veth peer
shell: |
ip netns add ns1
ip link set peer{{ interface }} netns ns1
ip netns exec ns1 ip -6 addr add 2001:db8::1/32 dev peer{{ interface }}
ip netns exec ns1 ip link set peer{{ interface }} up
when:
# netns not available on RHEL/CentOS 6
- ansible_distribution_major_version != '6'
- block:
- name: >-
TEST: I can configure an interface with static ipv6 config
debug:
msg: "##################################################"
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
type: ethernet
state: up
ip:
dhcp4: false
auto6: false
address:
- "2001:db8::2/32"
- "2001:db8::3/32"
- "2001:db8::4/32"
gateway6: "2001:db8::1"
- include_tasks: tasks/assert_device_present.yml
- include_tasks: tasks/assert_profile_present.yml
vars:
profile: "{{ interface }}"
- name: Get ip address information
command: "ip addr show {{ interface }}"
register: ip_addr
- name:
debug:
var: ip_addr.stdout
- name: Assert ipv6 addresses are correctly set
assert:
that:
- >-
'inet6 2001:db8::2/32' in ip_addr.stdout
- >-
'inet6 2001:db8::3/32' in ip_addr.stdout
- >-
'inet6 2001:db8::4/32' in ip_addr.stdout
- name: Get ipv6 routes
command: "ip -6 route"
register: ipv6_route
- name:
debug:
var: ipv6_route.stdout
- name: Assert default ipv6 route is set
assert:
that:
- >-
"default via 2001:db8::1 dev {{ interface }}"
in ipv6_route.stdout
- name: Test gateway can be pinged
command: ping6 -c1 2001:db8::1
when:
- ansible_distribution_major_version != '6'
always:
- name: "TEARDOWN: remove profiles."
debug:
msg: "##################################################"
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
persistent_state: absent
state: down
ignore_errors: true
- include_tasks: tasks/manage_test_interface.yml
vars:
state: absent
- name: Clean up namespace
command: ip netns delete ns1
when:
- ansible_distribution_major_version != '6'

View File

@@ -0,0 +1,60 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
- name: Test configuring ethernet devices
hosts: all
vars:
type: veth
interface: ethtest0
tasks:
- name: "set type={{ type }} and interface={{ interface }}"
set_fact:
type: "{{ type }}"
interface: "{{ interface }}"
- include_tasks: tasks/show_interfaces.yml
- include_tasks: tasks/manage_test_interface.yml
vars:
state: present
- include_tasks: tasks/assert_device_present.yml
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
interface_name: "{{ interface }}"
type: ethernet
ip:
ipv6_disabled: true
- name: Verify nmcli connection ipv6.method
shell: |
set -euxo pipefail
nmcli connection show {{ interface }} | grep ipv6.method
register: ipv6_method
ignore_errors: yes
- name: "Assert that ipv6.method disabled is configured correctly"
assert:
that:
- "'disabled' in ipv6_method.stdout"
msg: "ipv6.method disabled is configured incorrectly"
- import_playbook: down_profile.yml
vars:
profile: "{{ interface }}"
# FIXME: assert profile/device down
- import_playbook: remove_profile.yml
vars:
profile: "{{ interface }}"
# FIXME: assert profile away
- name: Remove interfaces
hosts: all
tasks:
- include_tasks: tasks/manage_test_interface.yml
vars:
state: absent
- include_tasks: tasks/assert_device_absent.yml
...

View File

@@ -0,0 +1,35 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
vars:
interface: testnic1
profile: "{{ interface }}"
lsr_fail_debug:
- __network_connections_result
tasks:
- debug:
msg: "this is: playbooks/tests_states.yml"
tags:
- always
- block:
- include_tasks: tasks/run_test.yml
vars:
state: present
lsr_description: I can manage a veth interface with NM after I
managed it with initscripts.
lsr_setup:
- tasks/setup_test_interface.yml
# run role once with defaults but nm provider to ensure that
# NetworKManager is running
- tasks/provider/default_with_nm.yml
- tasks/provider/create_and_remove_with_initscripts.yml
lsr_test:
- tasks/provider/create_with_nm.yml
lsr_assert:
- tasks/assert_profile_present.yml
lsr_cleanup:
- tasks/cleanup_profile+device.yml
tags:
- tests::provider:initscripts_to_nm

View File

@@ -0,0 +1,66 @@
# SPDX-License-Identifier: BSD-3-Clause
# This test should check whether the NMDevice.reapply method is called by the
# role. This is probably a good candidate to test with pytest directly instead
# of via Ansible. Until there is better test support for this, just check the
# log output for the respective log message.
---
- hosts: all
vars:
interface: rpltstbr
profile: "{{ interface }}"
network_provider: nm
pre_tasks:
- debug:
msg: Inside states tests
- include_tasks: tasks/show_interfaces.yml
- include_tasks: tasks/assert_device_absent.yml
roles:
- linux-system-roles.network
tasks:
- block:
# create test profile
- include_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
state: up
type: bridge
ip:
dhcp4: false
auto6: false
- include_tasks: tasks/assert_device_present.yml
- include_tasks: tasks/assert_profile_present.yml
# Use internal module to get output
- network_connections:
provider: nm
connections:
- name: "{{ interface }}"
state: up
type: bridge
ip:
address:
- 192.0.2.72/31
dhcp4: false
auto6: false
ignore_errors: true
register: test_module_run
- debug:
var: test_module_run
- name: Assert that reapply is found in log output
assert:
fail_msg: Reapply not found in log output
that: "{{ 'connection reapplied' in test_module_run.stderr }}"
always:
- block:
# Use internal module directly for speedup
- network_connections:
provider: nm
connections:
- name: "{{ interface }}"
persistent_state: absent
state: down
- command: ip link del "{{ interface }}"
ignore_errors: true
tags:
- "tests::cleanup"

View File

@@ -0,0 +1,30 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
vars:
interface: team0
profile: "{{ interface }}"
lsr_fail_debug:
- __network_connections_result
tasks:
- debug:
msg: "this is: playbooks/tests_team.yml"
tags:
- always
- block:
- include_tasks: tasks/run_test.yml
vars:
lsr_description: Create a team interface without any port attached
lsr_setup:
- tasks/delete_interface.yml
- tasks/assert_device_absent.yml
lsr_test:
- tasks/create_team_profile.yml
lsr_assert:
- tasks/assert_profile_present.yml
- tasks/assert_device_present.yml
lsr_cleanup:
- tasks/cleanup_profile+device.yml
tags:
- tests::team:create

View File

@@ -0,0 +1,40 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
tasks:
- name: remove the NetworkManager-team package
package:
name: "NetworkManager-team"
state: absent
- name: "get the rpm package facts"
package_facts:
manager: "auto"
- name: "Assert NetworkManager-team removed before team configuration"
assert:
that:
- "'NetworkManager-team' not in ansible_facts.packages"
msg: "NetworkManager-team is not removed before team configuration"
- name: "Team interface configuration"
include_role:
name: linux-system-roles.network
vars:
network_connections:
# Specify the team profile
- name: team0
persistent_state: present
type: team
interface_name: team0
- name: "get the rpm package facts"
package_facts:
manager: "auto"
- name: "Assert NetworkManager-team is installed after team configuration"
assert:
that:
- "'NetworkManager-team' in ansible_facts.packages"
msg: "NetworkManager-team is not installed after team configuration"
...

View File

@@ -0,0 +1,88 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
vars:
interface: wlan0
tasks:
- name: "INIT: wireless tests"
debug:
msg: "##################################################"
- include_tasks: tasks/setup_mock_wifi.yml
- name: Copy client certs
copy:
src: "{{ item }}"
dest: "/etc/pki/tls/{{ item }}"
mode: 0644
with_items:
- client.key
- client.pem
- cacert.pem
- block:
- name: "TEST: wireless connection with WPA-PSK"
debug:
msg: "##################################################"
- import_role:
name: linux-system-roles.network
vars:
network_allow_restart: true
network_connections:
- name: "{{ interface }}"
state: up
type: wireless
ip:
address:
- 203.0.113.2/24
dhcp4: "no"
auto6: "no"
wireless:
ssid: "mock_wifi"
key_mgmt: "wpa-psk"
password: "p@55w0rD"
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
persistent_state: absent
state: down
- name: "TEST: wireless connection with 802.1x TLS-EAP"
debug:
msg: "##################################################"
- import_role:
name: linux-system-roles.network
vars:
network_allow_restart: true
network_connections:
- name: "{{ interface }}"
state: up
type: wireless
ip:
address:
- 203.0.113.2/24
dhcp4: "no"
auto6: "no"
wireless:
ssid: "mock_wifi"
key_mgmt: "wpa-eap"
ieee802_1x:
identity: myhost
eap: tls
private_key: /etc/pki/tls/client.key
private_key_password: test
private_key_password_flags:
- none
client_cert: /etc/pki/tls/client.pem
ca_cert: /etc/pki/tls/cacert.pem
always:
- block:
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
persistent_state: absent
state: down
ignore_errors: true
- include_tasks: tasks/cleanup_mock_wifi.yml
tags:
- "tests::cleanup"

View File

@@ -0,0 +1,40 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
tasks:
- name: remove the NetworkManager-wifi package
package:
name: "NetworkManager-wifi"
state: absent
- name: "get the rpm package facts"
package_facts:
manager: "auto"
- name: "Assert NetworkManager-wifi removed before wireless configuration"
assert:
that:
- "'NetworkManager-wifi' not in ansible_facts.packages"
msg: "NetworkManager-wifi is not removed before wirelss configuration"
- name: "wireless configuration"
include_role:
name: linux-system-roles.network
vars:
network_connections:
- name: wlan0
type: wireless
wireless:
ssid: "My WPA2-PSK Network"
key_mgmt: "wpa-psk"
password: "p@55w0rD"
- name: "get the rpm package facts"
package_facts:
manager: "auto"
- name: "Assert NetworkManager-wifi installed after wireless configuration"
assert:
that:
- "'NetworkManager-wifi' in ansible_facts.packages"
msg: "NetworkManager-wifi is not installed after wireless configured"

View File

@@ -0,0 +1,41 @@
#!/bin/bash
# SPDX-License-Identifier: MIT
set -euo pipefail
if [ -n "${DEBUG:-}" ] ; then
set -x
fi
if [ ! -d "${1:-}" ] ; then
echo Either ansible is not installed, or there is no ansible/module_utils
echo in $1 - Skipping
exit 0
fi
if [ ! -d "${2:-}" ] ; then
echo Role has no module_utils - Skipping
exit 0
fi
# we need absolute path for $2
absmoddir=$( readlink -f "$2" )
# clean up old links to module_utils
for item in "$1"/* ; do
if lnitem=$( readlink "$item" ) && test -n "$lnitem" ; then
case "$lnitem" in
*"${2}"*) rm -f "$item" ;;
esac
fi
done
# add new links to module_utils
for item in "$absmoddir"/* ; do
case "$item" in
*__pycache__) continue;;
*.pyc) continue;;
esac
bnitem=$( basename "$item" )
ln -s "$item" "$1/$bnitem"
done

View File

@@ -0,0 +1,9 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
state: up
...

View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include: get_interface_stat.yml
- name: "assert that interface {{ interface }} is absent"
assert:
that: not interface_stat.stat.exists
msg: "{{ interface }} exists"

View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include: get_interface_stat.yml
- name: "assert that interface {{ interface }} is present"
assert:
that: interface_stat.stat.exists
msg: "{{ interface }} does not exist"

View File

@@ -0,0 +1,12 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: "Assert that warnings is empty"
assert:
that:
- "'warnings' not in __network_connections_result"
msg: "There are unexpected warnings"
- name: "Assert that there is output in stderr"
assert:
that:
- "'stderr' in __network_connections_result"
msg: "There are no messages in stderr"

View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include: get_profile_stat.yml
- name: "assert that profile '{{ profile }}' is absent"
assert:
that: not lsr_net_profile_exists
msg: "profile {{ profile }} does exist"

View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include: get_profile_stat.yml
- name: "assert that profile '{{ profile }}' is present"
assert:
that: lsr_net_profile_exists
msg: "profile {{ profile }} does not exist"

View File

@@ -0,0 +1,19 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Remove test interfaces
shell: |
ip netns delete ns1
ip link delete veth1-br
ip link delete veth2-br
ip link delete br1
- name: Kill hostapd process
shell: pkill hostapd
- name: Remove certs and config
file:
state: absent
path: "{{ item }}"
with_items:
- /etc/pki/tls/hostapd_test
- /etc/hostapd/wired.conf
- /etc/hostapd/hostapd.eap_user

View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Unload mac80211_hwsim module
shell: modprobe -r mac80211_hwsim
- name: Kill hostapd process
shell: pkill hostapd

View File

@@ -0,0 +1,9 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- shell: |
nmcli con delete {{ interface }}
nmcli con load /etc/sysconfig/network-scripts/ifcfg-{{ interface }}
rm -f /etc/sysconfig/network-scripts/ifcfg-{{ interface }}
ip link del {{ interface }}
ignore_errors: true
...

View File

@@ -0,0 +1,20 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include_tasks: show_interfaces.yml
- include_tasks: manage_test_interface.yml
vars:
state: absent
- include_tasks: show_interfaces.yml
- include_tasks: assert_device_absent.yml
- include_tasks: manage_test_interface.yml
vars:
state: present
- include_tasks: show_interfaces.yml
- include_tasks: assert_device_present.yml
- include_tasks: manage_test_interface.yml
vars:
state: absent
- include_tasks: show_interfaces.yml
- include_tasks: assert_device_absent.yml

View File

@@ -0,0 +1,15 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
persistent_state: present
type: bridge
ip:
dhcp4: false
auto6: false
- debug:
var: __network_connections_result
...

View File

@@ -0,0 +1,16 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
autoconnect: false
persistent_state: present
type: bridge
ip:
dhcp4: false
auto6: false
- debug:
var: __network_connections_result
...

View File

@@ -0,0 +1,15 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
state: up
type: dummy
ip:
address:
- "192.0.2.42/30"
- debug:
var: __network_connections_result
...

View File

@@ -0,0 +1,15 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
persistent_state: present
type: team
ip:
dhcp4: false
auto6: false
- debug:
var: __network_connections_result
...

View File

@@ -0,0 +1,73 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Install dnsmasq
package:
name: dnsmasq
state: present
- name: Create test interfaces
shell: |
# NM to see veth devices starting with test* as managed after ip add..
echo 'ENV{ID_NET_DRIVER}=="veth",\
ENV{INTERFACE}=="test*", \
ENV{NM_UNMANAGED}="0"' >/etc/udev/rules.d/88-veth.rules
udevadm control --reload-rules
udevadm settle --timeout=5
# Setuptwo devices with IPv4/IPv6 auto support
ip link add {{dhcp_interface1}} type veth peer name {{dhcp_interface1}}p
ip link set {{dhcp_interface1}}p up
ip link add {{dhcp_interface2}} type veth peer name {{dhcp_interface2}}p
ip link set {{dhcp_interface2}}p up
# Create the 'testbr' - providing both 10.x ipv4 and 2620:52:0 ipv6 dhcp
ip link add name testbr type bridge forward_delay 0
ip link set testbr up
ip addr add 192.0.2.1/24 dev testbr
ip -6 addr add 2001:DB8::1/32 dev testbr
if grep 'release 6' /etc/redhat-release; then
# We need bridge-utils and radvd only in rhel6
if ! rpm -q --quiet radvd; then yum -y install radvd; fi
if ! rpm -q --quiet bridge-utils; then yum -y install bridge-utils; fi
# We need to add iptables rule to allow dhcp request
iptables -I INPUT -i testbr -p udp --dport 67:68 --sport 67:68 -j ACCEPT
# Add {{dhcp_interface1}}, {{dhcp_interface2}} peers into the testbr
brctl addif testbr {{dhcp_interface1}}p
brctl addif testbr {{dhcp_interface2}}p
# in RHEL6 /run is not present
mkdir -p /run
# and dnsmasq does not support ipv6
dnsmasq \
--pid-file=/run/dhcp_testbr.pid \
--dhcp-leasefile=/run/dhcp_testbr.lease \
--dhcp-range=192.0.2.1,192.0.2.254,240 \
--interface=testbr --bind-interfaces
# start radvd for ipv6
echo 'interface testbr {' > /etc/radvd.conf
echo ' AdvSendAdvert on;' >> /etc/radvd.conf
echo ' prefix 2001:DB8::/64 { ' >> /etc/radvd.conf
echo ' AdvOnLink on; }; ' >> /etc/radvd.conf
echo ' }; ' >> /etc/radvd.conf
# enable ipv6 forwarding
sysctl -w net.ipv6.conf.all.forwarding=1
service radvd restart
else
ip link set {{dhcp_interface1}}p master testbr
ip link set {{dhcp_interface2}}p master testbr
# Run joint DHCP4/DHCP6 server with RA enabled in veth namespace
dnsmasq \
--pid-file=/run/dhcp_testbr.pid \
--dhcp-leasefile=/run/dhcp_testbr.lease \
--dhcp-range=192.0.2.1,192.0.2.254,240 \
--dhcp-range=2001:DB8::10,2001:DB8::1FF,slaac,64,240 \
--enable-ra --interface=testbr --bind-interfaces
fi

View File

@@ -0,0 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: remove test interface if necessary
command: "ip link del {{ interface }}"
ignore_errors: true
...

View File

@@ -0,0 +1,26 @@
# SPDX-License-Identifier: BSD-3-Clause
- name: Fix CentOS6 Base repo
copy:
dest: /etc/yum.repos.d/CentOS-Base.repo
content: |
[base]
name=CentOS-$releasever - Base
baseurl=https://vault.centos.org/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[updates]
name=CentOS-$releasever - Updates
baseurl=https://vault.centos.org/6.10/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[extras]
name=CentOS-$releasever - Extras
baseurl=https://vault.centos.org/6.10/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
when:
- ansible_distribution == 'CentOS'
- ansible_distribution_major_version == '6'
- include_tasks: enable_epel.yml

View File

@@ -0,0 +1,24 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Enable EPEL {{ ansible_distribution_major_version }}
# yamllint disable-line rule:line-length
command: yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm
args:
warn: false
creates: /etc/yum.repos.d/epel.repo
when:
- ansible_distribution in ['RedHat', 'CentOS']
- ansible_distribution_major_version in ['7', '8']
- name: Enable EPEL 6
copy:
dest: /etc/yum.repos.d/epel.repo
content: |
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
baseurl=https://archives.fedoraproject.org/pub/archive/epel/6/$basearch
enabled=1
gpgcheck=0
when:
- ansible_distribution in ['RedHat', 'CentOS']
- ansible_distribution_major_version == '6'

View File

@@ -0,0 +1,19 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- block:
- name: Get NetworkManager RPM version
command:
cmd: rpm -qa --qf '%{name}-%{version}-%{release}\n' NetworkManager
warn: false
register: __rpm_q_NetworkManager
- name: Store NetworkManager version
set_fact:
NetworkManager_NVR: "{{ __rpm_q_NetworkManager.stdout }}"
- name: Show NetworkManager version
debug:
var: NetworkManager_NVR
tags:
- always
...

View File

@@ -0,0 +1,8 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- command: ls -1
args:
chdir: /sys/class/net
register: _current_interfaces
- set_fact:
current_interfaces: "{{ _current_interfaces.stdout_lines }}"

View File

@@ -0,0 +1,9 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: "Get stat for interface {{ interface }}"
stat:
get_attributes: false
get_checksum: false
get_mime: false
path: "/sys/class/net/{{ interface }}"
register: interface_stat

View File

@@ -0,0 +1,92 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: set collection paths
set_fact:
collection_paths: |
{{
(lookup("env","ANSIBLE_COLLECTIONS_PATH").split(":") +
lookup("env","ANSIBLE_COLLECTIONS_PATHS").split(":") +
lookup("config", "COLLECTIONS_PATHS")) |
select | list
}}
- name: set search paths
set_fact:
modules_search_path: |
{{
(lookup("env", "ANSIBLE_LIBRARY").split(":") +
["../../library", "../library"] +
lookup("config", "DEFAULT_MODULE_PATH")) |
select | list
}}
module_utils_search_path: |
{{
(lookup("env", "ANSIBLE_MODULE_UTILS").split(":") +
["../../module_utils", "../module_utils"] +
lookup("config", "DEFAULT_MODULE_UTILS_PATH")) |
select | list
}}
# the output should be something like
# - path to parent directory to chdir to in order to use tar
# - relative path under parent directory to tar
# e.g. for the local role case
# - ../..
# - library
# would translate to tar -C ../.. library
# for the collection case
# - /home/user/.ansible/collections
# - ansible_collections/fedora/linux_system_roles/plugins/modules
# would translate to tar -C /home/user/.ansible/collections \
# ansible_collections/fedora/linux_system_roles/plugins/modules
- name: find parent directory and path of modules
shell: |
set -euxo pipefail
for dir in {{ modules_search_path | join(" ") }}; do
if [ -f "$dir/network_connections.py" ]; then
readlink -f "$(dirname "$dir")"
basename "$dir"
exit 0
fi
done
for dir in {{ collection_paths | join(" ") }}; do
if [ ! -d "$dir" ]; then continue; fi
cd "$dir"
for subdir in ansible_collections/*/*/plugins/modules; do
if [ -f "$subdir/network_connections.py" ]; then
echo "$dir"
echo "$subdir"
exit 0
fi
done
done
echo network_connections.py not found
exit 1
delegate_to: localhost
register: modules_parent_and_dir
- name: find parent directory and path of module_utils
shell: |
set -euxo pipefail
for dir in {{ module_utils_search_path | join(" ") }}; do
if [ -d "$dir/network_lsr" ]; then
readlink -f "$(dirname "$dir")"
basename "$dir"
exit 0
fi
done
for dir in {{ collection_paths | join(" ") }}; do
if [ ! -d "$dir" ]; then continue; fi
cd "$dir"
for subdir in ansible_collections/*/*/plugins/module_utils; do
if [ -d "$subdir/network_lsr" ]; then
echo "$dir"
echo "$subdir"
exit 0
fi
done
done
echo network_lsr not found
exit 1
delegate_to: localhost
register: module_utils_parent_and_dir

View File

@@ -0,0 +1,24 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- set_fact: lsr_net_profile_exists=false
- name: stat profile file
stat:
get_attributes: false
get_checksum: false
get_mime: false
path: /etc/sysconfig/network-scripts/ifcfg-{{ profile }}
register: profile_stat
- set_fact: lsr_net_profile_exists=true
when: profile_stat.stat.exists
# When certain profile is marked as absent but still up, the `nmcli connection`
# still show it with FILENAME starting with /run. Only consider profile exists
# when its FILENAME is in /etc folder
- shell: nmcli -f NAME,FILENAME connection show |grep {{ profile }} | grep /etc
register: nm_profile_exists
ignore_errors: yes
- set_fact: lsr_net_profile_exists=true
when: nm_profile_exists.rc == 0

View File

@@ -0,0 +1,59 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- fail:
msg: "state needs to be present or absent, not '{{ state }}'"
when: state not in ["present", "absent"]
- fail:
msg: "type needs to be dummy, tap or veth, not '{{ type }}'"
when: type not in ["dummy", "tap", "veth"]
- include: show_interfaces.yml
- name: Install iproute
package:
name: iproute
state: present
# veth
- name: Create veth interface {{ interface }}
command: "{{ item }}"
with_items:
- ip link add {{ interface }} type veth peer name peer{{ interface }}
- ip link set peer{{ interface }} up
- ip link set {{ interface }} up
when: "type == 'veth' and state == 'present' and
interface not in current_interfaces"
- name: Set up veth as managed by NetworkManager
shell: nmcli d set {{ interface }} managed true
# The varible for `network_provider` is not exists yet,
# just ignore error for initscripts
ignore_errors: yes
when: "type == 'veth' and state == 'present'"
- name: Delete veth interface {{ interface }}
command: ip link del {{ interface }} type veth
when: "type == 'veth' and state == 'absent' and
interface in current_interfaces"
# dummy
- name: Create dummy interface {{ interface }}
command: ip link add "{{ interface }}" type dummy
when: "type == 'dummy' and state == 'present' and
interface not in current_interfaces"
- name: Delete dummy interface {{ interface }}
command: ip link del "{{ interface }}" type dummy
when: "type == 'dummy' and state == 'absent' and
interface in current_interfaces"
# tap
- name: Create tap interface {{ interface }}
command: ip tuntap add dev {{ interface }} mode tap
when: "type == 'tap' and state == 'present'
and interface not in current_interfaces"
- name: Delete tap interface {{ interface }}
command: ip tuntap del dev {{ interface }} mode tap
when: "type == 'tap' and state == 'absent' and
interface in current_interfaces"

View File

@@ -0,0 +1,23 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
state: up
persistent_state: present
type: ethernet
autoconnect: yes
ip:
address: 192.0.2.1/24
network_provider: initscripts
- include_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
state: down
persistent_state: absent
network_provider: initscripts
...

View File

@@ -0,0 +1,15 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
state: up
persistent_state: present
type: ethernet
autoconnect: yes
ip:
address: 192.0.2.1/24
network_provider: nm
...

View File

@@ -0,0 +1,8 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include_role:
name: linux-system-roles.network
vars:
network_connections: []
network_provider: nm
...

View File

@@ -0,0 +1,10 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
persistent_state: absent
state: down
...

View File

@@ -0,0 +1,9 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
persistent_state: absent
...

View File

@@ -0,0 +1,25 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Remove test interfaces
shell: |
ip link delete {{dhcp_interface1}}
ip link delete {{dhcp_interface2}}
ip link delete testbr
# Remove udev rule for NM to see veth devices starting with test*.....
rm -rf /etc/udev/rules.d/88-veth.rules
udevadm control --reload-rules
udevadm settle --timeout=5
- name: Stop dnsmasq/radvd services
shell: |
pkill -F /run/dhcp_testbr.pid
rm -rf /run/dhcp_testbr.pid
rm -rf /run/dhcp_testbr.lease
if grep 'release 6' /etc/redhat-release; then
# Stop radvd server
service radvd stop
iptables -D INPUT -i testbr -p udp --dport 67:68 --sport 67:68 -j ACCEPT
fi

View File

@@ -0,0 +1,68 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Run test
block:
- name: "TEST: {{ lsr_description }}"
debug:
msg: "########## {{ lsr_description }} ##########"
- debug:
var: "{{ item }}"
loop:
- lsr_description
- lsr_setup
- lsr_test
- lsr_assert
- lsr_assert_when
- lsr_fail_debug
- lsr_cleanup
- include_tasks: tasks/show_interfaces.yml
- name: setup
include_tasks: "{{ item }}"
loop: "{{ lsr_setup }}"
tags:
- "tests::setup"
- name: test
include_tasks: "{{ item }}"
loop: "{{ lsr_test }}"
tags:
- "tests::test"
- name: asserts
include_tasks: "{{ item }}"
loop: "{{ lsr_assert }}"
tags:
- "tests::assert"
- name: conditional asserts
include_tasks: "{{ item['what'] }}"
when:
- "{{ item['when'] }}"
loop: "{{ lsr_assert_when|default([]) }}"
- name: "Success in test '{{ lsr_description }}'"
debug:
msg: "+++++ Success in test '{{ lsr_description }}' +++++"
rescue:
- name: "Failure in test '{{ lsr_description }}'"
debug:
msg: "!!!!! Failure in test '{{ lsr_description }}' !!!!!"
- debug:
var: "{{ item }}"
loop: "{{ lsr_fail_debug | default([]) }}"
- fail:
msg: "!!!!! Failure in test '{{ lsr_description }}' !!!!!"
always:
- name: cleanup
include_tasks: "{{ item }}"
loop: "{{ lsr_cleanup }}"
tags:
- "tests::cleanup"
...

View File

@@ -0,0 +1,11 @@
- include_tasks: tasks/setup_802_1x_server.yml
- name: Copy client certs
copy:
src: "{{ item }}"
dest: "/etc/pki/tls/{{ item }}"
mode: 0644
with_items:
- client.key
- client.key.nocrypt
- client.pem
- cacert.pem

View File

@@ -0,0 +1,75 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Install hostapd
package:
name: hostapd
state: present
- name: Create directory for test certificates
file:
state: directory
path: /etc/pki/tls/hostapd_test
- name: Copy server certificates
copy:
src: "{{ item }}"
dest: "/etc/pki/tls/hostapd_test/{{ item }}"
with_items:
- server.key
- dh.pem
- server.pem
- cacert.pem
- name: Create test interfaces
shell: |
ip link add veth1 type veth peer name veth1-br
ip link add veth2 type veth peer name veth2-br
ip link add br1 type bridge
ip link set br1 up
ip netns add ns1
ip link set veth1 netns ns1
ip netns exec ns1 ip addr add 203.0.113.1/24 dev veth1
ip link set veth1-br up
ip link set veth2-br up
ip link set veth1-br master br1
ip link set veth2-br master br1
ip netns exec ns1 ip link set veth1 up
ip link set veth2 up
# Enable forwarding of EAP 802.1x messages through software bridge "br1".
echo 8 > /sys/class/net/br1/bridge/group_fwd_mask
- name: Create hostapd config
copy:
content: |
interface=veth1
driver=wired
debug=2
ieee8021x=1
eap_reauth_period=3600
eap_server=1
use_pae_group_addr=1
eap_user_file=/etc/hostapd/hostapd.eap_user
ca_cert=/etc/pki/tls/hostapd_test/cacert.pem
dh_file=/etc/pki/tls/hostapd_test/dh.pem
server_cert=/etc/pki/tls/hostapd_test/server.pem
private_key=/etc/pki/tls/hostapd_test/server.key
private_key_passwd=test
logger_syslog=-1
logger_syslog_level=0
dest: /etc/hostapd/wired.conf
- name: Create eap_user_file config
copy:
content: |
* TLS
dest: /etc/hostapd/hostapd.eap_user
- name: Run hostapd in namespace
shell: ip netns exec ns1 hostapd -B /etc/hostapd/wired.conf && sleep 5

View File

@@ -0,0 +1,82 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Install packages required to set up mock wifi network
package:
name:
- hostapd
- NetworkManager
- wpa_supplicant
state: present
- name: Ensure NetworkManager is running
service:
name: NetworkManager
state: started
- name: Copy server certificates
copy:
src: "{{ item }}"
dest: "/etc/pki/tls/{{ item }}"
with_items:
- server.key
- dh.pem
- server.pem
- cacert.pem
- name: Create hostapd config
copy:
content: |
interface=wlan1
driver=nl80211
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
ssid=mock_wifi
country_code=EN
hw_mode=g
channel=7
auth_algs=3
wpa=3
ieee8021x=1
eapol_version=1
wpa_key_mgmt=WPA-EAP WPA-PSK
wpa_passphrase=p@55w0rD
eap_reauth_period=3600
eap_server=1
use_pae_group_addr=1
eap_user_file=/etc/hostapd/hostapd.eap_user
ca_cert=/etc/pki/tls/cacert.pem
dh_file=/etc/pki/tls/dh.pem
server_cert=/etc/pki/tls/server.pem
private_key=/etc/pki/tls/server.key
private_key_passwd=test
logger_syslog=-1
logger_syslog_level=0
dest: /etc/hostapd/wireless.conf
- name: Create eap_user_file config
copy:
content: |
* TLS
dest: /etc/hostapd/hostapd.eap_user
- name: Load mac80211_hwsim kernel module to mock a wifi network
shell: modprobe mac80211_hwsim && sleep 5
- name: Restart NetworkManager and wpa_supplicant
service:
name: "{{ item }}"
state: restarted
with_items:
- NetworkManager
- wpa_supplicant
- name: Configure wlan0 and wlan1 (mock wifi interfaces)
shell: |
ip link set up wlan0
ip link set up wlan1
nmcli device set wlan1 managed off
ip add add 203.0.113.1/24 dev wlan1
sleep 5
- name: Start hostapd
shell: hostapd -B /etc/hostapd/wireless.conf && sleep 5

View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include_tasks: tasks/manage_test_interface.yml
vars:
state: present
type: veth
...

View File

@@ -0,0 +1,5 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- include: get_current_interfaces.yml
- debug:
msg: "current_interfaces: {{ current_interfaces }}"

View File

@@ -0,0 +1,108 @@
---
- name: >-
TEST: 802.1x profile with unencrypted private key and ca_path
debug:
msg: "##################################################"
- set_fact:
# Fixed versions/NVRs:
# 1.25.2
# NetworkManager-1.24.2-1.fc33
# NetworkManager-1.22.14-1.fc32
# NetworkManager-1.20.12-1.fc31
# 1.18.8
__NM_capath_ignored_NVRs:
- NetworkManager-1.18.0-5.el7.x86_64
- NetworkManager-1.18.4-3.el7.x86_64
- NetworkManager-1.20.0-3.el8.x86_64
- NetworkManager-1.22.8-4.el8.x86_64
- NetworkManager-1.20.4-1.fc31.x86_64
- NetworkManager-1.22.10-1.fc32.x86_64
- NetworkManager-1.22.12-1.fc32.x86_64
- name: Create directory for ca_path test
file:
path: "/etc/pki/tls/my_ca_certs"
state: directory
mode: 0755
- name: Copy cacert to ca_path
copy:
src: "cacert.pem"
dest: "/etc/pki/tls/my_ca_certs/cacert.pem"
mode: 0644
- name: Install openssl (test dependency)
package:
name: openssl
state: present
- name: Hash cacert
command: openssl x509 -hash -noout
-in /etc/pki/tls/my_ca_certs/cacert.pem
register: cacert_hash
- name: Add symlink for cacert
file:
state: link
path: "/etc/pki/tls/my_ca_certs/{{ cacert_hash.stdout }}.0"
src: cacert.pem
- name: Get NetworkManager version
command:
cmd: rpm -qa NetworkManager
warn: false
register: __network_NM_NVR
- block:
- import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface | default('802-1x-test') }}"
interface_name: veth2
state: up
type: ethernet
ip:
address:
- 203.0.113.2/24
dhcp4: "no"
auto6: "no"
ieee802_1x:
identity: myhost_capath
eap: tls
private_key: /etc/pki/tls/client.key.nocrypt
client_cert: /etc/pki/tls/client.pem
private_key_password_flags:
- not-required
ca_path: /etc/pki/tls/my_ca_certs
- name: "TEST: I can ping the EAP server"
command: ping -c1 203.0.113.1
- name: trigger failure in case the role did not fail
fail:
msg: after test
rescue:
- debug:
var: "{{ item }}"
with_items:
- ansible_failed_result
- ansible_failed_task
- __network_NM_NVR.stdout
- __NM_capath_ignored_NVRs
- name: Assert role behavior
vars:
expected_failure: __network_NM_NVR.stdout in __NM_capath_ignored_NVRs
failure: __network_connections_result.failed
assert:
that: (failure and expected_failure) or
(not failure and not expected_failure)
msg: "Role {{ failure and 'failed' or 'did not fail' }} but was expected
{{ expected_failure and '' or 'not' }} to fail.
NM NVR: {{ __network_NM_NVR.stdout }}"
- name: Assert role failure
assert:
that: "
'ieee802_1x.ca_path specified but not supported by NetworkManager'
in __network_connections_result.stderr"
when:
- __network_connections_result.failed
- name: Assert ping succeeded
assert:
that:
- "not 'cmd' in ansible_failed_result"
...

View File

@@ -0,0 +1,20 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
# set network provider and gather facts
- hosts: all
name: Run playbook 'playbooks/tests_802_1x.yml' with nm as provider
tasks:
- include_tasks: tasks/el_repo_setup.yml
- name: Set network provider to 'nm'
set_fact:
network_provider: nm
tags:
- always
# The test requires or should run with NetworkManager, therefore it cannot run
# on RHEL/CentOS 6
- import_playbook: playbooks/tests_802_1x.yml
when:
- ansible_distribution_major_version != '6'

View File

@@ -0,0 +1,20 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
# set network provider and gather facts
- hosts: all
name: Run playbook 'playbooks/tests_802_1x_updated.yml' with nm as provider
tasks:
- include_tasks: tasks/el_repo_setup.yml
- name: Set network provider to 'nm'
set_fact:
network_provider: nm
tags:
- always
# The test requires or should run with NetworkManager, therefore it cannot run
# on RHEL/CentOS 6
- import_playbook: playbooks/tests_802_1x_updated.yml
when:
- ansible_distribution_major_version != '6'

View File

@@ -0,0 +1,14 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
- hosts: all
name: Run playbook 'playbooks/tests_bond_deprecated.yml' with initscripts
tasks:
- include_tasks: tasks/el_repo_setup.yml
- name: Set network provider to 'initscripts'
set_fact:
network_provider: initscripts
tags:
- always
- import_playbook: playbooks/tests_bond_deprecated.yml

View File

@@ -0,0 +1,19 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
# set network provider and gather facts
- hosts: all
name: Run playbook 'playbooks/tests_bond_deprecated.yml' with nm as provider
tasks:
- name: Set network provider to 'nm'
set_fact:
network_provider: nm
tags:
- always
# The test requires or should run with NetworkManager, therefore it cannot run
# on RHEL/CentOS 6
- import_playbook: playbooks/tests_bond_deprecated.yml
when:
- ansible_distribution_major_version != '6'

View File

@@ -0,0 +1,14 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
- hosts: all
name: Run playbook 'playbooks/tests_bond.yml' with initscripts as provider
tasks:
- include_tasks: tasks/el_repo_setup.yml
- name: Set network provider to 'initscripts'
set_fact:
network_provider: initscripts
tags:
- always
- import_playbook: playbooks/tests_bond.yml

View File

@@ -0,0 +1,20 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
# set network provider and gather facts
- hosts: all
name: Run playbook 'playbooks/tests_bond.yml' with nm as provider
tasks:
- include_tasks: tasks/el_repo_setup.yml
- name: Set network provider to 'nm'
set_fact:
network_provider: nm
tags:
- always
# The test requires or should run with NetworkManager, therefore it cannot run
# on RHEL/CentOS 6
- import_playbook: playbooks/tests_bond.yml
when:
- ansible_distribution_major_version != '6'

View File

@@ -0,0 +1,14 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
- hosts: all
name: Run playbook 'playbooks/tests_bridge.yml' with initscripts as provider
tasks:
- include_tasks: tasks/el_repo_setup.yml
- name: Set network provider to 'initscripts'
set_fact:
network_provider: initscripts
tags:
- always
- import_playbook: playbooks/tests_bridge.yml

View File

@@ -0,0 +1,20 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
# set network provider and gather facts
- hosts: all
name: Run playbook 'playbooks/tests_bridge.yml' with nm as provider
tasks:
- include_tasks: tasks/el_repo_setup.yml
- name: Set network provider to 'nm'
set_fact:
network_provider: nm
tags:
- always
# The test requires or should run with NetworkManager, therefore it cannot run
# on RHEL/CentOS 6
- import_playbook: playbooks/tests_bridge.yml
when:
- ansible_distribution_major_version != '6'

View File

@@ -0,0 +1,10 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
tasks:
- include_tasks: tasks/el_repo_setup.yml
- name: Set network provider to 'initscripts'
set_fact:
network_provider: initscripts
- import_playbook: tests_default.yml

View File

@@ -0,0 +1,14 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
tasks:
- include_tasks: tasks/el_repo_setup.yml
- name: Set network provider to 'nm'
set_fact:
network_provider: nm
# The test should run with NetworkManager, therefore it cannot run on
# RHEL/CentOS 6
- import_playbook: tests_default.yml
when:
- ansible_distribution_major_version != '6'

View File

@@ -0,0 +1,19 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
# set network provider and gather facts
- hosts: all
name: Run playbook 'playbooks/tests_dummy.yml' with nm as provider
tasks:
- name: Set network provider to 'nm'
set_fact:
network_provider: nm
tags:
- always
# The test requires or should run with NetworkManager, therefore it cannot run
# on RHEL/CentOS 6
- import_playbook: playbooks/tests_dummy.yml
when:
- ansible_distribution_major_version != '6'

View File

@@ -0,0 +1,19 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
# set network provider and gather facts
- hosts: all
name: Run playbook 'playbooks/tests_eth_dns_support.yml' with nm as provider
tasks:
- name: Set network provider to 'nm'
set_fact:
network_provider: nm
tags:
- always
# The test requires or should run with NetworkManager, therefore it cannot run
# on RHEL/CentOS 6
- import_playbook: playbooks/tests_eth_dns_support.yml
when:
- ansible_distribution_major_version != '6'

View File

@@ -0,0 +1,15 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
- hosts: all
name: Run playbook 'playbooks/tests_ethernet.yml' with initscripts as provider
tasks:
- include_tasks: tasks/el_repo_setup.yml
- name: Set network provider to 'initscripts'
set_fact:
network_provider: initscripts
tags:
- always
- import_playbook: playbooks/tests_ethernet.yml

View File

@@ -0,0 +1,21 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
# set network provider and gather facts
- hosts: all
name: Run playbook 'playbooks/tests_ethernet.yml' with nm as provider
tasks:
- include_tasks: tasks/el_repo_setup.yml
- name: Set network provider to 'nm'
set_fact:
network_provider: nm
tags:
- always
# The test requires or should run with NetworkManager, therefore it cannot run
# on RHEL/CentOS 6
- import_playbook: playbooks/tests_ethernet.yml
when:
- ansible_distribution_major_version != '6'

View File

@@ -0,0 +1,41 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
# set network provider and gather facts
- hosts: all
name: Run playbook 'playbooks/tests_ethtool_coalesce.yml' with nm as provider
tasks:
- name: Set network provider to 'nm'
set_fact:
network_provider: nm
tags:
- always
- block:
- name: Install NetworkManager
package:
name: NetworkManager
state: present
- name: Get NetworkManager version
command: rpm -q --qf "%{version}" NetworkManager
args:
warn: false
register: NetworkManager_version
when: true
when:
- ansible_distribution_major_version != '6'
tags:
- always
# workaround for: https://github.com/ansible/ansible/issues/27973
# There is no way in Ansible to abort a playbook hosts with specific OS
# releases Therefore we include the playbook with the tests only if the hosts
# would support it.
# The test requires or should run with NetworkManager, therefore it cannot run
# on RHEL/CentOS 6
- import_playbook: playbooks/tests_ethtool_coalesce.yml
when:
- ansible_distribution_major_version != '6'
- NetworkManager_version.stdout is version('1.25.1', '>=')

View File

@@ -0,0 +1,30 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- name: Check that creating and removing test devices and assertions work
hosts: all
tasks:
- include_tasks: tasks/el_repo_setup.yml
- name: test veth interface management
include_tasks: tasks/create_and_remove_interface.yml
vars:
type: veth
interface: veth1298
- name: test veth interface management
include_tasks: tasks/create_and_remove_interface.yml
vars:
type: dummy
interface: dummy1298
# FIXME: when: does not seem to work with include_tasks, therefore this cannot
# be safely tested for now
# - name: test tap interfaces
# include_tasks: tasks/create_and_remove_interface.yml
# vars:
# - type: tap
# - interface: tap1298
# when: ansible_distribution_major_version > 6
# # ip tuntap does not exist on RHEL6
# # FIXME: Maybe use some other tool to manage devices, openvpn can do
# # this, but it is in EPEL

View File

@@ -0,0 +1,10 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
tasks:
- include_tasks: tasks/el_repo_setup.yml
- import_playbook: playbooks/integration_pytest_python3.yml
when: (ansible_distribution in ["CentOS", "RedHat"] and
ansible_distribution_major_version == "8") or
ansible_distribution == "Fedora"

View File

@@ -0,0 +1,20 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
# set network provider and gather facts
- hosts: all
name: Run playbook 'playbooks/tests_ipv6_disabled.yml' with nm as provider
tasks:
- name: Set network provider to 'nm'
set_fact:
network_provider: nm
tags:
- always
# The test requires or should run with NetworkManager, therefore it cannot run
# on RHEL/CentOS 6
- import_playbook: playbooks/tests_ipv6_disabled.yml
when:
- ansible_distribution_major_version != '6'
- ansible_distribution_major_version == '8'

View File

@@ -0,0 +1,13 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
- hosts: all
name: Run playbook 'playbooks/tests_ipv6.yml' with initscripts as provider
tasks:
- name: Set network provider to 'initscripts'
set_fact:
network_provider: initscripts
tags:
- always
- import_playbook: playbooks/tests_ipv6.yml

View File

@@ -0,0 +1,19 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
# set network provider and gather facts
- hosts: all
name: Run playbook 'playbooks/tests_ipv6.yml' with nm as provider
tasks:
- name: Set network provider to 'nm'
set_fact:
network_provider: nm
tags:
- always
# The test requires or should run with NetworkManager, therefore it cannot run
# on RHEL/CentOS 6
- import_playbook: playbooks/tests_ipv6.yml
when:
- ansible_distribution_major_version != '6'

View File

@@ -0,0 +1,39 @@
# SPDX-License-Identifier: BSD-3-Clause
# This file was generated by ensure_provider_tests.py
---
# set network provider and gather facts
- hosts: all
name: Run playbook 'playbooks/tests_provider.yml' with nm as provider
tasks:
- include_tasks: tasks/el_repo_setup.yml
- name: Set network provider to 'nm'
set_fact:
network_provider: nm
tags:
- always
- block:
- name: Install NetworkManager
package:
name: NetworkManager
state: present
- name: Get NetworkManager version
command: rpm -q --qf "%{version}" NetworkManager
args:
warn: false
register: NetworkManager_version
when: true
when:
- ansible_distribution_major_version != '6'
tags:
- always
# The test requires or should run with NetworkManager, therefore it cannot run
# on RHEL/CentOS 6
- import_playbook: playbooks/tests_provider.yml
when:
- ansible_distribution_major_version != '6'
- NetworkManager_version.stdout is version('1.20.0', '>=')

Some files were not shown because too many files have changed in this diff Show More