Skip to content

Commit 942e01d

Browse files
committed
test: ensure NetworkManager, ensure eth1 is active
This is mainly needed on el7 - NetworkManager is installed by default, or somewhere else, on el8 and later. Additionally, if the NetworkManager-server-config package is installed, then the secondary interface will not be active, so ensure it is active. Signed-off-by: Rich Megginson <[email protected]>
1 parent 6acd803 commit 942e01d

File tree

4 files changed

+86
-2
lines changed

4 files changed

+86
-2
lines changed

tests/ensure_provider_tests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@
8080
"playbooks/tests_infiniband.yml": {},
8181
"playbooks/tests_ipv6_disabled.yml": {},
8282
"playbooks/tests_ipv6_dns_search.yml": {},
83-
"playbooks/tests_mac_address_match.yml": {},
83+
"playbooks/tests_mac_address_match.yml": {
84+
MINIMUM_VERSION: "'1.18.0'",
85+
"comment": "# needs any old version of NM",
86+
},
8487
"playbooks/tests_provider.yml": {
8588
MINIMUM_VERSION: "'1.20.0'",
8689
"comment": "# NetworKmanager 1.20.0 added support for forgetting profiles",

tests/playbooks/tests_mac_address_match.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
tags:
3434
- always
3535

36+
- name: Ensure NetworkManager is running
37+
service:
38+
name: NetworkManager
39+
state: started
40+
3641
- name: Install ethtool (test dependency)
3742
package:
3843
name: ethtool

tests/tasks/find+remove_profile.yml

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,64 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
---
33
- name: Get connection profile for '{{ interface }}'
4-
command: "nmcli -g GENERAL.CONNECTION device show {{ interface }}"
4+
shell:
5+
executable: /bin/bash
6+
cmd: |
7+
set -euo pipefail
8+
connection="$(nmcli -g GENERAL.CONNECTION device show {{ interface | quote }})" || :
9+
if [ -z "$connection" ]; then
10+
nmcli device connect {{ interface | quote }} 1>&2
11+
fi
12+
nmcli -g GENERAL.CONNECTION device show {{ interface | quote }}
513
register: connection_name
614
changed_when: false
715

16+
- name: Debug
17+
shell: |
18+
set -x
19+
exec 1>&2
20+
systemctl status NetworkManager || :
21+
nmcli || :
22+
nmcli device status || :
23+
nmcli device show || :
24+
nmcli connection show || :
25+
nmcli connection show '{{ interface }}' || :
26+
ip a
27+
echo connection_name: {{ connection_name | to_nice_json | quote }} || :
28+
ls -alrtF /etc/sysconfig/network-scripts || :
29+
for file in /etc/sysconfig/network-scripts/ifcfg-*; do
30+
if [ -f "$file" ]; then
31+
echo "file: $file"
32+
cat "$file" || :
33+
fi
34+
done
35+
cat /etc/NetworkManager/NetworkManager.conf || :
36+
find /etc/NetworkManager -type f -ls || :
37+
for file in /etc/NetworkManager/system-connections/*.nmconnection; do
38+
if [ -f "$file" ]; then
39+
echo "file: $file"
40+
cat "$file" || :
41+
fi
42+
done
43+
for file in /etc/NetworkManager/conf.d/*; do
44+
if [ -f "$file" ]; then
45+
echo "file: $file"
46+
cat "$file" || :
47+
fi
48+
done
49+
find /usr/lib/NetworkManager -type f -ls || :
50+
for file in /usr/lib/NetworkManager/conf.d/*; do
51+
if [ -f "$file" ]; then
52+
echo "file: $file"
53+
cat "$file" || :
54+
fi
55+
done
56+
NetworkManager --print-config
57+
journalctl -u NetworkManager || :
58+
changed_when: false
59+
when: connection_name is failed or connection_name.stdout | length == 0
60+
failed_when: connection_name is failed or connection_name.stdout | length == 0
61+
862
- name: Bring down and delete the connection profile for '{{ interface }}'
963
include_role:
1064
name: linux-system-roles.network

tests/tests_mac_address_match_nm.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,32 @@
1414
tags:
1515
- always
1616

17+
- name: Install NetworkManager and get NetworkManager version
18+
when:
19+
- ansible_distribution_major_version != '6'
20+
tags:
21+
- always
22+
block:
23+
- name: Install NetworkManager
24+
package:
25+
name: NetworkManager
26+
state: present
27+
use: "{{ (__network_is_ostree | d(false)) |
28+
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
29+
- name: Get package info
30+
package_facts:
31+
- name: Get NetworkManager version
32+
set_fact:
33+
networkmanager_version: "{{
34+
ansible_facts.packages['NetworkManager'][0]['version'] }}"
35+
1736

1837
# The test requires or should run with NetworkManager, therefore it cannot run
1938
# on RHEL/CentOS 6
39+
# needs any old version of NM
2040
- name: Import the playbook 'playbooks/tests_mac_address_match.yml'
2141
import_playbook: playbooks/tests_mac_address_match.yml
2242
when:
2343
- ansible_distribution_major_version != '6'
44+
45+
- networkmanager_version is version('1.18.0', '>=')

0 commit comments

Comments
 (0)