From 4bac670e650b936767a5589dd3466f65dbf613fc Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Tue, 28 Feb 2023 17:00:06 -0500 Subject: [PATCH] ansible-lint: Fix name[template] warnings Jinja templates should only be at the end of 'name'. This helps with the identification of tasks inside the source code when they fail. Signed-off-by: Wen Liang --- tests/playbooks/down_profile.yml | 2 +- tests/playbooks/integration_pytest_python3.yml | 2 +- tests/playbooks/tests_bond_removal.yml | 12 ++++++------ tests/playbooks/tests_eth_dns_support.yml | 2 +- tests/playbooks/tests_ethernet.yml | 2 +- tests/playbooks/tests_ipv6_disabled.yml | 2 +- tests/playbooks/tests_network_state.yml | 4 ++-- tests/playbooks/tests_route_table.yml | 2 +- tests/playbooks/tests_routing_rules.yml | 18 +++++++++--------- tests/playbooks/tests_switch_provider.yml | 5 +++-- tests/tasks/assert_device_absent.yml | 2 +- tests/tasks/assert_device_present.yml | 2 +- tests/tasks/assert_profile_absent.yml | 2 +- tests/tasks/assert_profile_present.yml | 4 ++-- tests/tests_unit.yml | 3 ++- 15 files changed, 33 insertions(+), 31 deletions(-) diff --git a/tests/playbooks/down_profile.yml b/tests/playbooks/down_profile.yml index 5087240..3f18a40 100644 --- a/tests/playbooks/down_profile.yml +++ b/tests/playbooks/down_profile.yml @@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause --- -- name: Set {{ profile }} down +- name: Set down {{ profile }} hosts: all vars: network_connections: diff --git a/tests/playbooks/integration_pytest_python3.yml b/tests/playbooks/integration_pytest_python3.yml index 31d0178..24b31e2 100644 --- a/tests/playbooks/integration_pytest_python3.yml +++ b/tests/playbooks/integration_pytest_python3.yml @@ -85,7 +85,7 @@ args: chdir: "{{ _rundir.path }}" - - name: "Create {{ _rundir.path }}/ansible" + - name: "Create subdirectory './ansible' under '{{ _rundir.path }}'" file: state: directory path: "{{ _rundir.path }}/ansible" diff --git a/tests/playbooks/tests_bond_removal.yml b/tests/playbooks/tests_bond_removal.yml index 4fa4891..82c6f50 100644 --- a/tests/playbooks/tests_bond_removal.yml +++ b/tests/playbooks/tests_bond_removal.yml @@ -94,16 +94,16 @@ persistent_state: absent state: down - - name: Get the port1 profile "{{ port1_profile }}" from the active - connection + - name: From the active connection, get the port1 profile + "{{ port1_profile }}" command: nmcli c show --active {{ port1_profile }} register: active_port1_profile ignore_errors: true changed_when: false when: network_provider == "nm" - - name: Get the port2 profile "{{ port2_profile }}" from the active - connection + - name: From the active connection, get the port2 profile + "{{ port2_profile }}" command: nmcli c show --active {{ port2_profile }} register: active_port2_profile ignore_errors: true @@ -192,8 +192,8 @@ persistent_state: absent state: down - - name: Get the controller profile "{{ controller_profile }}" from the - active connection + - name: From the active connection, get the controller profile + "{{ controller_profile }}" command: nmcli c show --active {{ controller_profile }} register: active_controller_profile ignore_errors: true diff --git a/tests/playbooks/tests_eth_dns_support.yml b/tests/playbooks/tests_eth_dns_support.yml index 4e98270..5c7f8ca 100644 --- a/tests/playbooks/tests_eth_dns_support.yml +++ b/tests/playbooks/tests_eth_dns_support.yml @@ -10,7 +10,7 @@ tasks: - - name: "set type={{ type }} and interface={{ interface }}" + - name: "set type={{ type }} and interface={{ interface }}" # noqa name set_fact: type: "{{ type }}" interface: "{{ interface }}" diff --git a/tests/playbooks/tests_ethernet.yml b/tests/playbooks/tests_ethernet.yml index 3b70a6e..913f100 100644 --- a/tests/playbooks/tests_ethernet.yml +++ b/tests/playbooks/tests_ethernet.yml @@ -16,7 +16,7 @@ interface: lsr27 tasks: - - name: "set type={{ type }} and interface={{ interface }}" + - name: "set type={{ type }} and interface={{ interface }}" # noqa name set_fact: type: "{{ type }}" interface: "{{ interface }}" diff --git a/tests/playbooks/tests_ipv6_disabled.yml b/tests/playbooks/tests_ipv6_disabled.yml index ac7842b..ad541ea 100644 --- a/tests/playbooks/tests_ipv6_disabled.yml +++ b/tests/playbooks/tests_ipv6_disabled.yml @@ -9,7 +9,7 @@ interface: ethtest0 tasks: - - name: "set type={{ type }} and interface={{ interface }}" + - name: "set type={{ type }} and interface={{ interface }}" # noqa name set_fact: type: "{{ type }}" interface: "{{ interface }}" diff --git a/tests/playbooks/tests_network_state.yml b/tests/playbooks/tests_network_state.yml index b34ceb6..8472d86 100644 --- a/tests/playbooks/tests_network_state.yml +++ b/tests/playbooks/tests_network_state.yml @@ -11,7 +11,7 @@ tasks: - - name: "set type={{ type }} and interface={{ interface0 }}" + - name: "set type={{ type }} and interface={{ interface0 }}" # noqa name set_fact: type: "{{ type }}" interface: "{{ interface0 }}" @@ -20,7 +20,7 @@ vars: state: present - include_tasks: tasks/assert_device_present.yml - - name: "set type={{ type }} and interface={{ interface1 }}" + - name: "set type={{ type }} and interface={{ interface1 }}" # noqa name set_fact: type: "{{ type }}" interface: "{{ interface1 }}" diff --git a/tests/playbooks/tests_route_table.yml b/tests/playbooks/tests_route_table.yml index 59f38af..a214021 100644 --- a/tests/playbooks/tests_route_table.yml +++ b/tests/playbooks/tests_route_table.yml @@ -10,7 +10,7 @@ tasks: - - name: "set type={{ type }} and interface={{ interface }}" + - name: "set type={{ type }} and interface={{ interface }}" # noqa name set_fact: type: "{{ type }}" interface: "{{ interface }}" diff --git a/tests/playbooks/tests_routing_rules.yml b/tests/playbooks/tests_routing_rules.yml index 2235b06..82ec3f7 100644 --- a/tests/playbooks/tests_routing_rules.yml +++ b/tests/playbooks/tests_routing_rules.yml @@ -9,7 +9,7 @@ interface: ethtest0 tasks: - - name: "set type={{ type }} and interface={{ interface }}" + - name: "set type={{ type }} and interface={{ interface }}" # noqa name set_fact: type: "{{ type }}" interface: "{{ interface }}" @@ -199,8 +199,8 @@ specified rule" when: ansible_distribution_major_version != "7" - - name: Assert that the IPv4 routing rule in the connection - "{{ interface }}" matches the specified rule + - name: Assert that the specified IPv4 routing rule was configured in the + connection "{{ interface }}" assert: that: - connection_route_rule.stdout is search("priority 30200 from @@ -221,11 +221,11 @@ 0.0.0.0/0 oif oiftest table 30400") - connection_route_rule.stdout is search("priority 200 from 198.51.100.56/26 table 200") - msg: "the IPv4 routing rule in the connection '{{ interface }}' does - not match the specified rule" + msg: "the specified IPv4 routing rule was not configured in the + connection '{{ interface }}'" - - name: Assert that the IPv6 routing rule in the connection - "{{ interface }}" matches the specified rule + - name: Assert that the specified IPv6 routing rule was configured in the + connection "{{ interface }}" assert: that: - connection_route_rule6.stdout is search("priority 30600 to @@ -234,8 +234,8 @@ ::/0 dport 128-256 table 30600") or connection_route_rule6.stdout is search("not priority 30601 from ::/0 dport 128-256 table 30600") - msg: "the IPv6 routing rule in the connection '{{ interface }}' does - not match the specified rule" + msg: "the specified IPv6 routing rule was not configured in the + connection '{{ interface }}'" - name: Remove the dedicated test file in `/etc/iproute2/rt_tables.d/` file: diff --git a/tests/playbooks/tests_switch_provider.yml b/tests/playbooks/tests_switch_provider.yml index 8645134..8007d70 100644 --- a/tests/playbooks/tests_switch_provider.yml +++ b/tests/playbooks/tests_switch_provider.yml @@ -11,7 +11,8 @@ interface: LST-TST-br34 tags: - always - - name: "Create test bridge {{ interface }} via initscripts provider" + - name: "Through the initscripts provider, create test bridge + {{ interface }}" include_role: name: linux-system-roles.network vars: @@ -33,7 +34,7 @@ network_provider: nm tags: - always - - name: "Create test bridge {{ interface }} via nm provider" + - name: "Through the nm provider, create test bridge {{ interface }}" include_role: name: linux-system-roles.network vars: diff --git a/tests/tasks/assert_device_absent.yml b/tests/tasks/assert_device_absent.yml index 2736c78..98f0d80 100644 --- a/tests/tasks/assert_device_absent.yml +++ b/tests/tasks/assert_device_absent.yml @@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - include_tasks: get_interface_stat.yml -- name: "assert that interface {{ interface }} is absent" +- name: "assert that the interface is absent - '{{ interface }}'" assert: that: not interface_stat.stat.exists msg: "{{ interface }} exists" diff --git a/tests/tasks/assert_device_present.yml b/tests/tasks/assert_device_present.yml index 4bf3310..f221b66 100644 --- a/tests/tasks/assert_device_present.yml +++ b/tests/tasks/assert_device_present.yml @@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - include_tasks: get_interface_stat.yml -- name: "assert that interface {{ interface }} is present" +- name: "assert that the interface is present - '{{ interface }}'" assert: that: interface_stat.stat.exists msg: "{{ interface }} does not exist" diff --git a/tests/tasks/assert_profile_absent.yml b/tests/tasks/assert_profile_absent.yml index c577e29..5676360 100644 --- a/tests/tasks/assert_profile_absent.yml +++ b/tests/tasks/assert_profile_absent.yml @@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - include_tasks: get_profile_stat.yml -- name: "assert that profile '{{ profile }}' is absent" +- name: "assert that the profile is absent - '{{ profile }}'" assert: that: not lsr_net_profile_exists msg: "profile {{ profile }} does exist" diff --git a/tests/tasks/assert_profile_present.yml b/tests/tasks/assert_profile_present.yml index 987c8e8..f7b011b 100644 --- a/tests/tasks/assert_profile_present.yml +++ b/tests/tasks/assert_profile_present.yml @@ -1,12 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause --- - include_tasks: get_profile_stat.yml -- name: "assert that profile '{{ profile }}' is present" +- name: "assert that the profile is present - '{{ profile }}'" assert: that: lsr_net_profile_exists msg: "profile {{ profile }} does not exist" -- name: "assert that ansible managed comment in '{{ profile }}' is present" +- name: "assert that the ansible managed comment is present in '{{ profile }}'" assert: that: lsr_net_profile_ansible_managed msg: "profile {{ profile }} does not have the ansible managed comment" diff --git a/tests/tests_unit.yml b/tests/tests_unit.yml index 5a59179..26f1c14 100644 --- a/tests/tests_unit.yml +++ b/tests/tests_unit.yml @@ -62,7 +62,8 @@ args: chdir: "{{ _rundir.path }}" - - name: Create {{ _rundir.path }}/ansible/module_utils + - name: Create subdirectory '/ansible/module_utils' under + '{{ _rundir.path }}' file: state: directory path: "{{ item }}"