Commit graph

511 commits

Author SHA1 Message Date
Wen Liang
cffefa8736 Docs: list all the available dns options for ipv4
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-04-02 15:47:46 +08:00
Till Maas
0f5a882bca Tests: Use more conscious language
Signed-off-by: Till Maas <opensource@till.name>
2021-03-10 11:54:50 +01:00
Wen Liang
fb5d6218de Test installation of NetworkManager plugins
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-03-05 11:57:16 +08:00
Fernando Fernandez Mancera
f4fabea554 README: remove "slaves" leftover from documentation
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-02-23 00:03:18 +01:00
Wen Liang
8318686620 Support ipv6.method disabled in network role
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-02-19 18:12:52 +01:00
Wen Liang
bda206d45c Fixing interface not found failure in tests_eth_dns_support.yml
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-02-17 12:54:30 +01:00
Noriko Hosoi
ef655447b3 use tox-lsr 2.2.0
Upgrade to tox-lsr 2.2.0 to pick up fix for improving collection
testing to get rid of black.

Signed-off-by: Noriko Hosoi <nhosoi@redhat.com>
2021-02-15 11:19:41 +01: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
e109d52e77 use molecule v3, drop v2 - use tox-lsr 2.1.2
Switch to molecule v3.  This drops support for v2.
This requires tox-lsr 2 or later.
Upgrade to tox-lsr 2.1.2 to pick up fix for collection dependency
on python six.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-02-10 15:26:04 -06:00
Rich Megginson
ba932115fb remove ansible 2.7 support from molecule
ansible 2.7 has been deprecated
https://docs.ansible.com/ansible/devel/reference_appendices/release_and_maintenance.html
We need to remove ansible 2.7 from molecule testing in order to
* make room for ansible 2.10 testing
* move to molecule v3

ansible 2.8 and later support platform-python on el8 and later
so we don't have to handle that case explicitly by setting
ansible_python_interpreter for centos8 in molecule.yml

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-02-09 11:44:13 -06:00
Fernando Fernandez Mancera
3167b3c125 inclusive language: use "port" instead of "slave"
In order to promote a diverse and inclusive environment we are replacing
all the reference to "slave" for "port".

Test case added.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-02-03 15:15:04 +01:00
Fernando Fernandez Mancera
a283e47c12 inclusive language: use "controller" instead of "master"
In order to promote a diverse and inclusive environment we are replacing
all the reference to "master" for "controller".

Test case added.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-02-03 12:57:03 +01:00
Wen Liang
880b7ab0cc Support dns-options in network role
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-01-28 09:57:45 +08:00
Thomas Haller
675c7e8073 argument_validator: add documentation comments
Signed-off-by: Thomas Haller <thaller@redhat.com>
2021-01-24 20:51:48 +08:00
Gris Ge
19139286ed nm provider: Refactor the volatilize action of network connection
Refactor the volatilize action of nm provider:
 * Move code to `module_utils/network_lsr/nm`
 * The `module_utils/network_lsr/nm` only volatilize profile by given UUID
   instead of guess. The `library/network_connections.py` is responsible
   on choosing UUID.

Signed-off-by: Gris Ge <fge@redhat.com>
2021-01-23 11:19:32 +08: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
Rich Megginson
26bbce0065 use tox-lsr 1.0.2
Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-01-19 13:21:58 -06:00
Rich Megginson
7798dcdfd3 add ansible-lint to github actions
Since we have disabled linting in molecule, use tox for running
ansible-lint.
In addition, fix molecule config to use `false` instead of `False`
since the former is the correct YAML boolean value.  This also
will make network consistent with the other roles.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-01-15 16:21:07 +08:00
Noriko Hosoi
023ecbd027 Collections - workaround for the module_utils path finding issue in ansible 2.9
The details of the issue is described in this ansible issue:
   https://github.com/ansible/ansible/issues/68361

The workaround contains 2 changes.
1) Advice from @sivel:
   replacing, e.g.,
     from ansible.module_utils.network_lsr.nm.provider import NetworkManagerProvider
   with
     from ansible.module_utils.network_lsr.nm import provider
   and then use provider.NetworkManagerProvider
2) In the later module_utils path finding path, gi.require_version("NM", "1.0")
   in module_utils/network_lsr/nm/client.py fails with "ValueError: Namespace
   NM not available" on the control node. By ignoring the exception, the failure
   is worked around. Please note that the missing package issue never occurs
   on the managed nodes since in case of "nm", the NetworkManager package is
   installed in the network role.

Signed-off-by: Noriko Hosoi <nhosoi@redhat.com>
2021-01-14 17:04:10 -05:00
Rich Megginson
977f149f1e Fix centos6 repos; use standard centos images; add centos8
Use the new vault.centos.org repos.  Fix the yum repo configs in the
image if necessary to use these new repos.
Use the standard centos images from the centos registry rather than
custom lsr images from dockerhub.
Add support for centos8.  Note that using ansible 2.7 on centos8
requires setting /usr/bin/python3 to be the ansible python
interpreter.  Later versions of ansible have better auto-detection.
We can get rid of this once we drop support for ansible 2.7
Use tox-lsr 1.0.1 - which means we do not need
molecule_extra_requirements.txt

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-01-13 23:43:11 +08:00
Antonio Cardace
69ae6b5b2a readme: Update README with ethtool coalescing options
Resolves: #112
Signed-off-by: Antonio Cardace <acardace@redhat.com>
2021-01-09 11:02:07 +08:00
Antonio Cardace
b586d11e79 Add support for ethtool coalesce settings
Also add related tests.

Resolves: #112
Signed-off-by: Antonio Cardace <acardace@redhat.com>
2021-01-09 11:02:07 +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
f01655c47a Add NetworkManager development documentation to contributing guide
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2020-12-18 17:54:56 +08:00
Rich Megginson
4f9f7a4c94 make CI work with tox-lsr
Use tox-lsr instead of the scripts in the `.travis/` directory and the
asssociated config files.  Yes, `.travis/custom.sh` is still there,
but once you are familiar with the way that tox-lsr works, you can
remove it and use your own custom tox.ini action.  The goal of this
commit was to make as few changes as possible, to keep feature parity
with the old `.travis/` script way of running CI.  Also note that
linting has moved into tox, so we needed to disable molecule linting.
The new version of ansible-lint adds a lot of checks, so these are
disabled for now, and should be fixed later.  Also, shellcheck is
turned off until the network team can address the issues.

The `.travis/custom.sh` script is not run in the CI environment, so
this was changed slightly to remove the check for `$TRAVIS`, and it is
no longer run as a tox testenv in CI.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2020-12-18 10:32:16 +08:00
Rich Megginson
302e682136 Fix python line length problem
The line was too long, and needed to be wrapped in a way that was
compatible with python black formatting.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2020-12-17 11:47:22 -07: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
Rich Megginson
c64b3b15ba use github actions instead of travis
adds a github actions tox workflow for CI testing, since
travis is discontinuing support for open source projects

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2020-12-11 14:46:40 +08:00
Jakub Haruda
899edea426 meta/main.yml: CI - Add support for all Fedora images
Signed-off-by: Jakub Haruda <jharuda@redhat.com>
2020-11-30 14:05:24 +08:00
Wen Liang
c183fff523 Disable Python2 unit tests on Fedora
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2020-11-30 13:31:56 +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
Gris Ge
c4643e56bb nm provider: Refactor the down action of network connection
When deactivating a profile in libNM, we should:

 * Check `NM.ActionConnection` existence
 * Check `NM.ActionConnection.props.state` not DEACTIVATED
 * Use signal `state-changed` of `NM.ActionConnection`.
 * Only invoke `NM.Client.deactivate_connection_async()` if not
   in DEACTIVATING state.
 * Ignore `NM.ManagerError.CONNECTIONNOTACTIVE` error.

This patch also introduced a new class `NetworkManagerProvider`
in `module_utils/network_lsr/nm`:

 * Independent from Ansible but need to use absolute import due to
   limitation of ansible 2.8.
 * Provide sync function wrapping async calls of libNM.
 * Use stable logging method of python.
 * Only load this module when provider is nm.

This patch also changed how logging is handling in
`Cmd_nm.run_action_down()` as initial step on isolate ansible log
mechanism from provider module.

By moving provider codes to `module_utils` folder, we can eventually
simplify the bloated `library/network_connections.py`.

Signed-off-by: Gris Ge <fge@redhat.com>
2020-11-19 18:58:26 +08:00
Fernando Fernandez Mancera
6812aab616 README.md: replace reference to "master" branch with "main" branch
All links containing references to the "master" branch must be replaced
by the "main" branch.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2020-11-10 10:36:22 +01:00
Noriko Hosoi
18ed81168f Sync with travis/runcollection.sh template
Source commit in the template repo: e9f2c3a 4f3c96a
    Merge pull request #48 from nhosoi/collections
    runcollection.sh - stop passing an argument list

This change allows to eliminate the test argument list as well as the
branch name to retrieve the lsr_role2collection.py script for the
collection test.

Signed-off-by: Noriko Hosoi <nhosoi@redhat.com>
2020-11-06 10:45:54 +01:00
Rich Megginson
c6b0226bf6 lock ansible-lint version at 4.3.5; suppress role name lint warning
lock the ansible-lint version to use the latest version 4.3.5 which
is compatible with the latest ansible 2.10
This means we need to suppress the error about the role name

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2020-10-27 11:37:20 +01:00
Fernando Fernandez Mancera
dc4bfa7272 github: add stale workflow
To ensure that old/untouched pull requests do not pile up, configure the
probot stale bot to mark pull requests without activity in the last 30
days as stale and close them after 14 more days if there is no further
activity. The pull requests are marked with the stale label.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2020-10-26 14:59:30 +01:00
Noriko Hosoi
890af84071 RHELPLAN-56586 - sync collections related changes from template to network role
The task 56586 is for adding tests against the collection converted
format to the tox/travis CI to capture a problem before merging the
pr, if any. It'd be helpful to find out bugs in the conversion tool
lsr_role2collection.py, as well. The source of this commit is located
in linux-system-roles/template. They are synced by auto-maintenance/
sync-template.sh, then manually adjusted to the network role.

.travis/runcollection.sh is the test script. tox.ini is modified to run
it in the tox/travis CI. The script downloads lsr_role2collection.py,
then converts the network role into the conversion format in the working
directory .tox. In the collection, it runs a set of tests black, flake8,
yamllint, py38 to check the converted result.
2020-10-23 13:35:14 +08:00
Wen Liang
3c7580d7f9 Remove comment about host selection workaround
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2020-10-15 07:40:33 +02:00
Wen Liang
e92a5c272a Document where to find other images used for testing
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2020-10-07 22:31:17 +02: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
Gris Ge
ed5fa4c606 CHANGELOG: emphasize the backward compatibility
Signed-off-by: Gris Ge <fge@redhat.com>
2020-09-23 15:53:15 +02:00
Wen Liang
eda49e3b38 Document running integration tests with podman
Document how to run integration test with podman, and list the files that are currently not working with podman.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2020-09-15 19:52:09 +02:00
Wen Liang
d2bd928278 Remove extra quote in configuring git user email
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2020-09-15 19:52:09 +02:00
Rich Megginson
35a09bbc61 use github_branch: main for galaxy import
Galaxy imports of the network role are failing:
https://galaxy.ansible.com/my-imports/1710
```
Task "703539" failed: Command '['git', 'clone', '--quiet', '--depth', '1', '--branch', 'master', 'https://github.com/linux-system-roles/network.git', '/var/tmp/galaxy/imports/tmpnxdxwzmg']' returned non-zero exit status 128.
```
We need to tell galaxy to use `main` instead of `master`.  The galaxy
roles documentation says that `github_branch` may be used for this
purpose:
https://galaxy.ansible.com/docs/contributing/creating_role.html#role-metadata

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2020-09-08 19:57:59 +02:00
Till Maas
9a6bdb5403 Update formatting according to new black version
Signed-off-by: Till Maas <opensource@till.name>
2020-08-28 09:11:56 +02:00
Rafael G. Ruiz
062b3a40ac contributing: add DCO requirement
Signed-off-by: Rafael G. Ruiz <llerrak@hotmail.com>
2020-08-28 09:10:43 +02:00
Till Maas
21de2fc95c Add CHANGELOG
Signed-off-by: Till Maas <opensource@till.name>
2020-08-26 18:41:46 +02:00
Elvira García Ruiz
5320e96a0e Add playbooks to automate integration testing
The main playbook executes integration/test_ethernet.py with pytest, adapting the
installation for different distributions.

Signed-off-by: Elvira García Ruiz <elviragr@riseup.net>
2020-08-24 21:52:25 +02:00