+
Skip to content

no-free-form Rule Only Auto-fixes FQCN, Not Short Module Name #4750

@iliyavl

Description

@iliyavl

Bug: no-free-form Rule Only Auto-fixes FQCN, Not Short Module Name

Summary

The no-free-form rule in ansible-lint detects and auto-fixes free-form (key=value) usage for modules when the fully qualified collection name (FQCN) is used (e.g., ansible.builtin.file), but does not auto-fix when the short module name (e.g., file) is used. This is inconsistent, as most users write tasks using the short module name.

Steps to Reproduce

  1. Create a playbook with a task using the short module name in free-form:

    - name: Example with discouraged free-form syntax
      hosts: localhost
      tasks:
        - name: mkdir /var/DS
          file: path=/var/DS state=directory mode=0755 owner=svc group=Infra
  2. Run:

    ansible-lint test.yaml --fix
    
  3. The violation is detected, but the file is not auto-fixed.

  4. Change the task to use the FQCN:

    - name: mkdir /var/DS
      ansible.builtin.file: path=/var/DS state=directory mode=0755 owner=svc group=Infra
  5. Run:

    ansible-lint test.yaml --fix
    
  6. The violation is detected and the file is auto-fixed to YAML dictionary style.

Expected Behavior

  • The no-free-form rule should auto-fix free-form usage for both FQCN and short module names, as most playbooks use the short form.

Actual Behavior

  • Auto-fix only works for FQCN, not for short module names.

Environment

  • ansible-lint version: ansible-lint 25.8.2 using ansible-core:2.17.1 ansible-compat:25.8.1 ruamel-yaml:0.18.15 ruamel-yaml-clib:0.2.12
  • Python version: Python 3.10.12
  • OS: Ubuntu

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载