Commit graph

31 commits

Author SHA1 Message Date
Wen Liang
2444e27cce wifi: Add Opportunistic Wireless Encryption (OWE) support
Enable WPA3 OWE support via:

    ```yaml
    network_connections:
      - name: wlan0
        type: wireless
        wireless:
          ssid: "WIFI_SSID"
          key_mgmt: "owe"
    ```

Integration test case was included for Fedora and CentOS. ( Failed in setting up the
mock wifi on RHEL, so skipped the integration test on RHEL)

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-24 10:51:01 +08:00
Noriko Hosoi
34665b916d Cleaning up ansible-lint errors except '106', '303' and '403'
That is the following errors are fixed.
'206'  # Variables should have spaces before and after: {{ var_name }}
'208'  # File permissions unset or incorrect
'301'  # Commands should not change things if nothing needs doing
'305'  # Use shell only when shell functionality is required
'502'  # All tasks should be named
'601'  # Don't compare to literal True/False
'602'  # Don't compare to empty string

RHELPLAN-73471

Signed-off-by: Noriko Hosoi <nhosoi@redhat.com>
2021-04-15 20:53:53 +02:00
Rich Megginson
209fa56d14 fix collection lookup problem
This fixes the following error:
```
/bin/sh: line 9: cd: /root/.ansible/collections: No such file or directory
```
The fix is to ensure the directory exists before attempting
to `cd` to the directory.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-02-10 16:50:52 -06:00
Rich Megginson
9c86ff6f76 collections - working unit tests during integration
The unit tests that are run during integration test did not
work for the role converted to collection format.  The tests need to
get the paths from the environment then set up the runtime environment
to look like the real Ansible runtime environment.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-01-22 05:57:16 +08:00
Gris Ge
b0f5d6352a test: Fix EL6 repo
* As EPEL6 has been moved to archive, created `tests/tasks/enable_epel.yml`.
 * As CentOS6 has been moved to vault, created `tests/tests_00_setup.yml`.

Signed-off-by: Gris Ge <fge@redhat.com>
2020-12-22 08:14:39 +08:00
Wen Liang
f848949c76 RFE: Support dummy interfaces
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2020-12-16 14:28:41 +08:00
Gris Ge
637e1e6bbe test: Fix profile assertion on Fedora 33
The NetworkManager in Fedora 33 does not use ifcfg-rh plugin by default,
the CI will fail on Fedora 33 with:

```
TASK [assert that profile 'bond0' is present] **********************************
task path: /tmp/tmpaz9m374e/tests/playbooks/tasks/assert_profile_present.yml:4
fatal: [/cache/fedora-33.qcow2]: FAILED! => {
    "assertion": "profile_stat.stat.exists",
    "changed": false,
    "evaluated_to": false,
    "msg": "profile /etc/sysconfig/network-scripts/ifcfg-bond0 does not exist"
}
```

Previously, we are checking the existence of
`/etc/sysconfig/network-scripts/` to determine whether ifcfg-rh plugin
is enabled. This is incorrect on Fedora 33.

The fix is checking the FILENAME[1] used for storing the NetworkManager
connection, the profile is considered as exists when it exists and does
not contains `/run`.

Since we cannot tell which provider we are using, we just check both
initscripts files and NetworkManager connections.

[1]: nmcli -f NAME,FILENAME connection show

Signed-off-by: Gris Ge <fge@redhat.com>
2020-12-16 10:39:13 +08:00
Gris Ge
ad2a8bfd29 test env: Bring test veth peer up
In order to allows NetworkManager to control veth interface,
the veth peer should be in up state and the veth should be marked as
managed.

Signed-off-by: Gris Ge <fge@redhat.com>
2020-11-27 16:36:57 +08:00
Gris Ge
acb1d0165e test 802.1x: Install openssl as test dependency
The Fedora 33 cloud image does not have openssl installed by default,
install openssl before using its cli tool.

Signed-off-by: Gris Ge <fge@redhat.com>
2020-11-23 15:55:35 +08:00
Wen Liang
c7af145a9a Install NetworkManager-team package when team profiles are configured
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2020-10-07 11:18:30 +02:00
Till Maas
bf4501bb87 tests: Do not check arch for NM version
To allow running the tests on any arch, do not check for the RPM
architecture when checking the NetworkManager version.

Signed-off-by: Till Maas <opensource@till.name>
2020-08-21 08:43:10 +02:00
Vladimír Beneš
6e85ffe5f2 tests: add simple bond tests for both nm and initscripts
* add a helper to create two veth devices with IPv4/IPv6 infra
 * add a bond in active-backup mode with miimon value
 * add two slaves connections for two veth devices
 * check automated IPv4/IPv6 addresses are assigned to master
 * check all connections are present
 * add a helper to delete previously created veth device setup
2020-08-20 17:06:05 +02:00
Till Maas
0b2edc50d8 Forget unmanaged state in NetworkManager
When removing a profile with initscripts, also notify NetworkManager so
it can forget that the specified device was to be ignored.
2020-07-11 16:17:06 +02:00
Till Maas
e0c7d550a9 States: Ignore already removed profile for absent
When a profile is specified as absent, ignore state requests if the
profile is already removed or not completely specified to improve
idempotence.

Also restructure the states test. This introduces a clear structure for
the individual test steps, properly assigns tags for each test from the
file and provides a clear error message with a description of the test
that failed in case of errors. Support for tests that expect a failure
is still missing.
2020-06-26 20:08:51 +02:00
Till Maas
ff1cba43d6 Tests: Check error message in ca_path test 2020-06-17 08:51:12 +02:00
Till Maas
cea278cd11 Tests: Avoid comparing booleans
Instead of testing directly for equality of boolean values, use logical
comparisons since the comparison is broken in Jinja2 before version
2.11.0.
2020-06-17 08:51:12 +02:00
Jack Adolph
51f8e5b05f Add support for wireless connections
WPA-PSK and WPA-EAP are supported. Uses existing 802.1x features of the role.
Added extra functionality to ArgValidatorStr to enforce a min and max length.
2020-06-15 21:10:54 +02:00
Jack Adolph
dd4ae77cbf Add ca_path option for 802.1x connections
Special notes:
Hash the cacert in the ca_path as OpenSSL needs symlinks for ca
certificates from their symlinks to their filename if specifying a
directory.

In case ieee802_1x.ca_path is specified but not supported by
NetworkManager, fail to ensure the setting is not silently ignored.

References:
https://stackoverflow.com/questions/25889341/what-is-the-equivalent-of-unix-c-rehash-command-script-on-linux
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/448

Co-authored-by: Till Maas <opensource@till.name>
2020-06-15 18:26:34 +02:00
Till Maas
371d6f4679 802.1x tests: Improve cleanup 2020-06-15 18:26:34 +02:00
Till Maas
7f222e5dbe Tests: Use command module 2020-06-15 18:26:34 +02:00
Elvira Garcia Ruiz
4753c70c55 library: Separate debug and info logs from warnings
Logs are now separed by severity level. Warnings and failures are the only logs
that appear now on the output. All logs are saved into a new json parameter
called "stderr" that is later shown on a different task. In case of
failure, all logs are shown as output. Tests have been created and modified in
order to assure that this feature works.

Signed-off-by: Elvira Garcia Ruiz <elviragr@riseup.net>
2020-05-06 21:57:34 +02:00
Jack Adolph
97129717a5 Rename files to be valid python identifiers 2020-04-22 17:40:03 +02:00
Jack Adolph
4af8f23955 Add support for 802.1x wired connections (EAP-TLS only)
Only EAP-TLS method is supported. Must use NetworkManager as the network_provider.
Also fixed bug in do_connections_validate_nm() function.
2020-03-25 10:49:10 +01:00
Till Maas
00a81165e8 tests: Install iproute to manage test interfaces 2019-04-16 18:27:45 +02:00
Till Maas
f8d325f9fa tests: Adjust profile path if necessary
If /etc/network-scripts does no exist, NeworkManger uses
/etc/NetworkManager/system-connections to store profiles. Use this
directory if necessary.
2019-04-16 18:27:45 +02:00
Till Maas
5273f55166 tests: Do not use ansible_interfaces
ansible_interfaces requires iproute to be present which might not be the
case for container images. Check /sys/class/net to avoid the dependency.
2019-04-16 18:27:45 +02:00
Till Maas
9b3712cbdf test asserts: Clarify name 2019-01-08 17:11:38 +01:00
Till Maas
49c7c6a0f4 tests: Properly set the name of assert tasks
Otherwise it breaks with Ansible 2.7 or does not show the name with
previous Ansible versions.
2018-10-16 11:31:22 +02:00
Till Maas
9b3d2d3ad8 Add simple test for bridges 2018-07-16 08:26:50 +02:00
Till Maas
488c59a5f5 Rename/symlink accidentally checked-in files 2018-06-28 16:55:37 +02:00
Till Maas
ff2f35cb8a Add helper tasks for integration tests 2018-05-23 18:55:21 +02:00