Commit graph

544 commits

Author SHA1 Message Date
Gris Ge
245ff58e25 nm: Fix the incorrect change indication for dns option
When applying with `dhcp4: "no"` or `auto6: "no"`, we get incorrect
change indication even when network connection was not changed.

The root cause is the `NM.SettingIPConfig.clear_dns_options(True)` will
create an empty list which will be discard by ifcfg plugin.
The follow up `NM.Connection.compare()` will show configuration changed
as dns option entry missing.

Fixed by remove dns option completely before appending.

Signed-off-by: Gris Ge <fge@redhat.com>
2021-07-05 20:15:57 +08:00
Gris Ge
f538865c68 nm: Fix the incorrect change indication when apply the same config twice
When applying the same network connections twice, the second apply still
shows `changed: true`.

The root cause:
 * When user never asked about ethtool configuration, network-role
   will generate an all-default `NM.SettingEthtool` and pass it to
   NetworkManager daemon. But NetworkManager discard it when saving to
   ifcfg plugin as ifcfg plugin will not keep empty ethtool option.

 * During second apply, the `NM.SimpleConnection.compare` will return
   False indicating configuration changed because of on-disk connection
   has no ethtool setting while pending connection does.

To fix it, we just remove the all-default `NM.SettingEthtool`.

Signed-off-by: Gris Ge <fge@redhat.com>
2021-07-05 20:15:57 +08:00
Wen Liang
833b6f3075 fix: dhclient is already running for nm-bond
Running `tests_bond_deprecated_initscripts.yml` and
`tests_bond_initscripts.yml` consecutively will fail in the downstream
testing with error "Determining IP information for nm-bond...dhclient is already running - exiting.".
Because the two tests have the same controller device name and dhclient
will keep running for the controller device `nm-bond`.

A workaround for this bug is to change the controller device name
associated with `tests_bond_deprecated_initscripts.yml`.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-07-01 22:42:59 +02:00
Kristof Wevers
85b75b6c8c Only show stderr_lines by default
This avoids dumping all the parameters which can cause rather lengthy
output if multiple interfaces, routers, ... are configured.
The previous behaviour where all the params etc were displayed can
still be achieved by adding `-v` to the `ansible-playbook` command.

Resolves: #394

Signed-off-by: Kristof Wevers <kristof.wevers@infura.eu>
2021-06-11 06:03:23 +08:00
Jack Adolph
b368bce8aa Add 'auto_gateway' option
If enabled, a default route will be configured using the default gateway. If disabled,
the default route will be removed.

If this variable is not specified, the role will use the default behavior of the
`network_provider` selected.

Setting this option to `no` is equivalent to:
- `DEFROUTE = no` in initscripts, or
- `ipv4.never-default/ipv6.never-default yes` in nmcli

Signed-off-by: Jack Adolph <jack.adolph@gmail.com>
2021-06-04 07:07:13 +08:00
Jakub Haruda
6fdac168a9 CI: Add support for RHEL-9
Signed-off-by: Jakub Haruda <jharuda@redhat.com>
2021-05-28 06:06:51 +08:00
Wen Liang
a6c98bd660 arg_validator: reject bool arguments from ArgValidatorNum
`ArgValidatorNum` would normalize boolean into int when
`self.numeric_type` is int, then `self.numeric_type(False)` is 0 and
`self.numeric_type(True)` is 1. Therefore, we need to fix
`ArgValidatorNum()` to reject boolean values when integer values are
expected for the setting. This bug fix potentially breaks previously
"working" playbooks (but realistically, they were not working, because
setting 0 or 1 was unlikely intended).

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-24 18:51:54 +08:00
Wen Liang
dfacbf72f7 arg_validator: normalize numeric value for ArgValidatorNum
In python, bool is a subclass of int. Thus,
isinstance(value, self.numeric_type) would be True, with value being a
bool and numeric_type an int.

ArgValidatorNum should normalize the input values to be of type
self.numeric_type, except the default_value, which might be None (or
anything really).

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-24 18:51:54 +08:00
Wen Liang
93e509b533 Fix: support dns_search and dns_options for all address family
`dns_search` and `dns_options` should not be specific to the address
family. Previously, `dns_search` and `dns_options` were only supported
for IPv4 nameservers, so we also need to support `dns_search` and
`dns_options` for IPv6 nameservers.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-24 15:34:52 +08:00
Wen Liang
2444e27cce wifi: Add Opportunistic Wireless Encryption (OWE) support
Enable WPA3 OWE support via:

    ```yaml
    network_connections:
      - name: wlan0
        type: wireless
        wireless:
          ssid: "WIFI_SSID"
          key_mgmt: "owe"
    ```

Integration test case was included for Fedora and CentOS. ( Failed in setting up the
mock wifi on RHEL, so skipped the integration test on RHEL)

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-24 10:51:01 +08:00
Wen Liang
ae2d60a0b2 Add support for ETHTOOL Ring option
ETHTOOL Ring option is not supported by NetworkManager until
NM 1.25.2. Currently, ETHTOOL Ring option is not suppored by
Network role, so enable the support for ETHTOOL Ring option.

Configure ethtool ring option via:

	```yaml
            network_connections:
              - name: testnic1
                type: ethernet
                state: up
                ip:
                  dhcp4: no
                  auto6: no
                ethtool:
                  ring:
                    rx: 128
                    rx_jumbo: 128
                    rx_mini: 128
                    tx: 128
	```

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-11 18:19:16 +02:00
Wen Liang
13e7f8a333 Support conditional testing for NM provider
- To properly run tests for features that are supported both in
initscripts and NM but require a specific NM version or other
condition, add a new test category for these tests.

- Use the new test category to enable testing coalesce support with
initscripts

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-09 07:04:46 +02:00
Wen Liang
1172c9ca85 Fix ethtool coalesce testing CI failures
To fix the CI failure - "Error: testnic1 - no such connection profile",
when testing ethtool coalesce setting with initscripts provider, bring
up the connection when the connection was created.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-09 07:04:46 +02:00
Rich Megginson
570246bad3 no need for __init__.py in module_utils/
The file module_utils/__init__.py is not needed.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-05-06 11:15:11 +02:00
Wen Liang
eb023ddfa7 Enable comment support for "NM_ONLY_TESTS"
To clearly explain to user why minimum version or extra running
condition is needed for certain "NM_ONLY_TESTS", include additional
comment support.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-04 08:09:04 +02:00
Rich Megginson
c1b0002bc9 fix python black issues
There was recently an upgrade to python black which made function
documentation checking stricter.  This caused network tox CI to
break.  The fix is to format the function doc text in the manner
expected by black.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-05-03 18:41:05 +02:00
Thomas Haller
c2e83b1d82 argval: use callable() check in get_default_value()
Previously, we would catch any kind of exception. We only want
to suppress an error if the default value is not a callable
(but instead a plain value).

Usually, in python they say it's easier to ask for forgiveness
than permission. However, that is often not true (the code here
this case becomes simpler, not more complicated). But more important,
in this case we only get a TypeError, which doesn't exactly tell
us what is wrong. We want to only suppress the error, if the
instance is not callable.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2021-04-16 12:09:43 +02:00
Thomas Haller
bf9933e482 argval: cleanup default values in ArgValidatorDict._validate_impl()
- split the "if" block in two. It's easier to read to only
  have one condition and to think about them independently.

- check "self.all_missing_during_validate" before getting the
  default value.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2021-04-16 12:09:43 +02:00
Till Maas
16f1898894 Revert "Add auto update GitHub action"
The auto update is creating merge commits instead of rebasing, therefore
it is not the right choice.
This reverts commit 81a602dd71.

Signed-off-by: Till Maas <opensource@till.name>
2021-04-15 21:16:32 +02:00
Wen Liang
4f62185714 Document gateway4 and gateway6 setting in README.md
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-04-15 21:15:54 +02:00
Till Maas
81a602dd71 Add auto update GitHub action
Enable https://github.com/tibdex/auto-update to simplify automatic
merging of PRs.

Signed-off-by: Till Maas <opensource@till.name>
2021-04-15 20:55:54 +02:00
Noriko Hosoi
34665b916d Cleaning up ansible-lint errors except '106', '303' and '403'
That is the following errors are fixed.
'206'  # Variables should have spaces before and after: {{ var_name }}
'208'  # File permissions unset or incorrect
'301'  # Commands should not change things if nothing needs doing
'305'  # Use shell only when shell functionality is required
'502'  # All tasks should be named
'601'  # Don't compare to literal True/False
'602'  # Don't compare to empty string

RHELPLAN-73471

Signed-off-by: Noriko Hosoi <nhosoi@redhat.com>
2021-04-15 20:53:53 +02:00
Rich Megginson
f5ff30a66c fix most ansible-test issues, suppress the rest
Automation Hub, and possibly Galaxy in the future, require the
collection to be screened with `ansible-test sanity` among other
checks.  The role had a number of issues:
* Use `AssertionError` instead of `assert`
* Use of `logging` module not in accordance with standards, but these
  are ok and the errors were suppressed
* Several import errors which are ok because they are checked
  elsewhere
* __init__.py in the module_utils directories must be empty, so a
  new file myerror.py was added to move the code from __init__.py
  * NOTE: network_lsr/nm/__init__.py is not empty
* The documentation block in the module was not properly constructed
  or formatted.
* shellcheck issues, including removing unused files
* use `unused` instead of `_` (underscore) for variables that are
  unused

add WARNING to module docs - collection users should not use directly

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-04-09 19:57:55 +02:00
Till Maas
87a9c5bd60 Enable github actions for push
Also run github actions for pushing to get CI updates for changes to the
main branch and a baseline to compare PRs to.

Signed-off-by: Till Maas <opensource@till.name>
2021-04-08 17:21:54 +02:00
Wen Liang
9e427428b4 Add markdownlint rules to allow header duplication
Markdownlint requires each section headers to be different by default
but the Changelog needs to contain multiple sections with the same
name, therefore enable `allow_different_nesting` to support this use
case.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-04-08 17:09:06 +02:00
Wen Liang
ed63f64b34 CHANGELOG: update changelog for 1.3.0 release
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-04-08 17:09:06 +02:00
Jack Adolph
001f81b823 Fix static IPv6 support for initscripts provider
Use the correct parameter names for declaring static IPV6 connections
for the initscripts provider. Also, add integration and unit tests to
cover this.

Signed-off-by: Jack Adolph <jack.adolph@gmail.com>
Signed-off-by: Till Maas <opensource@till.name>
2021-04-08 16:49:20 +02:00
Wen Liang
387005098b Docs: update 'mac' to suggest user using quotation mark
Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-04-07 21:03:58 +02:00
Rich Megginson
167edabe8d use lsr-gh-action-py26 for python 2.6 unit tests
Use the new https://github.com/linux-system-roles/lsr-gh-action-py26
for running unit tests on python 2.6.  This uses an EL6 VM so more
closely corresponds to the managed hosts that still use python 2.6.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-04-07 20:12:28 +02:00
Till Maas
a83372d5ee Add markdownlint GitHub Action
Setup https://github.com/marketplace/actions/markdownlint-mdl-action for
automatic markdown linting.

Signed-off-by: Till Maas <opensource@till.name>
2021-04-07 18:06:31 +02:00
Till Maas
b55d96a8a9 Add markdownlint style
Add a style for https://github.com/markdownlint/markdownlint/ to allow
it to be used to check for a consistent style and matching the current
style.

Signed-off-by: Till Maas <opensource@till.name>
2021-04-07 18:06:31 +02:00
Till Maas
ffa98f4876 Unify Markdown syntax
- Use a consistent style for lists and fix indentations
- Adjust whitespace to fence lists or code blocks
- Remove double blank lines
- Wrap lines at 88 characters
- Add missing notations for code
- Use proper links instead of plain URLs
- Reword some parts to fit the style and update the text

Signed-off-by: Till Maas <opensource@till.name>
2021-04-07 18:06:31 +02:00
Rich Megginson
a3ccd5561e update to tox-lsr 2.4.0 - add support for ansible-test sanity with docker
set `LSR_ANSIBLE_TEST_DOCKER: "true"` so that we run ansible-test sanity
with docker
This should fix issues we are seeing with tox ansible-test failures

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2021-04-07 13:26:22 +02:00
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