Commit graph

437 commits

Author SHA1 Message Date
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
Till Maas
47ad99c7f0 Tests: Allow extra run conditions for NM tests
To be able to restrict running tests with NM, for example only on
CentOS/RHEL 7, allow to specify an extra run condition for the generated
shims.
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
f72fc394ea library: Return module params for debugging
Set invocation as suggested in
https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#invocation
to report how the internal module was invoked.
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
ef20874f4d library: Change ethtool features to use underscores
Ethtool features should use underscores instead of dashes. A
warning shows in case dashes used, and it fails if underscore and dashes are
mixed. Unit tests and integration tests have been added. Since nm already
needed underscores, the string processing that was made in nm_provider is now
unneeded and therefore removed.
2020-06-15 14:13:23 +02:00
Till Maas
3fc15de068 Library: Introduce debug flags
Allow to disable the checkpoint feature with a debug flag to make
debugging easier.
2020-05-29 08:41:12 +02:00
Elvira Garcia Ruiz
c9d2f8f3b7 Update contributing.md with detailed info of the project
Now the contribution document has some steps to facilitate to get into the
project's workflow for new contributors. It also contains the code
structure and how to use the CI testing of the project and basic info about git
configuration. A small reference to the contributing document has been added to
the readme.

Signed-off-by: Elvira Garcia Ruiz <elviragr@riseup.net>
2020-05-27 13:59:49 +02:00
Jack Adolph
8fe0799270 Prefix all local role variables with '__network'
To avoid conflicts with other roles, it is recomended to prefix all variables
that are only used internally with '__' and the name of the role ('__network_').
2020-05-18 08:39:16 +02:00
Fernando Fernandez Mancera
2e5dd50852 ethtool: use GPERMADDR instead the ethtool command line tool
This patch implements the ETHTOOL_GPERMADDR command in order to retrieve
the permanent address from ethtool instead using command line tool.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2020-05-15 16:11:56 +02:00
Fernando Fernandez Mancera
024ba709f6 library: all the imports must be on the top
According to PEP8 [1], the import are always put at the top of the file,
just after any module comments and docstrings, and before module globals
and constants.

[1] https://www.python.org/dev/peps/pep-0008/#imports

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2020-05-14 11:34:27 +02:00
Till Maas
aa34c91e67 Checkpoint test: Use variable for profile 2020-05-13 16:30:02 +02:00
Till Maas
4c6db0c90d Tests: Fix cleanup for checkpoint test
In some fail cases, the ifcfg-cptstbr file might not be removed by
cleaning up with the network role. Therefore remove it explicitly.
2020-05-12 21:51:14 +02:00
Till Maas
da918d0712 Tests: Use busctl instead of gdbus
Systemd ships with busctl that can be used instead of gdbus. Use it to
reduce test dependencies.
2020-05-12 21:51:14 +02:00
Till Maas
bcef3e23cf checkpoint tests: Work around Fedora 32 bug
network-scripts needs dbus-tools to be present to properly communciate
with NetworkManager but the dependency is missing and dbus-tools is not
installed on the CloudBase images. Therefore, ensure that it is present.
2020-05-12 21:51:14 +02:00
Patrick Ladd
52ca060167 Document setting bond options
There was no documentation of the supported bond options.
Added supported options to the README.md and added an example of a
simple bond with both of those options.
2020-05-11 17:14:46 +02:00
Harsh Jain
1359d963b0 Add the mailing list and IRC channel in contributing 2020-05-11 13:48:35 +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
Till Maas
b5fb076579 tox: Use C.UTF-8 locale
Molecule requires a UTF-8 molecule because of click:
https://click.palletsprojects.com/en/7.x/python3/
2020-05-06 19:20:01 +02:00
Till Maas
615db2e642 tox: Move common options to testenv
Move several common options to testenv instead of base to simplify the
file and use normal tox inheritance.
2020-05-06 19:20:01 +02:00
Harsh Jain
40b337fbf4 Add a test for downing non existent profile 2020-05-06 19:18:32 +02:00
Till Maas
9510fe34a8 travis: Use lsr_check_python_version
Richard Megginson suggested this in
https://github.com/linux-system-roles/network/pull/215#discussion_r420210849
2020-05-05 20:46:40 +02:00
Till Maas
47381469a1 tox: Add travis config for 3.8-dev
As reported in https://github.com/tox-dev/tox-travis/issues/147, the
python factor in tox-travis needs to match the Travis python environment
and not the python version. Therefore, add a separate line.
2020-05-05 15:47:58 +02:00
Till Maas
b334ce4d74 Travis: Fix python2 detection 2020-05-05 15:47:58 +02:00
Till Maas
0afed7ed88 Meta: Update Fedora releases 2020-05-05 11:14:01 +02:00
Till Maas
0258ee8575 travis: Upgrade to bionic 2020-05-05 11:14:01 +02:00
Rich Megginson
a9407a4803 use selectattr instead of json_query
Some tests were getting the following error:
```
Unexpected templating type error occurred on ({{
     network_connections |
       json_query('[*][ieee802_1x]') | flatten | count > 0 }}): 'NoneType'
       object is not iterable"
```
In general it is better to avoid the use of `json_query` and use
the older built-in jinaj2 filters such as `selectattr`, unless you
need to perform a complex query of complex json data.  In this
case, not sure what the problem was with the input json, but
using `selectattr` seems to have fixed it.
2020-05-04 18:46:42 +02:00
Jack Adolph
939772fdc1 Add support for domain-suffix-match 802.1x option
Role now supports validating the domain name of the EAP server certificate.
Regenerated the CA certificate as the private key for the original CA has been lost.
Updated test certificates to include a domain name in the CN so the domain-suffix-match
feature can be tested.
2020-05-04 13:01:41 +02:00
Harsh Jain
9d561ea915 Add commit message guidelines to contributing 2020-04-26 17:03:57 +02:00
Jack Adolph
97129717a5 Rename files to be valid python identifiers 2020-04-22 17:40:03 +02:00
Jack Adolph
330729c6dd Change 802.1x parameters to be valid python identifiers 2020-04-21 08:11:15 +02:00
Till Maas
16ba71f303 Integration tests: Explicitly select provider
Instead of determining the non-default provider, run all integration
tests explicitly for both providers or only the providers that are
required. Since Ansible does not allow to pass variables to playbooks
imported with `import_playbook` to select another playbook to import,
generate the files instead of using a shared playbook like
`run_with_nm.yml` or `run_with_initscripts.yml`.
2020-04-19 21:08:56 +02:00
Till Maas
ebbec7708f runpylint.sh: Export RUN_PYLINT_* variables
Some of the RUN_PYLINT_* variables are evaluated in a python script. To
ensure that they are passed to it, they need to be exported.
2020-04-19 21:08:56 +02:00
Till Maas
c398f401f9 Travis/tox: Run coveralls for all unit tests
Run coveralls after the unit tests to ensure that coverage data is
available
2020-04-18 16:20:52 +02:00
Till Maas
20a20b60fb Module/NM: Try to reapply connections 2020-04-18 11:02:59 +02:00
Till Maas
1554c4a6a3 Library/NM: Always rollback checkpoint on failure
If there is a NetworkManager checkpoint, roll it back on any failure.
Otherwise future invocations of the role fail until the checkpoint timed
out.
2020-04-18 01:14:07 +02:00
Till Maas
da35b81b2b Meta: Update minimum Ansible version 2020-04-17 17:25:07 +02:00
Till Maas
d9ea229a6a 802.1x tests: Fix cleanup
The runtime state needs to be down.
2020-04-17 17:25:07 +02:00
Akash Saini
255aed57a4 Coverage: Use find and file module instead of shell command 2020-04-16 18:48:11 +02:00
Till Maas
185075fdfb Integration tests: Fix coverage collection
Update coverage helpers for changes in newer Ansible versions (tested
with 2.9.6) and with using module_utils.
2020-04-15 22:12:22 +02:00
Till Maas
f01cb8f657 Update gitignore 2020-04-14 16:46:18 +02:00
Pavel Cahyna
33f68c5e49 Add ansible-lint config, now turns off the silly rule 602
See https://github.com/linux-system-roles/timesync/issues/31
2020-04-08 13:16:43 +02:00
Rich Megginson
05a9223a33 move flake8 args to [flake8] section of tox.ini
tox supports a `[flake8]` section, so move the default
settings there rather than having them passed in on the
command line.  Projects can still override flake8 arguments
by using `RUN_FLAKE8_EXTRA_ARGS` in `.travis/config.sh`

Signed-off-by: Till Maas <opensource@till.name>
2020-04-08 13:16:43 +02:00
Till Maas
b9e19fb2be config.sh/custom.sh: Sync with template 2020-04-08 13:16:43 +02:00
Rich Megginson
92519644ba python 2.6 support for pytest and ansible 2.6
Removed `mock` from the `testenv` `deps`.
Added `mock` to the template pytest_extra_requirements.txt,
commented out.  Projects such as network that need it can uncomment it.
2020-04-07 11:02:28 +02:00
Rich Megginson
7fdfa3204e update to latest template code
These changes don't directly affect network, or don't actually
change the behavior of existing code that network uses (coveralls),
but are intended to sync with the latest template code.

Adds `LSR_PUBLISH_COVERAGE=normal` to `.travis/config.sh` because
network wants to publish coverage normally (as opposed to `strict`
or not at all).
2020-04-07 11:01:26 +02:00
Rich Megginson
dec163940e support testing/linting module_utils code
This does not directly affect network because network has its own
solution for dealing with testing/linting module_utils code, but
it gets network to feature/code parity with the template and
other repos.

Defines a shell function in utils.sh - lsr_setup_module_utils -
that allows configuring a tox venv installed ansible to have
the repo module_utils code in the default pythonpath for the
venv, which allows testing and linting the module_utils code
without having to otherwise munge or mock the pythonpath.

Projects needing this functionality can set in `.travis/config.sh`
the variable `RUN_PYTEST_SETUP_MODULE_UTILS` to setup
module_utils/ for pytest, and `RUN_PYLINT_SETUP_MODULE_UTILS`
to setup module_utils/ for pylint.
2020-04-06 19:14:42 +02:00
a-mere-peasant
11a03f0ceb Add documentation for existing team type support
Add no other configurability available
2020-04-06 15:23:58 +02:00
Rich Megginson
7863e08e9b allow more overrides of template code
NOTE: I don't think this commit directly affects network, since
network doesn't use any of these - this PR is more for parity
with template and other repos.

Centralize the setting of `ME` and `TOPDIR` in utils.sh

Add support for `RUN_FLAKE8_EXTRA_ARGS` and `RUN_BLACK_EXTRA_ARGS`
2020-04-06 15:17:14 +02:00