Commit graph

927 commits

Author SHA1 Message Date
Till Maas
ce979cdb18 README: Remove outdated information regarding the ifcfg-rh plugin.
The storage plugin used by NM is an implementation detail that the role
does not care about, since it uses NM via libnm.

Signed-off-by: Till Maas <opensource@till.name>
2022-03-21 14:06:20 +01:00
Rich Megginson
60b92ab7c0 Revert "Add support for Rocky Linux; fix supporting the infiniband ports in active-backup mode"
This reverts commit 7c03e49b10.
2022-03-15 11:03:20 -06:00
Rich Megginson
7c03e49b10 Add support for Rocky Linux; fix supporting the infiniband ports in active-backup mode
# New features

- Add support for Rocky Linux

# Bug fixes

- bond: Fix supporting the infiniband ports in active-backup mode
2022-03-15 11:01:46 -06:00
Wen Liang
dccd5d48d6 CHANGELOG: update changelog for 1.7.1 release
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2022-03-15 10:58:27 -06:00
Wen Liang
db4bf873cb Clean up connection profile after running pytest
Running the pytest with nm provider failed in the downstream testing
because the "NM_CONTROLLED=no" appeared in
`/etc/sysconfig/network-scripts/ifcfg-testeth` which caused the veth
`testeth` strictly unmanaged by NetworkManager. To fix it, clean up
such a connection profile at the end when running the pytest.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2022-03-14 18:27:02 +01:00
Till Maas
d3a7124f07 GitHub CI: Trigger on main branch
The network role is using `main` for the default branch, so this needs
to be used in the workflow definition.

Signed-off-by: Till Maas <opensource@till.name>
2022-03-11 15:55:25 +01:00
Till Maas
83dcfdc346 Contributing: Explain how to install tox_lsr
Signed-off-by: Till Maas <opensource@till.name>
2022-03-11 15:43:51 +01:00
Gris Ge
3a2fe6d13d InfiniBand bond: Fix typo of bond mode active-backup
The correct bond mode is `active-backup` instead of `active_backup`.

Thanks to vpal who found this issue via
https://github.com/linux-system-roles/network/issues/475

Signed-off-by: Gris Ge <fge@redhat.com>
2022-03-11 07:04:19 +01:00
Cong Luo
dfcd294552 add Rocky Linux support
Signed-off-by: Cong Luo <c.luo@fz-juelich.de>
2022-03-08 12:22:52 +01:00
Rich Megginson
c377f993c6 use pgrep instead of pidof; ensure packages exist
The tests are giving failures that are unfortunately being ignored.
One of which is that pidof is not available by default on all platforms,
and on some platforms is not available at all (el7).  Same with sysctl.

There are a couple of fixes:
* run the large embedded test `shell` with `set -euo pipefail` to
trigger script errors to be handled.
* install the procps or procps-ng package which provides the tools
such as pgrep, pkill, sysctl, etc.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2022-03-01 08:36:20 +08:00
Noriko Hosoi
79b39792e4 System Roles should consistently use ansible_managed in configuration files it manages
bz#2044640

The network role create an ifcfg file for initscripts. The file
used to append a comment "# this file was created by ansible".
This patch replaces the proprietary string with the ansible
standard {{ ansible_managed }} to adjust to the other system
roles.

For the implementation, it borrowed the method from kernel_settings,
getting the ansible managed comment using the get_ansible_managed.j2
template and pass the comment to network_connections which is added
to the ifcfg file.

In case network_provider is nm, the comment is not added to the
ifcfg file as the file is not managed by Ansible.

Note: the required parameter name to pass the ansible managed comment
to the network_connection module is "__header".

Do not use get_ansible_managed.j2 in the test scripts, but use a
hardcoded ansible managed comment to simplify the tests.

tests/tasks/get_profile_stat.yml: replace the '=' style with the YAML
notation in set_fact.

Signed-off-by: Noriko Hosoi <nhosoi@redhat.com>
2022-02-25 06:10:42 +08:00
Wen Liang
61423ed36f Fix hostapd package installation error
The hostapd package was moved from EPEL to CentOS Stream and therefore
is not available anymore on EPEL, which made the installation failed.
To fix it, install the hostapd via CentOS Stream in order to run
managed host testing in RHEL-8.5.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2022-02-21 21:51:38 +01:00
Rich Megginson
a029152e16 use tox-lsr version 2.10.1
Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2022-02-21 21:20:04 +01:00
Till Maas
cf04059fc8 test: Use new py26 environment
Signed-off-by: Till Maas <opensource@till.name>
2022-02-18 09:57:46 +01:00
Till Maas
d400cadfe4 pytest: Remove PyYAML dependency
This does not seem to be needed anymore.

Signed-off-by: Till Maas <opensource@till.name>
2022-02-18 09:57:46 +01:00
Wen Liang
f2760ab059 CHANGELOG: update changelog for 1.7.0 release
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2022-02-15 14:58:58 +01:00
Wen Liang
59be618857 Support more bond options
In order to enable user to flexibly control the network transmission
over the bonded interface, support all the bond options which are
currently supported by NetworkManager.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2022-02-11 23:40:34 +01:00
Wen Liang
fde69e0758 Disable all initscripts provider tests on Fedora
The initscripts provider tests are unstable on Fedora and users are not
using the initscripts on Fedora, therefore, disable all initscripts
provider tests on Fedora.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2022-02-11 21:59:35 +01:00
Till Maas
a4267e4e91 GitHub CI: Exclude unsupported tests
To ensure that new tests are going to be tested by the CI, only exclude
tests that are not supported instead of only included the supported
ones.

Signed-off-by: Till Maas <opensource@till.name>
2022-02-09 23:40:43 +08:00
Rich Megginson
206c354b7e [citest skip] bump tox-lsr version to 2.9.1
Signed-off-by: Rich Megginson <rmeggins@redhat.com>

The new tox-lsr also requires the use of `{toxinidir}` for the
local config file paths.
2022-02-07 18:58:27 -07:00
Gris Ge
0e3d480de7 CI: Enable CentOS 9 stream integration test
Signed-off-by: Gris Ge <fge@redhat.com>
2022-02-05 19:25:09 +01:00
Fernando Fernandez Mancera
2ebc8b5022 tests: do not run test_switch_provider on CentOS/RHEL 9
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2022-02-05 07:15:54 +01:00
Till Maas
ac33851552 Contributing: Update IRC information
Signed-off-by: Till Maas <opensource@till.name>
2022-02-04 18:33:39 +01:00
Till Maas
adf4192e38 Contributing: Fix spelling
Signed-off-by: Till Maas <opensource@till.name>
2022-02-04 18:33:39 +01:00
Till Maas
9d8a280b8a README: Clarify the name setting
Signed-off-by: Till Maas <opensource@till.name>
2022-02-04 18:14:52 +01:00
Wen Liang
2307969aef Remove CentOS8 GitHub actions CI Tests
As CentOS8 is already EOL, remove CentOS8 CI integration tests.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2022-02-04 09:23:58 +01:00
Wen Liang
62b0be6091 CHANGELOG: update changelog for 1.6.0 release
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2022-02-04 09:07:56 +01:00
Rich Megginson
f8a5e8576a fix python black errors
fix python black errors

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2022-02-03 16:01:09 +01:00
Fernando Fernandez Mancera
2b881a6c3f tests: use down_profile+delete_interface instead of down_profile
The files must be named so that it explain what happens. In addition,
`down_profile+delete_interface` must use `changed_when` to match the
content of `delete_interface`.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2022-01-28 17:47:13 +01:00
Gris Ge
c98c17a236 Fix problem when switch provider from initscript to nm
Problem:

After `tests_bridge_initscripts.yml` passed, the `tests_bridge_nm.yml`
will fail with NetworkManager 1.18.

Root cause:

 1. The `absent` and `down` action of initscript provider will not
    remove the bridge interface which fail the assertion in
    `tests_bridge_nm.yml`.
 2. In initscript mode, network role will create ifcfg file with
    `NM_CONTROLLED=no` instructing NetworkManager to mark the bridge as
    unmanaged. The follow up `down` and `absent` action of initscript
    provider will not change the NetworkManager's understanding on
    unmanaged state of this interface.

Fixes:
 1. We cannot change existing behaviour of initscript on not deleting
    interface in `down` and `absent` action. So we change the test
    function `tests/playbooks/down_profile.yml` to delete the interface
    manually via `ip link del <ifname>` command.

 2. Use `NM.Client.reload_connections_async()` to reload the
    configuration for nm provider on NetworkManager 1.18.

Previous test infrastructure is running each test file in a brand new VM
or container which cause this problem not been found before.

Dedicate test case `tests/tests_switch_provider.yml` included.

Signed-off-by: Gris Ge <fge@redhat.com>
2022-01-28 17:47:13 +01:00
Gris Ge
f508c27674 CI: Enable CentOS 7 integration test
Removed `tests_wireless_nm.yml` as github CI has no mac80211_hwsim
kernel module.

Signed-off-by: Gris Ge <fge@redhat.com>
2022-01-28 17:47:13 +01:00
Wen Liang
5eb03fa992 Support routing tables in static routes
The users want to use the policy routing (e.g. source routing), so
that they can forward the packet based on the other criteria except for
the destination address in the packet. In such scenario, the routing
tables have to be supported beforehand in static routes, so that the
users can define policy routing rules later to instruct the system
which table to use to determine the correct route.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2022-01-27 18:18:47 +01:00
Rich Megginson
20667b0860 bump tox-lsr version to 2.8.3
Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2022-01-10 12:35:01 -05:00
Wen Liang
af123707c2 Set DNS search setting only for enabled IP families
NetworkManager requires to configure DNS options (such as the search
setting) for each IP family even though it does not matter in the
system's DNS configuration. Also, NetworkManager only allows to
configure the DNS options for each IP family, when they are enabled. In
the network_connections dictionary, the DNS options are configured
without considering the IP family. Therefore, configure ipv4.dns-search
or ipv6.dns-search only if the IP family is enabled.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-12-21 09:18:38 +01:00
Wen Liang
4790e20ca4 CHANGELOG: update changelog for 1.5.0 release
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-12-15 11:27:18 -05:00
Wen Liang
5db8d0c5d1 Reject DNS_search setting if no IP family is enabled
NetworkManager only allows to configure the DNS options for each IP
family, when they are enabled. Therefore, reject DNS settings in
ArgValidator if no IP family is enabled.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-12-14 13:29:08 +01:00
Wen Liang
05b38b4217 Reject IPv6 DNS setting if IPv6 family is not enabled
NetworkManager only allows to configure the IPv6 nameservers if the
IPv6 family is enabled. Therefore, reject the IPv6 nameservers setting
in ArgValidator if the IPv6 family is not enabled.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-11-29 10:33:58 -05:00
Sergei Petrosian
5c7fa548ea update tox-lsr version to 2.8.0
New version adds check for proper commenting of the ansible_managed var
2021-11-23 09:36:17 +01:00
Rich Megginson
be8e38a5c6 use tox-lsr 2.7.1 with Ansible 2.12 GA
Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-11-08 20:01:01 +01:00
Rich Megginson
cdea768ffa drop python 3.7 from CI
None of the platforms we support use python 3.7, so drop it from
CI testing.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-11-08 20:01:01 +01:00
Rich Megginson
16ac152542 support ansible-core 2.12; ansible-plugin-scan; fix pylint errors; py39
Use the new tox-lsr that uses ansible-core 2.12.
Use ansible-plugin-scan in CI.
Fix pylint errors found by new ansible-test pylinter.
CI test with py39

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-11-08 20:01:01 +01:00
Wen Liang
774242fb63 test IPv6 DNS when static IPv6 is configured
When static IPv6 is configured, configuring IPv6 DNS will not raise any
validation error. Add unit test to verify that.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-10-29 12:42:23 -04:00
Wen Liang
b0c8195843 unit tests: Fix python 2.6 compatibility
Introduce Python26CompatTestCase to fix Python 2.6 support for unit
tests:

- Use TestCase.assertRaises on Python 2.6 because it does not support
  TestCase.assertRaisesRegexp

- Use TestCase.assertRaisesRegex on Python 3.2 and newer because it
  deprecates TestCase.assertRaisesRegexp

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-10-28 14:20:38 +02:00
Wen Liang
f813fb33b7 fix ensure_provider_tests.py; fix generated tests; add check to CI
Fix ensure_provider_tests.py so that the tests are correctly generated.
Because the generated tests have not been checked in a while, there was
some drift between the actual tests and what should have been generated,
so the new generated tests have also been included.
When `ensure_provider_tests.py` detects differences, it will now show
the diffs using a unified diff format.
Added a new tox testenv `ensure_provider_tests` - use
`tox -e ensure_provider_tests` to run - to pass arguments, use
`tox -e ensure_provider_tests -- generate`
Added `ensure_provider_tests` as one of the tox testenvs to run for
github tox CI.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-10-19 20:21:03 +02:00
Wen Liang
1112bc2664 refactor IPv6 DNS test when IPv6 is disabled
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-10-13 10:19:18 +02:00
Rich Megginson
db10fc2035 add support for ansible-core 2.11 ansible-lint, ansible-test
Add support for using latest ansible-lint and ansible-test with
ansible-core 2.11.  There are a few new warnings that need to
be addressed or suppressed.

One of the changes is to add `# noqa ignore-errors` to the places in
the role where `ignore_errors: true` is used.  In general, it is not
a good idea to use `ignore_errors: true` - instead, it is better to
capture the result of the command using a `register`, then use
`failed_when`.  Or, if that is not possible, use a `block`/`rescue`
for more complex error handling.  However, in the case where the network
role is using `ignore_errors: true` in test code, it is acceptable.
see https://ansible-lint.readthedocs.io/en/latest/default_rules.html#ignore-errors

Another change is to have all tasks have a valid `name:`.  This
is explained at https://ansible-lint.readthedocs.io/en/latest/default_rules.html#unnamed-task

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-10-11 12:03:00 -06:00
Sergei Petrosian
c0f6038082 On RHEL 7, enable epel using yum-config-manager
Fixing the CI on RHEL 7, it was broken by PR #422

Signed-off-by: Sergei Petrosian <spetrosi@redhat.com>
2021-10-06 20:02:12 +02:00
Wen Liang
9fd19afa25 Allow configuring network connection via matching path
Users can easily configure or update network connection via matching
physical device path of the interface, which add certain flexibilty of
user experience.

Update connection profile via matching `path` setting:

```yaml
  - name: eth0
    type: ethernet
    autoconnect: yes
    # For PCI devices, the path has the form "pci-$domain:$bus:$device.$function"
    # It will only update the interface with the path "pci-0000:00:03.0"
    match:
      path:
        - pci-0000:00:03.0
```

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-10-06 18:22:42 +08:00
Wen Liang
b569704c72 arg_validator: accept None as valid input for ArgValidatorDict
Users might want to use jinja2 templates to set properties. As such,
it's convenient to accept None as an alias for an empty dictionary.

For exmaple, setting like `"match": None` will be allowed by the role:
e.g.
        network_connections:
          - name: enp0s8
            type: ethernet
            persistent_state: present
            state: up
            match:
            ip:
              route_metric4: 10

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-10-06 18:22:42 +08:00
Wen Liang
af07c2a58d arg_validator: accept None as valid input for ArgValidatorList
Users might want to use jinja2 templates to set properties. As such,
it's convenient to accept None as an alias for an empty list.

For exmaple, setting like `"match": {"path": None}` will be allowed by
the role:

        network_connections:
          - name: enp0s8
            type: ethernet
            persistent_state: present
            state: up
            match:
              path:
            ip:
              route_metric4: 10

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-10-06 18:22:42 +08:00