Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25A8327E070 for ; Mon, 25 Aug 2025 19:42:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756150925; cv=none; b=RTTf4561FVHM9bPYYO0QKhgJcKPxhNUfErwy52f/VJbvx9rGmvXhUSgZLe4hqxy3PpTzd/keZpW68EdZza+H0oYwtiwPHG33JG4LrEY16QbRKwU50cHiwYKkRzSwfVxh1JVXDrHnMMKGWfyM2fW7WT7g3mGi20SPIq64LPjhBik= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756150925; c=relaxed/simple; bh=NFhBSD/1hPcshtvRLAD3hQUlZmWkNzFZ3XmfkK8WSx4=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=UdIBnzvMjhM6wWNqW9Dud2cZ6YBTCsa9FdEPn58HQnU3NO+NUlO0M44CEGn5Ct1obFXshNCp1isUYRJvYkdXb2giH4Z5lO7XbvecqrmDs5LdE2hPKC20R3s4Ze3dmAs2Or/aejEjk3hDBnz6jAqszIyf4qXdgR+P3zH1Z1FOBYQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M1AjBUxv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M1AjBUxv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEFE7C4CEED; Mon, 25 Aug 2025 19:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756150924; bh=NFhBSD/1hPcshtvRLAD3hQUlZmWkNzFZ3XmfkK8WSx4=; h=Date:Reply-To:Subject:To:References:From:In-Reply-To:From; b=M1AjBUxvQVjnBc37nL4yTjLc9AoJpWU4jFIeqM5sQ+qCWRhhWOsMoLXxlA9HjYYHE 7bZpGIfqruAsFX0ujGeBtG4WMTWU2OAqVD1J6s4PmLIUC7Ts20PMGMABVMxdptVaIP QP4ZZ506Ki68L3bobcwAApBklCGN+etCvoa3ZaFi7nmFZyuI9m4WXEFg7PKMAmI+GC Ppt2FTEuVImsqfahIbhxXddNA/1Arl3e3uZhexh48FybIiRSsdcTgCTUYjDaLKwiBt BPIr21OJTIVW8MRMyomFBfNfwRdW2ZXau6HmybRYtBViEkJuFOUe3PWnk6MbDcle6f b1aFirk7Q5t/Q== Message-ID: Date: Mon, 25 Aug 2025 21:42:01 +0200 Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Reply-To: Daniel Gomez Subject: Re: [RFT] scripts: add fix_ansible_lint.py To: Luis Chamberlain , Chuck Lever , Daniel Gomez , kdevops@lists.linux.dev References: <20250823012911.898920-1-mcgrof@kernel.org> Content-Language: en-US From: Daniel Gomez Organization: kernel.org In-Reply-To: <20250823012911.898920-1-mcgrof@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 23/08/2025 03.29, Luis Chamberlain wrote: > Add a script which fixes all fatal ansible-lint errors. > > Usage examples: > python3 scripts/fix_ansible_lint.py --changes-only > > python3 scripts/fix_ansible_lint.py > > python3 scripts/fix_ansible_lint.py playbooks/foo.yml playbooks/bar*.yml > > python3 scripts/fix_ansible_lint.py --dry-run > > python3 scripts/fix_ansible_lint.py --changes-only --check > > This tool goes beyond ansible-lint --fix by handling more issue types > and providing better control over what gets fixed. > > Generated-by: Claude AI > Signed-off-by: Luis Chamberlain > --- I have an ansible-lint --fix wrapper script that goes rule by rule: ./scripts/ansible-lint-fix-rules.py --no-rich --dry-run playbooks/ === Ansible-lint Rules to Process (11 total) === 1. command-instead-of-shell - Use shell only when shell functionality is required 2. deprecated-local-action - Replace deprecated local_action with delegate_to: localhost 3. fqcn - Use FQCN (Fully Qualified Collection Names) for builtin actions 4. jinja - Fix Jinja2 template formatting and syntax issues 5. key-order - Ensure proper key ordering in YAML mappings 6. name - Add or improve task and play names for better readability 7. no-free-form - Fix discouraged free-form syntax for action modules 8. no-jinja-when - Remove Jinja2 templating from when conditions 9. no-log-password - Add no_log to tasks containing password parameters 10. partial-become - Fix become_user tasks missing corresponding become directive 11. yaml - Fix YAML formatting and syntax issues reported by yamllint DRY RUN: Would process 11 fixable rules Commands that would be executed: ansible-lint --fix=command-instead-of-shell playbooks/ ansible-lint --fix=deprecated-local-action playbooks/ ansible-lint --fix=fqcn playbooks/ ansible-lint --fix=jinja playbooks/ ansible-lint --fix=key-order playbooks/ ansible-lint --fix=name playbooks/ ansible-lint --fix=no-free-form playbooks/ ansible-lint --fix=no-jinja-when playbooks/ ansible-lint --fix=no-log-password playbooks/ ansible-lint --fix=partial-become playbooks/ ansible-lint --fix=yaml playbooks/ I think the script below does things that the linter should be able to fix. Let me first post these patches and then, we can run this other one. Finally, ansible-lint also supports custom rules: https://ansible.readthedocs.io/projects/lint/custom-rules/ Not sure if autofix can be implemented though. In that case, it would make sense to augment the official linter I think. > > Request for testing -- if it works a bit maybe just merge it Daniel, as Indeed. Let's do testing to move this forward. > you're doing your changes? Then we can expand on it with more love as we > find new ways to fix these sorts of things? I'll use it for now for the > new workflows I have but I think you have a much broader agenda and can > likely just ask Claude to implement all its learned on the script? ansible-lint autofix support is limited. For the rest of the linter issues claude works well. But let's make sure we don't do things with claude that the current linter autofix already support.