Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions tests/playbooks/tests_ethernet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,54 @@
debug:
var: network_provider

# FIXME: assert profile present
# FIXME: assert profile/device up + IP address
- name: Get NM connection file
slurp:
src: "/etc/NetworkManager/system-connections/{{ interface }}.nmconnection"
register: nm_connection_file
when:
- network_provider == 'nm'
# RHEL up to 8 uses initscripts backend
- ansible_distribution_major_version | int >= 9
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? Isn't when: network_provider == 'nm' sufficient?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No -- even with the NM backend, NM in RHEL < 9 is configured to store the connections in the old initscripts format; in 9 it moved to the NM-specific /etc/NetworkManager/system-connections/ ini files.


- name: Assert settings in NM connection file
assert:
that:
- "('interface-name=' + interface) in nm_connection_file.content | b64decode"
- "'type=ethernet' in nm_connection_file.content | b64decode"
- "'address1=192.0.2.1/24' in nm_connection_file.content | b64decode"
- "'method=manual' in nm_connection_file.content | b64decode"
when:
- network_provider == 'nm'
# RHEL up to 8 uses initscripts backend
- ansible_distribution_major_version | int >= 9

- name: Get NM connection status
command: "nmcli connection show {{ interface }}"
changed_when: false
register: nm_connection_status
when: network_provider == 'nm'

- name: Assert NM connection status
assert:
that:
- nm_connection_status.stdout is search("ipv4.addresses:\s+192.0.2.1/24")
when: network_provider == 'nm'

- name: Get initscripts connection file
slurp:
src: "/etc/sysconfig/network-scripts/ifcfg-{{ interface }}"
register: initscripts_connection_file
when: network_provider == 'initscripts' or ansible_distribution_major_version | int < 9

- name: Assert settings in initscripts connection file
assert:
that:
- "'TYPE=Ethernet' in initscripts_connection_file.content | b64decode"
- "'DEVICE={{ interface }}' in initscripts_connection_file.content | b64decode"
- "'IPADDR=192.0.2.1' in initscripts_connection_file.content | b64decode"
- "'PREFIX=24' in initscripts_connection_file.content | b64decode"
when: network_provider == 'initscripts' or ansible_distribution_major_version | int < 9

- name: Include the tasks 'down_profile+delete_interface.yml'
include_tasks: tasks/down_profile+delete_interface.yml
vars:
Expand Down
6 changes: 1 addition & 5 deletions tests/tasks/test_802.1x_capath.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
- 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"
Expand Down Expand Up @@ -103,8 +100,7 @@
expected_failure: "{{ __network_nm_nvr.stdout in __NM_capath_ignored_NVRs }}"
failure: "{{ __network_connections_result is failed }}"
assert:
that: (failure and expected_failure) or
(not failure and not expected_failure)
that: failure == expected_failure
msg: "Role {{ failure | ternary('failed', 'did not fail') }} but was expected
{{ expected_failure | ternary('', 'not') }} to fail.
NM NVR: {{ __network_nm_nvr.stdout }}"
Expand Down
Loading