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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
* 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>
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>
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>
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>
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>
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>
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>
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>
All links containing references to the "master" branch must be replaced
by the "main" branch.
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
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>
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>
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>
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.
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>
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>