From db10fc203511141f3dddf505de9e79883824fba1 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Wed, 6 Oct 2021 10:40:45 -0600 Subject: [PATCH] add support for ansible-core 2.11 ansible-lint, ansible-test Add support for using latest ansible-lint and ansible-test with ansible-core 2.11. There are a few new warnings that need to be addressed or suppressed. One of the changes is to add `# noqa ignore-errors` to the places in the role where `ignore_errors: true` is used. In general, it is not a good idea to use `ignore_errors: true` - instead, it is better to capture the result of the command using a `register`, then use `failed_when`. Or, if that is not possible, use a `block`/`rescue` for more complex error handling. However, in the case where the network role is using `ignore_errors: true` in test code, it is acceptable. see https://ansible-lint.readthedocs.io/en/latest/default_rules.html#ignore-errors Another change is to have all tasks have a valid `name:`. This is explained at https://ansible-lint.readthedocs.io/en/latest/default_rules.html#unnamed-task Signed-off-by: Rich Megginson --- .ansible-lint | 3 + .github/run_test.sh | 36 +++++----- .sanity-ansible-ignore-2.11.txt | 70 +++++++++++++++++++ .travis/custom.sh | 2 + .../playbooks/integration_pytest_python3.yml | 4 +- .../manual_test_ethtool_coalesce.yml | 11 +-- tests/playbooks/tests_802_1x.yml | 12 ++-- tests/playbooks/tests_auto_gateway.yml | 16 +++-- tests/playbooks/tests_bond.yml | 6 +- tests/playbooks/tests_bond_deprecated.yml | 6 +- tests/playbooks/tests_checkpoint_cleanup.yml | 9 ++- tests/playbooks/tests_dummy.yml | 3 +- tests/playbooks/tests_eth_dns_support.yml | 3 +- .../playbooks/tests_eth_pci_address_match.yml | 6 +- tests/playbooks/tests_ethernet.yml | 9 ++- tests/playbooks/tests_ethtool_coalesce.yml | 15 ++-- tests/playbooks/tests_ethtool_features.yml | 25 ++++--- tests/playbooks/tests_ethtool_ring.yml | 15 ++-- tests/playbooks/tests_ipv6.yml | 12 ++-- tests/playbooks/tests_ipv6_disabled.yml | 3 +- tests/playbooks/tests_provider.yml | 3 +- tests/playbooks/tests_reapply.yml | 9 ++- tests/playbooks/tests_states.yml | 3 +- tests/playbooks/tests_team.yml | 3 +- tests/playbooks/tests_vlan_mtu.yml | 8 ++- tests/playbooks/tests_wireless.yml | 12 ++-- tests/playbooks/tests_wireless_wpa3_owe.yml | 3 +- tests/tasks/activate_profile.yml | 3 +- tests/tasks/cleanup_profile+device.yml | 6 +- tests/tasks/create_bridge_profile.yml | 6 +- .../create_bridge_profile_no_autoconnect.yml | 6 +- tests/tasks/create_dummy_profile.yml | 6 +- tests/tasks/create_team_profile.yml | 6 +- .../create_test_interfaces_with_dhcp.yml | 2 +- tests/tasks/delete_interface.yml | 3 +- tests/tasks/manage_test_interface.yml | 2 +- .../create_and_remove_with_initscripts.yml | 6 +- tests/tasks/provider/create_with_nm.yml | 3 +- tests/tasks/provider/default_with_nm.yml | 3 +- tests/tasks/remove+down_profile.yml | 3 +- tests/tasks/remove_profile.yml | 3 +- tests/tasks/run_test.yml | 6 +- tests/tasks/show_interfaces.yml | 3 +- tests/tasks/test_802.1x_capath.yml | 6 +- 44 files changed, 269 insertions(+), 111 deletions(-) create mode 100644 .sanity-ansible-ignore-2.11.txt diff --git a/.ansible-lint b/.ansible-lint index 3f712ce..9125ee0 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -3,3 +3,6 @@ skip_list: - '106' # Role name does not match ^[a-z][a-z0-9_]+$ pattern - '303' # Using command rather than module - '403' # Package installs should not use latest +- var-naming # allow tests to use var names with Capital Letters +warn_list: +- load-failure # allow include_tasks with tasks/ directory diff --git a/.github/run_test.sh b/.github/run_test.sh index c2198a1..9ccfbd3 100755 --- a/.github/run_test.sh +++ b/.github/run_test.sh @@ -1,11 +1,13 @@ #!/bin/bash -x +set -euo pipefail + TEST_SOURCE_DIR="/network-role" C8S_CONTAINER_IMAGE="quay.io/linux-system-roles/c8s-network-role" C8_CONTAINER_IMAGE="quay.io/linux-system-roles/c8-network-role" PODMAN_OPTS="--systemd=true --privileged" -read -d '' TEST_FILES << EOF +read -r -d '' TEST_FILES << EOF || : tests_802_1x_nm.yml tests_bond_nm.yml tests_auto_gateway_nm.yml @@ -57,8 +59,9 @@ case $OS_TYPE in ;; esac -CONTAINER_ID=`podman run -d $PODMAN_OPTS \ - -v $PROJECT_PATH:$TEST_SOURCE_DIR $CONTAINER_IMAGE` +# shellcheck disable=SC2086 +CONTAINER_ID=$(podman run -d $PODMAN_OPTS \ + -v "$PROJECT_PATH":$TEST_SOURCE_DIR $CONTAINER_IMAGE) if [ -z "$CONTAINER_ID" ];then echo "Failed to start container" @@ -66,49 +69,46 @@ if [ -z "$CONTAINER_ID" ];then fi function clean_up { - podman rm -f $CONTAINER_ID || true + podman rm -f "$CONTAINER_ID" || true } -if [ -z "$DEBUG" ];then +if [ -z "${DEBUG:-}" ];then trap clean_up ERR EXIT fi -# Ensure we quit on first failure -set -e - # Ensure we are testing the latest packages and ignore upgrade failure -sudo podman exec -i $CONTAINER_ID /bin/bash -c 'dnf upgrade -y' || true +sudo podman exec -i "$CONTAINER_ID" /bin/bash -c 'dnf upgrade -y' || true -podman exec -i $CONTAINER_ID \ +podman exec -i "$CONTAINER_ID" \ /bin/bash -c \ 'while ! systemctl is-active dbus; do sleep 1; done' -podman exec -i $CONTAINER_ID \ +podman exec -i "$CONTAINER_ID" \ /bin/bash -c 'sysctl -w net.ipv6.conf.all.disable_ipv6=0' -sudo podman exec -i $CONTAINER_ID \ +sudo podman exec -i "$CONTAINER_ID" \ /bin/bash -c \ 'systemctl start systemd-udevd; while ! systemctl is-active systemd-udevd; do sleep 1; done' -podman exec -i $CONTAINER_ID \ +podman exec -i "$CONTAINER_ID" \ /bin/bash -c \ 'systemctl restart NetworkManager; while ! systemctl is-active NetworkManager; do sleep 1; done' -podman exec -i $CONTAINER_ID \ +podman exec -i "$CONTAINER_ID" \ /bin/bash -c \ 'systemctl restart sshd; while ! systemctl is-active sshd; do sleep 1; done' -podman exec -i $CONTAINER_ID \ +podman exec -i "$CONTAINER_ID" \ /bin/bash -c \ 'cat /dev/zero | ssh-keygen -q -N ""; cp -v /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys' for test_file in $TEST_FILES; do - podman exec -i $CONTAINER_ID \ + podman exec -i "$CONTAINER_ID" \ /bin/bash -c \ "cd $TEST_SOURCE_DIR; env ANSIBLE_HOST_KEY_CHECKING=False \ @@ -116,7 +116,7 @@ for test_file in $TEST_FILES; do ./tests/$test_file" done -if [ -n "$DEBUG" ];then - podman exec -it $CONTAINER_ID bash +if [ -n "${DEBUG:-}" ];then + podman exec -it "$CONTAINER_ID" bash clean_up fi diff --git a/.sanity-ansible-ignore-2.11.txt b/.sanity-ansible-ignore-2.11.txt new file mode 100644 index 0000000..9a89e03 --- /dev/null +++ b/.sanity-ansible-ignore-2.11.txt @@ -0,0 +1,70 @@ +plugins/module_utils/network_lsr/nm/__init__.py empty-init!skip +plugins/module_utils/network_lsr/nm/__init__.py import-2.6!skip +plugins/module_utils/network_lsr/nm/__init__.py import-2.7!skip +plugins/module_utils/network_lsr/nm/__init__.py import-3.5!skip +plugins/module_utils/network_lsr/nm/__init__.py import-3.6!skip +plugins/module_utils/network_lsr/nm/__init__.py import-3.7!skip +plugins/module_utils/network_lsr/nm/__init__.py import-3.8!skip +plugins/module_utils/network_lsr/nm/__init__.py import-3.9!skip +plugins/module_utils/network_lsr/nm/active_connection.py import-2.6!skip +plugins/module_utils/network_lsr/nm/active_connection.py import-2.7!skip +plugins/module_utils/network_lsr/nm/active_connection.py import-3.5!skip +plugins/module_utils/network_lsr/nm/active_connection.py import-3.6!skip +plugins/module_utils/network_lsr/nm/active_connection.py import-3.7!skip +plugins/module_utils/network_lsr/nm/active_connection.py import-3.8!skip +plugins/module_utils/network_lsr/nm/active_connection.py import-3.9!skip +plugins/module_utils/network_lsr/nm/client.py import-2.6!skip +plugins/module_utils/network_lsr/nm/client.py import-2.7!skip +plugins/module_utils/network_lsr/nm/client.py import-3.5!skip +plugins/module_utils/network_lsr/nm/client.py import-3.6!skip +plugins/module_utils/network_lsr/nm/client.py import-3.7!skip +plugins/module_utils/network_lsr/nm/client.py import-3.8!skip +plugins/module_utils/network_lsr/nm/client.py import-3.9!skip +plugins/module_utils/network_lsr/nm/connection.py import-2.6!skip +plugins/module_utils/network_lsr/nm/connection.py import-2.7!skip +plugins/module_utils/network_lsr/nm/connection.py import-3.5!skip +plugins/module_utils/network_lsr/nm/connection.py import-3.6!skip +plugins/module_utils/network_lsr/nm/connection.py import-3.7!skip +plugins/module_utils/network_lsr/nm/connection.py import-3.8!skip +plugins/module_utils/network_lsr/nm/connection.py import-3.9!skip +plugins/module_utils/network_lsr/nm/error.py import-2.6!skip +plugins/module_utils/network_lsr/nm/error.py import-2.7!skip +plugins/module_utils/network_lsr/nm/error.py import-3.5!skip +plugins/module_utils/network_lsr/nm/error.py import-3.6!skip +plugins/module_utils/network_lsr/nm/error.py import-3.7!skip +plugins/module_utils/network_lsr/nm/error.py import-3.8!skip +plugins/module_utils/network_lsr/nm/error.py import-3.9!skip +plugins/module_utils/network_lsr/nm/provider.py import-2.6!skip +plugins/module_utils/network_lsr/nm/provider.py import-2.7!skip +plugins/module_utils/network_lsr/nm/provider.py import-3.5!skip +plugins/module_utils/network_lsr/nm/provider.py import-3.6!skip +plugins/module_utils/network_lsr/nm/provider.py import-3.7!skip +plugins/module_utils/network_lsr/nm/provider.py import-3.8!skip +plugins/module_utils/network_lsr/nm/provider.py import-3.9!skip +plugins/modules/network_connections.py validate-modules:doc-default-does-not-match-spec +plugins/modules/network_connections.py validate-modules:doc-required-mismatch +plugins/modules/network_connections.py validate-modules:missing-examples +plugins/modules/network_connections.py validate-modules:missing-gplv3-license +plugins/modules/network_connections.py validate-modules:module-invalid-version-added +plugins/modules/network_connections.py validate-modules:no-default-for-required-parameter +plugins/modules/network_connections.py validate-modules:parameter-list-no-elements +plugins/modules/network_connections.py validate-modules:parameter-type-not-in-doc +plugins/modules/network_connections.py validate-modules:undocumented-parameter +tests/network/covstats shebang!skip +tests/network/ensure_provider_tests.py compile-2.6!skip +tests/network/ensure_provider_tests.py compile-2.7!skip +tests/network/ensure_provider_tests.py compile-3.5!skip +tests/network/ensure_provider_tests.py future-import-boilerplate!skip +tests/network/ensure_provider_tests.py metaclass-boilerplate!skip +tests/network/ensure_provider_tests.py shebang!skip +tests/network/get_coverage.sh shebang!skip +tests/network/get_total_coverage.sh shebang!skip +tests/network/integration/conftest.py future-import-boilerplate!skip +tests/network/integration/conftest.py metaclass-boilerplate!skip +tests/network/integration/test_ethernet.py future-import-boilerplate!skip +tests/network/integration/test_ethernet.py metaclass-boilerplate!skip +tests/network/merge_coverage.sh shebang!skip +tests/network/unit/test_network_connections.py future-import-boilerplate!skip +tests/network/unit/test_network_connections.py metaclass-boilerplate!skip +tests/network/unit/test_nm_provider.py future-import-boilerplate!skip +tests/network/unit/test_nm_provider.py metaclass-boilerplate!skip diff --git a/.travis/custom.sh b/.travis/custom.sh index a929d2a..210630d 100755 --- a/.travis/custom.sh +++ b/.travis/custom.sh @@ -3,6 +3,8 @@ set -e +# https://github.com/koalaman/shellcheck/wiki/SC1091 +# shellcheck disable=SC1091 . "$LSR_SCRIPTDIR/utils.sh" # Write your custom commands here that should be run when `tox -e custom`: diff --git a/tests/playbooks/integration_pytest_python3.yml b/tests/playbooks/integration_pytest_python3.yml index 86101a5..e31a335 100644 --- a/tests/playbooks/integration_pytest_python3.yml +++ b/tests/playbooks/integration_pytest_python3.yml @@ -112,8 +112,10 @@ modules_parent_and_dir.stdout_lines[1] ~ ':' ~ _rundir.path }}" - - debug: + - name: Show _lsr_python_path + debug: msg: path {{ _lsr_python_path }} + - name: "ls -alrtFR {{ _rundir.path }}" command: ls -alrtFR {{ _rundir.path }} diff --git a/tests/playbooks/manual_test_ethtool_coalesce.yml b/tests/playbooks/manual_test_ethtool_coalesce.yml index 8b2c456..39b2e2b 100644 --- a/tests/playbooks/manual_test_ethtool_coalesce.yml +++ b/tests/playbooks/manual_test_ethtool_coalesce.yml @@ -25,7 +25,8 @@ - name: Get current device coalesce command: "ethtool --show-coalesce {{ interface }}" register: original_ethtool_coalesce - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -46,7 +47,8 @@ TEST: I can set rx-frames and adaptive-tx. debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -63,7 +65,7 @@ - name: Get current device coalesce command: "ethtool --show-coalesce {{ interface }}" register: ethtool_coalesce - - name: + - name: Show ethtool_coalesce output debug: var: ethtool_coalesce.stdout_lines - name: Assert device coalesce @@ -78,7 +80,8 @@ - name: "TEST: I can reset coalesce to their original value." debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: diff --git a/tests/playbooks/tests_802_1x.yml b/tests/playbooks/tests_802_1x.yml index 9cce1ae..4d6da39 100644 --- a/tests/playbooks/tests_802_1x.yml +++ b/tests/playbooks/tests_802_1x.yml @@ -12,7 +12,8 @@ - name: "TEST: 802.1x profile with private key password and ca cert" debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -36,7 +37,8 @@ ca_cert: /etc/pki/tls/cacert.pem - name: "TEST: I can ping the EAP server" command: ping -c1 203.0.113.1 - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -55,7 +57,8 @@ mode: 0644 - name: Update ca trust command: update-ca-trust - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -79,7 +82,8 @@ domain_suffix_match: example.com - name: "TEST: I can ping the EAP server" command: ping -c1 203.0.113.1 - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: diff --git a/tests/playbooks/tests_auto_gateway.yml b/tests/playbooks/tests_auto_gateway.yml index 1972a9c..5dcc96c 100644 --- a/tests/playbooks/tests_auto_gateway.yml +++ b/tests/playbooks/tests_auto_gateway.yml @@ -14,7 +14,8 @@ TEST: I can configure an interface with auto_gateway enabled debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -58,14 +59,15 @@ - name: "TEARDOWN: remove profiles." debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: - name: "{{ interface }}" persistent_state: absent state: down - ignore_errors: true + ignore_errors: true # noqa ignore-errors - include_tasks: tasks/manage_test_interface.yml vars: state: absent @@ -76,7 +78,8 @@ - include_tasks: tasks/manage_test_interface.yml vars: state: present - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -120,14 +123,15 @@ - name: "TEARDOWN: remove profiles." debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: - name: "{{ interface }}" persistent_state: absent state: down - ignore_errors: true + ignore_errors: true # noqa ignore-errors - include_tasks: tasks/manage_test_interface.yml vars: state: absent diff --git a/tests/playbooks/tests_bond.yml b/tests/playbooks/tests_bond.yml index c1a3956..1fef2fb 100644 --- a/tests/playbooks/tests_bond.yml +++ b/tests/playbooks/tests_bond.yml @@ -27,7 +27,8 @@ - name: "TEST Add Bond with 2 ports" debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -80,7 +81,8 @@ delay: 2 always: - block: - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: diff --git a/tests/playbooks/tests_bond_deprecated.yml b/tests/playbooks/tests_bond_deprecated.yml index 82598c3..56353bf 100644 --- a/tests/playbooks/tests_bond_deprecated.yml +++ b/tests/playbooks/tests_bond_deprecated.yml @@ -23,7 +23,8 @@ - name: "TEST Add Bond with 2 ports using deprecated 'master' argument" debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -76,7 +77,8 @@ delay: 2 always: - block: - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: diff --git a/tests/playbooks/tests_checkpoint_cleanup.yml b/tests/playbooks/tests_checkpoint_cleanup.yml index b55d0f4..3432a89 100644 --- a/tests/playbooks/tests_checkpoint_cleanup.yml +++ b/tests/playbooks/tests_checkpoint_cleanup.yml @@ -10,7 +10,8 @@ profile: "{{ interface }}" network_provider: nm pre_tasks: - - debug: + - name: Show test banner + debug: msg: Inside states tests - include_tasks: tasks/show_interfaces.yml - include_tasks: tasks/assert_device_absent.yml @@ -24,7 +25,8 @@ name: dbus-tools state: present # create test profile - - include_role: + - name: Include network role + include_role: name: linux-system-roles.network vars: network_provider: initscripts @@ -60,7 +62,8 @@ - name: get NM dbus objects command: busctl --system tree --list org.freedesktop.NetworkManager register: nm_dbus_objects - - debug: + - name: Show nm_dbus_objects + debug: var: nm_dbus_objects - name: Assert that no checkpoints are left assert: diff --git a/tests/playbooks/tests_dummy.yml b/tests/playbooks/tests_dummy.yml index 8fe8762..3b97844 100644 --- a/tests/playbooks/tests_dummy.yml +++ b/tests/playbooks/tests_dummy.yml @@ -7,7 +7,8 @@ lsr_fail_debug: - __network_connections_result tasks: - - debug: + - name: Show playbook name + debug: msg: "this is: playbooks/tests_dummy.yml" tags: - always diff --git a/tests/playbooks/tests_eth_dns_support.yml b/tests/playbooks/tests_eth_dns_support.yml index 4b4beb0..107ff34 100644 --- a/tests/playbooks/tests_eth_dns_support.yml +++ b/tests/playbooks/tests_eth_dns_support.yml @@ -20,7 +20,8 @@ state: present - include_tasks: tasks/assert_device_present.yml - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: diff --git a/tests/playbooks/tests_eth_pci_address_match.yml b/tests/playbooks/tests_eth_pci_address_match.yml index 5211ba0..5a5316e 100644 --- a/tests/playbooks/tests_eth_pci_address_match.yml +++ b/tests/playbooks/tests_eth_pci_address_match.yml @@ -2,7 +2,8 @@ --- - hosts: all tasks: - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -64,7 +65,8 @@ msg: "The PCI address is not removed" always: - block: - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: diff --git a/tests/playbooks/tests_ethernet.yml b/tests/playbooks/tests_ethernet.yml index cd02579..1b48147 100644 --- a/tests/playbooks/tests_ethernet.yml +++ b/tests/playbooks/tests_ethernet.yml @@ -2,9 +2,11 @@ --- - hosts: all tasks: - - debug: + - name: Show inside ethernet tests + debug: msg: Inside ethernet tests - - debug: + - name: Show network_provider + debug: var: network_provider - name: Test configuring ethernet devices @@ -42,7 +44,8 @@ - hosts: all tasks: - - debug: + - name: Show network_provider + debug: var: network_provider # FIXME: assert profile present diff --git a/tests/playbooks/tests_ethtool_coalesce.yml b/tests/playbooks/tests_ethtool_coalesce.yml index 691f46f..fc46031 100644 --- a/tests/playbooks/tests_ethtool_coalesce.yml +++ b/tests/playbooks/tests_ethtool_coalesce.yml @@ -5,7 +5,8 @@ interface: testnic1 type: veth tasks: - - debug: + - name: Show playbook name + debug: msg: "this is: playbooks/tests_ethtool_coalesce.yml" tags: - always @@ -28,7 +29,8 @@ TEST: I can create a profile without any coalescing option. debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -66,7 +68,8 @@ TEST: I can set rx-frames. debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -106,7 +109,8 @@ - name: "TEST: I can clear coalescing options" debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -142,7 +146,8 @@ always: - block: - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: diff --git a/tests/playbooks/tests_ethtool_features.yml b/tests/playbooks/tests_ethtool_features.yml index 5cda09e..678e8d4 100644 --- a/tests/playbooks/tests_ethtool_features.yml +++ b/tests/playbooks/tests_ethtool_features.yml @@ -5,7 +5,8 @@ interface: testnic1 type: veth tasks: - - debug: + - name: Show playbook name + debug: msg: "this is: playbooks/tests_ethtool_features.yml" tags: - always @@ -32,7 +33,8 @@ - name: Get current device features command: "ethtool --show-features {{ interface }}" register: original_ethtool_features - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -55,7 +57,8 @@ TEST: I can disable gro and tx-tcp-segmentation and enable gso. debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -73,7 +76,7 @@ - name: Get current device features command: "ethtool --show-features {{ interface }}" register: ethtool_features - - name: + - name: Show ethtool_features debug: var: ethtool_features.stdout_lines - name: Assert device features @@ -94,7 +97,8 @@ TEST: I can enable tx_tcp_segmentation (using underscores). debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -110,7 +114,7 @@ - name: Get current device features command: "ethtool --show-features {{ interface }}" register: ethtool_features - - name: + - name: Show ethtool_features debug: var: ethtool_features.stdout_lines - name: Assert device features @@ -156,14 +160,16 @@ - name: Check failure debug: var: __network_connections_result - - assert: + - name: Assert that the result is failure + assert: that: __network_connections_result.failed - name: "TEST: I can reset features to their original value." debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -185,7 +191,8 @@ network_provider == 'nm' always: - block: - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: diff --git a/tests/playbooks/tests_ethtool_ring.yml b/tests/playbooks/tests_ethtool_ring.yml index 00b0460..0c41474 100644 --- a/tests/playbooks/tests_ethtool_ring.yml +++ b/tests/playbooks/tests_ethtool_ring.yml @@ -5,7 +5,8 @@ interface: testnic1 type: veth tasks: - - debug: + - name: Show playbook name + debug: msg: "this is: playbooks/tests_ethtool_ring.yml" tags: - always @@ -28,7 +29,8 @@ TEST: I can create a profile without any ring option. debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -66,7 +68,8 @@ TEST: I can set rx. debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -144,7 +147,8 @@ - name: "TEST: I can clear ring options" debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -180,7 +184,8 @@ always: - block: - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: diff --git a/tests/playbooks/tests_ipv6.yml b/tests/playbooks/tests_ipv6.yml index 98d98d1..5fb5c1e 100644 --- a/tests/playbooks/tests_ipv6.yml +++ b/tests/playbooks/tests_ipv6.yml @@ -23,7 +23,8 @@ TEST: I can configure an interface with static ipv6 config debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -45,7 +46,7 @@ - name: Get ip address information command: "ip addr show {{ interface }}" register: ip_addr - - name: + - name: Show ip_addr debug: var: ip_addr.stdout - name: Assert ipv6 addresses are correctly set @@ -60,7 +61,7 @@ - name: Get ipv6 routes command: "ip -6 route" register: ipv6_route - - name: + - name: Show ipv6_route debug: var: ipv6_route.stdout - name: Assert default ipv6 route is set @@ -77,14 +78,15 @@ - name: "TEARDOWN: remove profiles." debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: - name: "{{ interface }}" persistent_state: absent state: down - ignore_errors: true + ignore_errors: true # noqa ignore-errors - include_tasks: tasks/manage_test_interface.yml vars: state: absent diff --git a/tests/playbooks/tests_ipv6_disabled.yml b/tests/playbooks/tests_ipv6_disabled.yml index ad397d0..09e46e3 100644 --- a/tests/playbooks/tests_ipv6_disabled.yml +++ b/tests/playbooks/tests_ipv6_disabled.yml @@ -19,7 +19,8 @@ state: present - include_tasks: tasks/assert_device_present.yml - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: diff --git a/tests/playbooks/tests_provider.yml b/tests/playbooks/tests_provider.yml index 1db2d08..c804f87 100644 --- a/tests/playbooks/tests_provider.yml +++ b/tests/playbooks/tests_provider.yml @@ -7,7 +7,8 @@ lsr_fail_debug: - __network_connections_result tasks: - - debug: + - name: Show playbook name + debug: msg: "this is: playbooks/tests_states.yml" tags: - always diff --git a/tests/playbooks/tests_reapply.yml b/tests/playbooks/tests_reapply.yml index eda4329..f68322c 100644 --- a/tests/playbooks/tests_reapply.yml +++ b/tests/playbooks/tests_reapply.yml @@ -10,7 +10,8 @@ profile: "{{ interface }}" network_provider: nm pre_tasks: - - debug: + - name: Show test banner + debug: msg: Inside states tests - include_tasks: tasks/show_interfaces.yml - include_tasks: tasks/assert_device_absent.yml @@ -19,7 +20,8 @@ tasks: - block: # create test profile - - include_role: + - name: Include network role + include_role: name: linux-system-roles.network vars: network_connections: @@ -46,7 +48,8 @@ auto6: false ignore_errors: true register: test_module_run - - debug: + - name: Show test_module_run + debug: var: test_module_run - name: Assert that reapply is found in log output assert: diff --git a/tests/playbooks/tests_states.yml b/tests/playbooks/tests_states.yml index eec27c0..426aebf 100644 --- a/tests/playbooks/tests_states.yml +++ b/tests/playbooks/tests_states.yml @@ -7,7 +7,8 @@ lsr_fail_debug: - __network_connections_result tasks: - - debug: + - name: Show playbook name + debug: msg: "this is: playbooks/tests_states.yml" tags: - always diff --git a/tests/playbooks/tests_team.yml b/tests/playbooks/tests_team.yml index 67a7b80..a12fff2 100644 --- a/tests/playbooks/tests_team.yml +++ b/tests/playbooks/tests_team.yml @@ -7,7 +7,8 @@ lsr_fail_debug: - __network_connections_result tasks: - - debug: + - name: Show playbook name + debug: msg: "this is: playbooks/tests_team.yml" tags: - always diff --git a/tests/playbooks/tests_vlan_mtu.yml b/tests/playbooks/tests_vlan_mtu.yml index 029b599..2eabd9f 100644 --- a/tests/playbooks/tests_vlan_mtu.yml +++ b/tests/playbooks/tests_vlan_mtu.yml @@ -15,7 +15,8 @@ TEST: I can configure the MTU for a vlan interface without autoconnect. debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -51,7 +52,8 @@ - name: "TEARDOWN: remove profiles." debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -61,7 +63,7 @@ - name: "{{ vlan_interface }}" persistent_state: absent state: down - ignore_errors: true + ignore_errors: true # noqa ignore-errors - include_tasks: tasks/manage_test_interface.yml vars: state: absent diff --git a/tests/playbooks/tests_wireless.yml b/tests/playbooks/tests_wireless.yml index 822a15e..22d0b0c 100644 --- a/tests/playbooks/tests_wireless.yml +++ b/tests/playbooks/tests_wireless.yml @@ -21,7 +21,8 @@ - name: "TEST: wireless connection with WPA-PSK" debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_allow_restart: true @@ -38,7 +39,8 @@ ssid: "mock_wifi" key_mgmt: "wpa-psk" password: "p@55w0rD" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -48,7 +50,8 @@ - name: "TEST: wireless connection with 802.1x TLS-EAP" debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_allow_restart: true @@ -75,7 +78,8 @@ ca_cert: /etc/pki/tls/cacert.pem always: - block: - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: diff --git a/tests/playbooks/tests_wireless_wpa3_owe.yml b/tests/playbooks/tests_wireless_wpa3_owe.yml index c0e87ac..a4a5ded 100644 --- a/tests/playbooks/tests_wireless_wpa3_owe.yml +++ b/tests/playbooks/tests_wireless_wpa3_owe.yml @@ -12,7 +12,8 @@ - name: "TEST: wireless connection with OWE" debug: msg: "##################################################" - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_allow_restart: true diff --git a/tests/tasks/activate_profile.yml b/tests/tasks/activate_profile.yml index dea878c..e3e75bd 100644 --- a/tests/tasks/activate_profile.yml +++ b/tests/tasks/activate_profile.yml @@ -1,6 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- -- include_role: +- name: Include network role + include_role: name: linux-system-roles.network vars: network_connections: diff --git a/tests/tasks/cleanup_profile+device.yml b/tests/tasks/cleanup_profile+device.yml index 92d1eba..07021e0 100644 --- a/tests/tasks/cleanup_profile+device.yml +++ b/tests/tasks/cleanup_profile+device.yml @@ -1,9 +1,11 @@ # SPDX-License-Identifier: BSD-3-Clause --- -- shell: | +- name: Cleanup profile and device + shell: | nmcli con delete {{ interface }} nmcli con load /etc/sysconfig/network-scripts/ifcfg-{{ interface }} rm -f /etc/sysconfig/network-scripts/ifcfg-{{ interface }} ip link del {{ interface }} - ignore_errors: true + ignore_errors: true # noqa ignore-errors + changed_when: false ... diff --git a/tests/tasks/create_bridge_profile.yml b/tests/tasks/create_bridge_profile.yml index e846127..4eb2248 100644 --- a/tests/tasks/create_bridge_profile.yml +++ b/tests/tasks/create_bridge_profile.yml @@ -1,6 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- -- include_role: +- name: Include network role + include_role: name: linux-system-roles.network vars: network_connections: @@ -10,6 +11,7 @@ ip: dhcp4: false auto6: false -- debug: +- name: Show result + debug: var: __network_connections_result ... diff --git a/tests/tasks/create_bridge_profile_no_autoconnect.yml b/tests/tasks/create_bridge_profile_no_autoconnect.yml index 308f57d..f93ec5d 100644 --- a/tests/tasks/create_bridge_profile_no_autoconnect.yml +++ b/tests/tasks/create_bridge_profile_no_autoconnect.yml @@ -1,6 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- -- include_role: +- name: Include network role + include_role: name: linux-system-roles.network vars: network_connections: @@ -11,6 +12,7 @@ ip: dhcp4: false auto6: false -- debug: +- name: Show result + debug: var: __network_connections_result ... diff --git a/tests/tasks/create_dummy_profile.yml b/tests/tasks/create_dummy_profile.yml index 950be6b..a1b9655 100644 --- a/tests/tasks/create_dummy_profile.yml +++ b/tests/tasks/create_dummy_profile.yml @@ -1,6 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- -- include_role: +- name: Include network role + include_role: name: linux-system-roles.network vars: network_connections: @@ -10,6 +11,7 @@ ip: address: - "192.0.2.42/30" -- debug: +- name: Show result + debug: var: __network_connections_result ... diff --git a/tests/tasks/create_team_profile.yml b/tests/tasks/create_team_profile.yml index 8bd36b0..458a66f 100644 --- a/tests/tasks/create_team_profile.yml +++ b/tests/tasks/create_team_profile.yml @@ -1,6 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- -- include_role: +- name: Include network role + include_role: name: linux-system-roles.network vars: network_connections: @@ -10,6 +11,7 @@ ip: dhcp4: false auto6: false -- debug: +- name: Show result + debug: var: __network_connections_result ... diff --git a/tests/tasks/create_test_interfaces_with_dhcp.yml b/tests/tasks/create_test_interfaces_with_dhcp.yml index 1026a7b..3035680 100644 --- a/tests/tasks/create_test_interfaces_with_dhcp.yml +++ b/tests/tasks/create_test_interfaces_with_dhcp.yml @@ -38,7 +38,7 @@ # We need to add iptables rule to allow dhcp request iptables -I INPUT -i testbr -p udp --dport 67:68 --sport 67:68 -j ACCEPT - # Add {{dhcp_interface1}}, {{dhcp_interface2}} peers into the testbr + # Add {{ dhcp_interface1 }}, {{ dhcp_interface2 }} peers into the testbr brctl addif testbr {{ dhcp_interface1 }}p brctl addif testbr {{ dhcp_interface2 }}p diff --git a/tests/tasks/delete_interface.yml b/tests/tasks/delete_interface.yml index 064e17f..6950569 100644 --- a/tests/tasks/delete_interface.yml +++ b/tests/tasks/delete_interface.yml @@ -2,5 +2,6 @@ --- - name: remove test interface if necessary command: "ip link del {{ interface }}" - ignore_errors: true + ignore_errors: true # noqa ignore-errors + changed_when: false ... diff --git a/tests/tasks/manage_test_interface.yml b/tests/tasks/manage_test_interface.yml index 602c778..03cda8d 100644 --- a/tests/tasks/manage_test_interface.yml +++ b/tests/tasks/manage_test_interface.yml @@ -30,7 +30,7 @@ command: nmcli d set {{ interface }} managed true # The varible for `network_provider` is not exists yet, # just ignore error for initscripts - ignore_errors: yes + ignore_errors: yes # noqa ignore-errors when: "type == 'veth' and state == 'present'" - name: Delete veth interface {{ interface }} diff --git a/tests/tasks/provider/create_and_remove_with_initscripts.yml b/tests/tasks/provider/create_and_remove_with_initscripts.yml index fd011cb..f88d2c3 100644 --- a/tests/tasks/provider/create_and_remove_with_initscripts.yml +++ b/tests/tasks/provider/create_and_remove_with_initscripts.yml @@ -1,6 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- -- include_role: +- name: Include network role + include_role: name: linux-system-roles.network vars: network_connections: @@ -12,7 +13,8 @@ ip: address: 192.0.2.1/24 network_provider: initscripts -- include_role: +- name: Include network role + include_role: name: linux-system-roles.network vars: network_connections: diff --git a/tests/tasks/provider/create_with_nm.yml b/tests/tasks/provider/create_with_nm.yml index 077841c..f438c4f 100644 --- a/tests/tasks/provider/create_with_nm.yml +++ b/tests/tasks/provider/create_with_nm.yml @@ -1,6 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- -- include_role: +- name: Include network role + include_role: name: linux-system-roles.network vars: network_connections: diff --git a/tests/tasks/provider/default_with_nm.yml b/tests/tasks/provider/default_with_nm.yml index 967bb7f..349ae24 100644 --- a/tests/tasks/provider/default_with_nm.yml +++ b/tests/tasks/provider/default_with_nm.yml @@ -1,6 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- -- include_role: +- name: Include network role + include_role: name: linux-system-roles.network vars: network_connections: [] diff --git a/tests/tasks/remove+down_profile.yml b/tests/tasks/remove+down_profile.yml index 99c0c8e..19cbfee 100644 --- a/tests/tasks/remove+down_profile.yml +++ b/tests/tasks/remove+down_profile.yml @@ -1,6 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- -- include_role: +- name: Include network role + include_role: name: linux-system-roles.network vars: network_connections: diff --git a/tests/tasks/remove_profile.yml b/tests/tasks/remove_profile.yml index a7dbc12..7378e86 100644 --- a/tests/tasks/remove_profile.yml +++ b/tests/tasks/remove_profile.yml @@ -1,6 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- -- include_role: +- name: Include network role + include_role: name: linux-system-roles.network vars: network_connections: diff --git a/tests/tasks/run_test.yml b/tests/tasks/run_test.yml index 5e9993c..a7b0124 100644 --- a/tests/tasks/run_test.yml +++ b/tests/tasks/run_test.yml @@ -6,7 +6,8 @@ debug: msg: "########## {{ lsr_description }} ##########" - - debug: + - name: Show item + debug: var: "{{ item }}" loop: - lsr_description @@ -52,7 +53,8 @@ debug: msg: "!!!!! Failure in test '{{ lsr_description }}' !!!!!" - - debug: + - name: Show item that failed + debug: var: "{{ item }}" loop: "{{ lsr_fail_debug | default([]) }}" diff --git a/tests/tasks/show_interfaces.yml b/tests/tasks/show_interfaces.yml index 6c2fbec..078fd7b 100644 --- a/tests/tasks/show_interfaces.yml +++ b/tests/tasks/show_interfaces.yml @@ -1,5 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause --- - include: get_current_interfaces.yml -- debug: +- name: Show current_interfaces + debug: msg: "current_interfaces: {{ current_interfaces }}" diff --git a/tests/tasks/test_802.1x_capath.yml b/tests/tasks/test_802.1x_capath.yml index 9431aec..93a3745 100644 --- a/tests/tasks/test_802.1x_capath.yml +++ b/tests/tasks/test_802.1x_capath.yml @@ -50,7 +50,8 @@ register: __network_NM_NVR changed_when: false - block: - - import_role: + - name: Import network role + import_role: name: linux-system-roles.network vars: network_connections: @@ -77,7 +78,8 @@ fail: msg: after test rescue: - - debug: + - name: Show failed item + debug: var: "{{ item }}" with_items: - ansible_failed_result