ansible-lint: Fix key-order[task] failures

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
This commit is contained in:
Wen Liang 2023-03-20 16:04:03 -04:00 committed by Fernando Fernández Mancera
parent 4bac670e65
commit a384e5bb00
32 changed files with 160 additions and 160 deletions

View file

@ -11,7 +11,11 @@ import sys
GET_NM_VERSION = """
- block:
- when:
- ansible_distribution_major_version != '6'
tags:
- always
block:
- name: Install NetworkManager
package:
name: NetworkManager
@ -20,10 +24,6 @@ GET_NM_VERSION = """
command: rpm -q --qf "%{version}" NetworkManager
register: networkmanager_version
when: true
when:
- ansible_distribution_major_version != '6'
tags:
- always
"""
MINIMUM_NM_VERSION_CHECK = """

View file

@ -102,7 +102,9 @@
when:
network_provider == 'nm'
always:
- block:
- tags:
- "tests::cleanup"
block:
- import_role:
name: linux-system-roles.network
vars:
@ -114,5 +116,3 @@
- include_tasks: tasks/manage_test_interface.yml
vars:
state: absent
tags:
- "tests::cleanup"

View file

@ -93,7 +93,9 @@
- include_tasks: tasks/test_802.1x_capath.yml
always:
- block:
- tags:
- "tests::cleanup"
block:
- import_role:
name: linux-system-roles.network
vars:
@ -124,5 +126,3 @@
- /etc/pki/ca-trust/source/anchors/cacert.pem
- name: Update ca trust
command: update-ca-trust
tags:
- "tests::cleanup"

View file

@ -66,25 +66,27 @@
- "{{ controller_profile }}"
- "{{ port1_profile }}"
- "{{ port2_profile }}"
- command: grep 'Polling Interval'
- name: "** TEST check polling interval"
command: grep 'Polling Interval'
/proc/net/bonding/{{ controller_device }}
name: "** TEST check polling interval"
register: result
until: "'110' in result.stdout"
- command: ip -4 a s {{ controller_device }}
name: "** TEST check IPv4"
- name: "** TEST check IPv4"
command: ip -4 a s {{ controller_device }}
register: result
until: "'192.0.2' in result.stdout"
retries: 20
delay: 2
- command: ip -6 a s {{ controller_device }}
name: "** TEST check IPv6"
- name: "** TEST check IPv6"
command: ip -6 a s {{ controller_device }}
register: result
until: "'2001' in result.stdout"
retries: 20
delay: 2
always:
- block:
- tags:
- "tests::cleanup"
block:
- name: Import network role
import_role:
name: linux-system-roles.network
@ -107,5 +109,3 @@
command: mv -vf /etc/resolv.conf.bak /etc/resolv.conf
when:
- network_provider == "initscripts"
tags:
- "tests::cleanup"

View file

@ -103,7 +103,9 @@
when: network_provider == 'initscripts'
always:
- block:
- tags:
- "tests::cleanup"
block:
- name: Import network role
import_role:
name: linux-system-roles.network
@ -126,5 +128,3 @@
command: mv -vf /etc/resolv.conf.bak /etc/resolv.conf
when:
- network_provider == "initscripts"
tags:
- "tests::cleanup"

View file

@ -62,25 +62,27 @@
- "{{ controller_profile }}"
- "{{ port1_profile }}"
- "{{ port2_profile }}"
- command: grep 'Polling Interval'
- name: "** TEST check polling interval"
command: grep 'Polling Interval'
/proc/net/bonding/{{ controller_device }}
name: "** TEST check polling interval"
register: result
until: "'110' in result.stdout"
- command: ip -4 a s {{ controller_device }}
name: "** TEST check IPv4"
- name: "** TEST check IPv4"
command: ip -4 a s {{ controller_device }}
register: result
until: "'192.0.2' in result.stdout"
retries: 20
delay: 2
- command: ip -6 a s {{ controller_device }}
name: "** TEST check IPv6"
- name: "** TEST check IPv6"
command: ip -6 a s {{ controller_device }}
register: result
until: "'2001' in result.stdout"
retries: 20
delay: 2
always:
- block:
- tags:
- "tests::cleanup"
block:
- name: Import network role
import_role:
name: linux-system-roles.network
@ -99,5 +101,3 @@
- command: ip link del {{ controller_device }}
ignore_errors: true
- import_tasks: tasks/remove_test_interfaces_with_dhcp.yml
tags:
- "tests::cleanup"

View file

@ -79,9 +79,9 @@
- "{{ port1_profile }}"
- "{{ port2_profile }}"
- command: cat
- name: "** TEST check bond settings"
command: cat
/sys/class/net/{{ controller_device }}/bonding/'{{ item.key }}'
name: "** TEST check bond settings"
register: result
until: "'{{ item.value }}' in result.stdout"
loop:
@ -102,14 +102,14 @@
- { key: 'use_carrier', value: '1'}
- { key: 'xmit_hash_policy', value: 'encap2+3'}
- command: ip -4 a s {{ controller_device }}
name: "** TEST check IPv4"
- name: "** TEST check IPv4"
command: ip -4 a s {{ controller_device }}
register: result
until: "'192.0.2' in result.stdout"
retries: 20
delay: 2
- command: ip -6 a s {{ controller_device }}
name: "** TEST check IPv6"
- name: "** TEST check IPv6"
command: ip -6 a s {{ controller_device }}
register: result
until: "'2001' in result.stdout"
retries: 20
@ -145,9 +145,9 @@
type: ethernet
interface_name: "{{ dhcp_interface2 }}"
controller: "{{ controller_profile }}"
- command: cat
- name: "** TEST check bond settings"
command: cat
/sys/class/net/{{ controller_device }}/bonding/'{{ item.key }}'
name: "** TEST check bond settings"
register: result
until: "'{{ item.value }}' in result.stdout"
loop:
@ -157,21 +157,23 @@
- { key: 'arp_validate', value: 'none'}
- { key: 'primary', value: '{{ dhcp_interface1 }}'}
- command: ip -4 a s {{ controller_device }}
name: "** TEST check IPv4"
- name: "** TEST check IPv4"
command: ip -4 a s {{ controller_device }}
register: result
until: "'192.0.2' in result.stdout"
retries: 20
delay: 2
- command: ip -6 a s {{ controller_device }}
name: "** TEST check IPv6"
- name: "** TEST check IPv6"
command: ip -6 a s {{ controller_device }}
register: result
until: "'2001' in result.stdout"
retries: 20
delay: 2
always:
- block:
- tags:
- "tests::cleanup"
block:
- name: Import network role
import_role:
name: linux-system-roles.network
@ -190,5 +192,3 @@
- command: ip link del {{ controller_device }}
ignore_errors: true
- import_tasks: tasks/remove_test_interfaces_with_dhcp.yml
tags:
- "tests::cleanup"

View file

@ -66,19 +66,19 @@
- "{{ controller_profile }}"
- "{{ port1_profile }}"
- "{{ port2_profile }}"
- command: grep 'Polling Interval'
- name: "** TEST check polling interval"
command: grep 'Polling Interval'
/proc/net/bonding/{{ controller_device }}
name: "** TEST check polling interval"
register: result
until: "'110' in result.stdout"
- command: ip -4 a s {{ controller_device }}
name: "** TEST check IPv4"
- name: "** TEST check IPv4"
command: ip -4 a s {{ controller_device }}
register: result
until: "'192.0.2' in result.stdout"
retries: 20
delay: 2
- command: ip -6 a s {{ controller_device }}
name: "** TEST check IPv6"
- name: "** TEST check IPv6"
command: ip -6 a s {{ controller_device }}
register: result
until: "'2001' in result.stdout"
retries: 20
@ -224,7 +224,9 @@
when: network_provider == "initscripts"
always:
- block:
- tags:
- "tests::cleanup"
block:
- name: Import network role
import_role:
name: linux-system-roles.network
@ -241,5 +243,3 @@
command: mv -vf /etc/resolv.conf.bak /etc/resolv.conf
when:
- network_provider == "initscripts"
tags:
- "tests::cleanup"

View file

@ -72,7 +72,10 @@
'/org/freedesktop/NetworkManager/Checkpoint/' not in
nm_dbus_objects.stdout_lines
always:
- block:
- tags:
- "tests::cleanup"
ignore_errors: true
block:
# Use internal module directly for speedup
- network_connections:
provider: nm
@ -84,6 +87,3 @@
dest: "/etc/sysconfig/network-scripts/ifcfg-{{ interface }}"
state: absent
- command: ip link del "{{ interface }}"
ignore_errors: true
tags:
- "tests::cleanup"

View file

@ -13,7 +13,9 @@
tags:
- always
- block:
- tags:
- tests::dummy:create
block:
- include_tasks: tasks/run_test.yml
vars:
lsr_description: Create a dummy interface
@ -27,5 +29,3 @@
- tasks/assert_device_present.yml
lsr_cleanup:
- tasks/cleanup_profile+device.yml
tags:
- tests::dummy:create

View file

@ -64,7 +64,9 @@
- "'pci-0001:00:00.0' not in clear_path.stdout"
msg: "The PCI address is not removed"
always:
- block:
- tags:
- "tests::cleanup"
block:
- name: Import network role
import_role:
name: linux-system-roles.network
@ -74,5 +76,3 @@
persistent_state: absent
state: down
ignore_errors: true
tags:
- "tests::cleanup"

View file

@ -145,7 +145,9 @@
- network_provider == "initscripts"
always:
- block:
- tags:
- "tests::cleanup"
block:
- name: Import network role
import_role:
name: linux-system-roles.network
@ -157,5 +159,3 @@
- include_tasks: tasks/manage_test_interface.yml
vars:
state: absent
tags:
- "tests::cleanup"

View file

@ -191,7 +191,9 @@
when:
network_provider == 'nm'
always:
- block:
- tags:
- "tests::cleanup"
block:
- name: Import network role
import_role:
name: linux-system-roles.network
@ -204,5 +206,3 @@
- include_tasks: tasks/manage_test_interface.yml
vars:
state: absent
tags:
- "tests::cleanup"

View file

@ -183,7 +183,9 @@
- network_provider == "initscripts"
always:
- block:
- tags:
- "tests::cleanup"
block:
- name: Import network role
import_role:
name: linux-system-roles.network
@ -195,5 +197,3 @@
- include_tasks: tasks/manage_test_interface.yml
vars:
state: absent
tags:
- "tests::cleanup"

View file

@ -1,6 +1,8 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- hosts: all
tags:
- "tests::infiniband"
tasks:
- block:
- name: TEST Configuring infiniband devices
@ -45,22 +47,24 @@
msg: the settings in the virtual device ib0.000a
match the specified settings
- command: ip -4 a s ib0.000a
name: "** TEST check IPv4"
- name: "** TEST check IPv4"
command: ip -4 a s ib0.000a
register: result
until: "'198.51.100.133/30' in result.stdout"
retries: 20
delay: 2
- command: ip -6 a s ib0.000a
name: "** TEST check IPv6"
- name: "** TEST check IPv6"
command: ip -6 a s ib0.000a
register: result
until: "'2001:db8::2/32' in result.stdout"
retries: 20
delay: 2
always:
- block:
- tags:
- "tests::cleanup"
block:
- name: Import network role
import_role:
name: linux-system-roles.network
@ -75,7 +79,3 @@
ignore_errors: true
- command: ip link del ib0.000a
ignore_errors: true
tags:
- "tests::cleanup"
tags:
- "tests::infiniband"

View file

@ -146,7 +146,9 @@
when: ansible_distribution_major_version | int > 7
always:
- block:
- tags:
- "tests::cleanup"
block:
- import_role:
name: linux-system-roles.network
vars:
@ -155,5 +157,3 @@
persistent_state: absent
state: down
ignore_errors: true
tags:
- "tests::cleanup"

View file

@ -199,8 +199,8 @@
msg: the file `/etc/resolv.conf` contains the specified DNS
configuration
- command: resolvectl
name: "** TEST check resolvectl"
- name: "** TEST check resolvectl"
command: resolvectl
register: result
until: "'example.com' in result.stdout"
retries: 20

View file

@ -14,7 +14,9 @@
- always
- block:
- tags:
- tests::provider:initscripts_to_nm
block:
- include_tasks: tasks/run_test.yml
vars:
state: present
@ -32,5 +34,3 @@
- tasks/assert_profile_present.yml
lsr_cleanup:
- tasks/cleanup_profile+device.yml
tags:
- tests::provider:initscripts_to_nm

View file

@ -57,7 +57,10 @@
fail_msg: Reapply not found in log output
that: "{{ 'connection reapplied' in test_module_run.stderr }}"
always:
- block:
- tags:
- "tests::cleanup"
ignore_errors: true
block:
# Use internal module directly for speedup
- network_connections:
provider: nm
@ -66,6 +69,3 @@
persistent_state: absent
state: down
- command: ip link del "{{ interface }}"
ignore_errors: true
tags:
- "tests::cleanup"

View file

@ -153,6 +153,8 @@
when: network_provider == "nm"
always:
- name: Remove test configuration
tags:
- "tests::cleanup"
block:
- name: Bring down test devices and profiles
include_role:
@ -183,6 +185,4 @@
loop:
- "{{ interface0 }}"
- "{{ interface1 }}"
tags:
- "tests::cleanup"
...

View file

@ -14,7 +14,9 @@
- always
- block:
- tags:
- tests::states:create
block:
- include_tasks: tasks/run_test.yml
vars:
lsr_description: I can create a profile
@ -32,10 +34,10 @@
when: "{{ network_provider == 'nm' }}"
lsr_cleanup:
- tasks/cleanup_profile+device.yml
tags:
- tests::states:create
- block:
- tags:
- tests::states:create_without_autoconnect
block:
- include_tasks: tasks/run_test.yml
vars:
lsr_description: I can create a profile without autoconnect
@ -50,10 +52,10 @@
- tasks/assert_profile_present.yml
lsr_cleanup:
- tasks/cleanup_profile+device.yml
tags:
- tests::states:create_without_autoconnect
- block:
- tags:
- tests::states:activate
block:
- include_tasks: tasks/run_test.yml
vars:
lsr_description: I can activate an existing profile
@ -66,10 +68,10 @@
- tasks/assert_profile_present.yml
lsr_cleanup:
- tasks/cleanup_profile+device.yml
tags:
- tests::states:activate
- block:
- tags:
- tests::states:remove_up
block:
- include_tasks: tasks/run_test.yml
vars:
lsr_description: I can remove an existing profile without taking it
@ -84,10 +86,10 @@
- tasks/assert_profile_absent.yml
lsr_cleanup:
- tasks/cleanup_profile+device.yml
tags:
- tests::states:remove_up
- block:
- tags:
- tests::states:remove_down
block:
- include_tasks: tasks/run_test.yml
vars:
lsr_description: I can take a profile down that is absent
@ -104,10 +106,10 @@
when: "{{ network_provider == 'nm' }}"
lsr_cleanup:
- tasks/cleanup_profile+device.yml
tags:
- tests::states:remove_down
- block:
- tags:
- tests::states:remove_down_twice
block:
- include_tasks: tasks/run_test.yml
vars:
lsr_description: I will not get an error when I try to
@ -129,5 +131,3 @@
when: "{{ network_provider == 'nm' }}"
lsr_cleanup:
- tasks/cleanup_profile+device.yml
tags:
- tests::states:remove_down_twice

View file

@ -13,7 +13,9 @@
tags:
- always
- block:
- tags:
- tests::team:create
block:
- include_tasks: tasks/run_test.yml
vars:
lsr_description: Create a team interface without any port attached
@ -27,5 +29,3 @@
- tasks/assert_device_present.yml
lsr_cleanup:
- tasks/cleanup_profile+device.yml
tags:
- tests::team:create

View file

@ -77,7 +77,9 @@
client_cert: /etc/pki/tls/client.pem
ca_cert: /etc/pki/tls/cacert.pem
always:
- block:
- tags:
- "tests::cleanup"
block:
- name: Import network role
import_role:
name: linux-system-roles.network
@ -88,5 +90,3 @@
state: down
ignore_errors: true
- include_tasks: tasks/cleanup_mock_wifi.yml
tags:
- "tests::cleanup"

View file

@ -1,6 +1,9 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- block:
- when:
- ansible_distribution in ['RedHat', 'CentOS']
- ansible_distribution_major_version in ['7', '8']
block:
- name: Create EPEL {{ ansible_distribution_major_version }}
command:
cmd: >-
@ -23,9 +26,6 @@
- name: Enable EPEL 8
command: dnf config-manager --set-enabled epel
when: ansible_distribution_major_version == '8'
when:
- ansible_distribution in ['RedHat', 'CentOS']
- ansible_distribution_major_version in ['7', '8']
- name: Enable EPEL 6
copy:

View file

@ -1,6 +1,8 @@
# SPDX-License-Identifier: BSD-3-Clause
---
- block:
- tags:
- always
block:
- name: Get NetworkManager RPM version
command:
cmd: rpm -qa --qf '%{name}-%{version}-%{release}\n' NetworkManager
@ -13,6 +15,4 @@
- name: Show NetworkManager version
debug:
var: networkmanager_nvr
tags:
- always
...

View file

@ -39,6 +39,9 @@
when: nm_profile_exists.rc == 0
- name: Check ansible_managed comment for the initscripts case
when:
- profile_stat.stat.exists
- nm_profile_exists.rc != 0
block:
- name: Get the ansible_managed comment in ifcfg-{{ profile }}
command: >-
@ -51,6 +54,3 @@
lsr_net_profile_ansible_managed: true
when:
- _result.stdout_lines | length == 1
when:
- profile_stat.stat.exists
- nm_profile_exists.rc != 0

View file

@ -55,7 +55,9 @@
assert:
that: not __network_connections_result is changed
always:
- block:
- tags:
- "tests::cleanup"
block:
- include_role:
name: linux-system-roles.network
vars:
@ -67,5 +69,3 @@
- include_tasks: tasks/manage_test_interface.yml
vars:
state: absent
tags:
- "tests::cleanup"

View file

@ -12,7 +12,11 @@
tags:
- always
- block:
- when:
- ansible_distribution_major_version != '6'
tags:
- always
block:
- name: Install NetworkManager
package:
name: NetworkManager
@ -21,10 +25,6 @@
command: rpm -q --qf "%{version}" NetworkManager
register: networkmanager_version
when: true
when:
- ansible_distribution_major_version != '6'
tags:
- always
# The test requires or should run with NetworkManager, therefore it cannot run

View file

@ -12,7 +12,11 @@
tags:
- always
- block:
- when:
- ansible_distribution_major_version != '6'
tags:
- always
block:
- name: Install NetworkManager
package:
name: NetworkManager
@ -21,10 +25,6 @@
command: rpm -q --qf "%{version}" NetworkManager
register: networkmanager_version
when: true
when:
- ansible_distribution_major_version != '6'
tags:
- always
# The test requires or should run with NetworkManager, therefore it cannot run

View file

@ -12,7 +12,11 @@
tags:
- always
- block:
- when:
- ansible_distribution_major_version != '6'
tags:
- always
block:
- name: Install NetworkManager
package:
name: NetworkManager
@ -21,10 +25,6 @@
command: rpm -q --qf "%{version}" NetworkManager
register: networkmanager_version
when: true
when:
- ansible_distribution_major_version != '6'
tags:
- always
# The test requires or should run with NetworkManager, therefore it cannot run

View file

@ -12,7 +12,11 @@
tags:
- always
- block:
- when:
- ansible_distribution_major_version != '6'
tags:
- always
block:
- name: Install NetworkManager
package:
name: NetworkManager
@ -21,10 +25,6 @@
command: rpm -q --qf "%{version}" NetworkManager
register: networkmanager_version
when: true
when:
- ansible_distribution_major_version != '6'
tags:
- always
# The test requires or should run with NetworkManager, therefore it cannot run

View file

@ -12,7 +12,11 @@
tags:
- always
- block:
- when:
- ansible_distribution_major_version != '6'
tags:
- always
block:
- name: Install NetworkManager
package:
name: NetworkManager
@ -21,10 +25,6 @@
command: rpm -q --qf "%{version}" NetworkManager
register: networkmanager_version
when: true
when:
- ansible_distribution_major_version != '6'
tags:
- always
# The test requires or should run with NetworkManager, therefore it cannot run