Commit graph

33 commits

Author SHA1 Message Date
Rich Megginson
751c3fffca fix: facts being gathered unnecessarily
Cause: The comparison of the present facts with the required facts is
being done on unsorted lists.

Consequence: The comparison may fail if the only difference is the
order.  Facts are gathered unnecessarily.

Fix: Use `difference` which works no matter what the order is.  Ensure
that the fact gathering subsets used are the absolute minimum required.

Result: The role gathers only the facts it requires, and does
not unnecessarily gather facts.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2023-07-14 15:23:56 -06:00
Ole Pannbacker
c2f89a78b9 feat: add AlmaLinux to RHEL compat distro list
Signed-off-by: Ole Pannbacker <opannbacker@cronon.net>
2023-06-01 16:23:16 -06:00
Rich Megginson
cf356230ca support ansible-core-2.14, ansible-lint 6.x
ansible-core 2.14 is now the current version of Ansible.  This version
does not support `args: warn: false` so we have to remove it from the
network role.  Users will need to use `COMMAND_WARNINGS` in their
Ansible configuration in order to suppress the warning in older versions
of Ansible such as 2.9, 2.11.
In addition, the gating tests are getting stricter about using new best
practices, such as using `true`, `false` for booleans instead of `yes`,
`no`; use of spaces in Jinja expressions; etc.  These issues were
addressed.
The `tests/` directory contains far too many cases of non-recommended
practices, so this directory has been exempted.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2022-11-14 13:54:14 -07:00
Rich Megginson
2b17fe73e9 support playbooks which use gather_facts: false
Some users prefer to use `gather_facts: false` in their playbooks.
However, the network role requires certain ansible_facts to be set.  If
the user wants to use the network role with `gather_facts: false`, the
role will gather the minimum subset of facts required.  If the user does
not want the role to gather facts, the user can either not use the
network role, or ensure that all required facts are in the facts cache.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2022-04-27 23:01:00 +02: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
9ce48eb05a replace json_query with selectattr
In order to work with ansible-core, json_query is replaced
with selectattr.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-09-14 07:49:16 -06: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
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
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
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
330729c6dd Change 802.1x parameters to be valid python identifiers 2020-04-21 08:11:15 +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
6cfcfc430c Defaults: Remove conditions for unsupported Fedora releases 2019-11-27 16:54:22 +01:00
Till Maas
85f16ddf6f Defaults: Break long lines 2019-11-27 16:49:40 +01:00
Ian Hill
a022dea582 Added OracleLinux as a RHEL clone for package detection purposes. 2019-07-08 16:54:15 +01:00
Till Maas
0c59fe1c6a Cleanup yaml files for molecule lint 2019-04-25 14:19:15 +02:00
Till Maas
97adeb5668 Default to install network-scripts for initscripts
Newer releases of `initscripts` ship the network scripts in a separate
package called `network-scripts`.

This fixes #81
2018-10-15 21:00:26 +02:00
Till Maas
d4936d1ca7 Require bridge-utils only for older distributions
The initscripts provider uses iproute2 in newer releases to setup
bridges.

This fixes #84
2018-10-15 21:00:05 +02:00
Till Maas
84fe98508e Use is version instead of |version_compare
Using tests as filters is deprecated and `version_compare` was renamed
to `version` in Ansible 2.5.
2018-10-15 20:53:20 +02:00
Till Maas
c279f0afc5 Run integration tests with other provider, too
- Amend and add files to run integration tests against the provider that
was not autodetected, too.
- Add check to ensure that all integration tests run against both
providers
- Run black check for all python scripts
2018-08-01 23:13:30 +02:00
Till Maas
4b9c91763b Use nm provider by default only when NetworkManager is running
- Use initscripts as provider except when NetworkManager is running
- Rename network_provider_default to network_provider_os_default, since
it contains the default based on the OS
2018-08-01 18:32:01 +02:00
Till Maas
35f2dcf8f7 Install bridge-utils if necessary for initscripts
Fixes #68
2018-07-16 08:26:50 +02:00
Till Maas
75784ea5ed Install python{,3}-gobject-base if required 2018-05-24 15:14:04 +02:00
Till Maas
f0d0e0637b Add SPDX-License-Identifier headers 2018-03-13 10:06:30 +01:00
Thomas Haller
b2901ebd3f Revert "network: install python-gobject package by default"
The package is not called python-gobject on RHEL.

This reverts commit a799777d1a.
2018-01-24 14:06:41 +01:00
Thomas Haller
a799777d1a network: install python-gobject package by default
The "nm" provider talks to NetworkManager via libnm and python GObject
introspection. Install the required python library by default.

Unfortunately, it's not immediately clear whether we want to install
python2-gobject or python3-gobject. Yeay, python.
2018-01-23 16:29:30 +01:00
Thomas Haller
e0c492eeb5 network: install ethtool package by default
The role uses ethtool to obtain the permanent MAC address of interfaces.
It should be installed by the role as well.
2018-01-23 16:19:58 +01:00
Thomas Haller
16ad34c20a role: improve making "network_provider" configurable via host vars
The role currently supports two providers: "nm" and "initscripts".

The provider is autodetected by loading one of the vars/*.yml files
(where the default is set via the internal "network_provider_default" variable).
The user can still overwrite the provider, by explicitly setting the
"network_provider" variable.

Depending on the provider there is the list of packages that shall be
installed and the service to start. Selecting this was broken before.

This is now fixed and works like following:

The variables "network_service_name" and "network_packages" can be
specified by the user as host variables. But usually the user wouldn't
want to do that. Instead, those settings depend on "network_provider".
The role looks into the internal "_network_provider_setup" dictionary,
which defaults to "network_service_name_nm", "network_service_name_initscripts",
"network_packages_nm", and "network_packages_initscripts".

These default variables are initialized in "defaults/main.yml" as well,
but they could be overwritten via "vars/*.yml" files, or via any other
mechanism.

https://github.com/linux-system-roles/network/pull/14
https://bugzilla.redhat.com/show_bug.cgi?id=1485074
2017-09-25 11:37:48 +02:00
Thomas Haller
29c7008f61 network: use top-level variables instead of nested "network" variable
The role already supported a default variable ("network_provider") and
host variables ("network_provider_default", "network_service_name",
"network_packages").

Don't use nested variables under "network" like

  network:
    provider:
    ignore_error:
    connections:

instead promote them all to top-level variables like:

  network_provider:
  network_ignore_error:
  network_connections:

This seems more consistent (as we already have multiple top-level
variables), it seems to follow ansible style, and it makes it easier
to overload individual variables via conditional include files.
2017-05-09 13:58:31 +02:00
Thomas Haller
52318732bb tasks: name "vars" file by the matching "{{ ansible_distribution }}"
This fixes the role to run on Fedora and CentOS.
2017-05-02 13:28:01 +02:00
Sam Doran
9c54c68858 Restructure role
Change default variables to include lookup table.
Change tasks to set variables based on distribution version.
2016-12-05 16:07:19 -05:00
Thomas Haller
ac35802240 first version 2016-12-05 18:14:20 +01:00