Skip to content

Commit 2c8c239

Browse files
committed
ansible-lint: comprehensive linting and manual fixes
This commit addresses systematic ansible-lint violations across the entire kdevops playbook infrastructure using both automated tools and manual fixes. Manual fixes performed: 1. Fixed ansible-lint --fix corruption - Resolved DuplicateKeyError in linux-mirror/tasks/main.yml where duplicate failed_when keys were incorrectly added by automated fixing - Corrected malformed YAML patterns in devconfig/tasks/main.yml where ansible-lint --fix corrupted variable syntax (path: "{{" -> path: "{{ var }}") 2. Systematic rule violation fixes - no-changed-when: Added changed_when: false to information-gathering commands (git status, systemctl is-active, uname, etc.) that don't modify system state - ignore-errors: Replaced ignore_errors: true with appropriate failed_when conditions for connectivity checks and optional operations - name[missing]: Added descriptive names to all unnamed tasks across 200+ playbook files, including distribution-specific setup tasks and package management role inclusions - yaml[truthy]: Standardized boolean values to use true/false instead of yes/no for consistency 3. Enhanced error handling - Replaced blanket ignore_errors with specific failed_when conditions for: - Network connectivity checks (failed_when: false) - Firewall status checks (failed_when: firewalld_status.rc not in [0, 3, 4]) - APT mirror connectivity checks - Optional git operations and file checks 4. Improved task clarity - Added meaningful task names following "action + target" pattern - Improved debugging capability by making all operations clearly identifiable - Enhanced maintainability for future development - Added proper spacing between tasks for better readability 5. Automated tooling created - Scripts for systematic fixing of common patterns - Validation tools to ensure consistency across roles - Pattern matching for bulk updates while preserving manual customizations 6. Additional missing task names fixed - Fixed 20 additional install-deps/main.yml files with missing task names - Added consistent naming for distribution-specific setup tasks: - "Include package management role" for ansible.builtin.include_role - "Debian/Ubuntu distribution specific setup" for debian import_tasks - "SUSE distribution specific setup" for suse import_tasks - "RedHat distribution specific setup" for redhat import_tasks - "Fedora distribution specific setup" for fedora import_tasks - Ensured proper blank line spacing between consecutive tasks The result is a more maintainable, debuggable, and reliable automation infrastructure that follows Ansible best practices while preserving all existing functionality. Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]>
1 parent 9a2ffc4 commit 2c8c239

File tree

234 files changed

+5308
-5098
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+5308
-5098
lines changed

playbooks/bootlinux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: bootlinux
2+
- name: Bootlinux
33
hosts: all
44
roles:
55
- role: bootlinux

playbooks/cxl.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: cxl
2+
- name: Cxl
33
hosts: baseline:dev
44
roles:
55
- role: cxl

playbooks/devconfig.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
- name: Configure developer environment on target systems
33
hosts: baseline:dev
4-
gather_facts: no
4+
gather_facts: false
55
roles:
66
- role: devconfig

playbooks/roles/ansible_cfg/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
ansible.builtin.template:
1616
src: "ansible.cfg.j2"
1717
dest: "{{ ansible_cfg_file }}"
18-
mode: '0755'
18+
mode: "0755"
1919

2020
- name: Update ansible.cfg access modification time so make sees it updated
2121
ansible.builtin.file:
2222
path: "{{ topdir_path }}/ansible.cfg"
2323
state: touch
24-
mode: '0755'
24+
mode: "0755"

playbooks/roles/blktests/defaults/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# Our sensible defaults for the blktests role.
44
#
55
# We default to not run tests.
6-
kdevops_run_blktests: False
7-
run_tests_on_failures: False
8-
blktests_skip_run: False
6+
kdevops_run_blktests: false
7+
run_tests_on_failures: false
8+
blktests_skip_run: false
99

1010
# Ror instance you can use "-g quick" but note that this may produce
1111
# not results as all quick tests may be expunded.
@@ -21,5 +21,5 @@ nbd_git: "https://github.com/NetworkBlockDevice/nbd.git"
2121
nbd_version: "nbd-3.21"
2222
nbd_data: "{{data_path}}/nbd"
2323

24-
compile_dbench: False
24+
compile_dbench: false
2525
blktests_dbench_git: "https://github.com/linux-kdevops/dbench.git"
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
---
12
# SPDX-License-Identifier GPL-2.0+ OR MIT
23
- name: Restart watchdog daemon
3-
service: name="{{watchdog_service_name}}" state=restarted
4+
ansible.builtin.service:
5+
name: "{{ watchdog_service_name }}"
6+
state: restarted

playbooks/roles/blktests/tasks/install-deps/debian/main.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
---
22
- name: Update apt cache
3-
become: yes
4-
become_method: sudo
5-
apt:
6-
update_cache: yes
3+
become: true
4+
become_method: ansible.builtin.sudo
5+
ansible.builtin.apt:
6+
update_cache: true
77
tags: linux
88

99
- name: Install nvme tools
10-
become: yes
11-
become_method: sudo
12-
apt:
10+
become: true
11+
become_method: ansible.builtin.sudo
12+
ansible.builtin.apt:
1313
name:
1414
- nvme-cli
15-
update_cache: yes
15+
update_cache: true
1616

1717
- name: Install blktests build dependencies
18-
become: yes
19-
become_method: sudo
20-
apt:
18+
become: true
19+
become_method: ansible.builtin.sudo
20+
ansible.builtin.apt:
2121
name:
2222
- bison
2323
- flex
@@ -65,5 +65,5 @@
6565
- libnl-utils
6666
- zlib1g-dev
6767
state: present
68-
update_cache: yes
69-
tags: [ 'blktests', 'deps' ]
68+
update_cache: true
69+
tags: ["blktests", "deps"]
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
---
2-
- include_role:
2+
- name: Include package management role
3+
ansible.builtin.include_role:
34
name: pkg
45

56
# tasks to install dependencies for oscheck
6-
- name: oscheck distribution ospecific setup
7-
import_tasks: tasks/install-deps/debian/main.yml
7+
- name: Oscheck distribution ospecific setup
8+
ansible.builtin.import_tasks: tasks/install-deps/debian/main.yml
89
when: ansible_facts['os_family']|lower == 'debian'
9-
- import_tasks: tasks/install-deps/suse/main.yml
10+
11+
- name: SUSE distribution specific setup
12+
ansible.builtin.import_tasks: tasks/install-deps/suse/main.yml
1013
when: ansible_facts['os_family']|lower == 'suse'
11-
- import_tasks: tasks/install-deps/redhat/main.yml
14+
15+
- name: RedHat distribution specific setup
16+
ansible.builtin.import_tasks: tasks/install-deps/redhat/main.yml
1217
when: ansible_facts['os_family']|lower == 'redhat'

playbooks/roles/blktests/tasks/install-deps/redhat/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
- name: Install build dependencies for blktests
3-
become: yes
4-
become_method: sudo
5-
yum:
6-
update_cache: yes
3+
become: true
4+
become_method: ansible.builtin.sudo
5+
ansible.builtin.dnf:
6+
update_cache: true
77
name: "{{ packages }}"
88
vars:
99
packages:

0 commit comments

Comments
 (0)