Skip to content

--fix breaks no-free-form rule #4862

@MichaelBitard

Description

@MichaelBitard
Summary

When using --fix, every oneliner that has a variable inside is broken.
For example, if I have this:

- dnf: name=https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-{{ ansible_distribution_version }}.noarch.rpm

I get

- ansible.builtin.dnf:
    name: https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-{{
    cmd: ansible_distribution_version }}.noarch.rpm
Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint 25 using ansible-core:2.18.11 ansible-compat:25.8.1 ruamel-yaml:0.18.16 ruamel-yaml-clib:0.2.12
  • ansible installation method: fedora 43 dnf
  • ansible-lint installation method: fedora 43 dnf
STEPS TO REPRODUCE

For example this role:

---
- dnf: name=https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-{{ ansible_distribution_version }}.noarch.rpm state=latest
  become: true
- dnf: name=https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-{{ ansible_distribution_version }}.noarch.rpm
  become: true
- dnf: name=kodi state=latest
  become: true
ansible-lint --fix this-file.yml
Desired Behavior
---
- ansible.builtin.dnf:
    name: https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-{{ ansible_distribution_version }}.noarch.rpm
    state: latest
  become: true
- ansible.builtin.dnf:
    name: https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-{{ ansible_distribution_version }}.noarch.rpm
  become: true
- ansible.builtin.dnf:
    name: kodi
    state: latest
  become: true
Actual Behavior
---
- ansible.builtin.dnf:
    name: https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-{{
    state: latest
    cmd: ansible_distribution_version }}.noarch.rpm
  become: true
- ansible.builtin.dnf:
    name: https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-{{
    cmd: ansible_distribution_version }}.noarch.rpm
  become: true
- ansible.builtin.dnf:
    name: kodi
    state: latest
  become: true

Please give some details of what is happening. Include a minimum complete
verifiable example
with:

  • minimized playbook to reproduce the error
  • the output of running ansible-lint including the command line used
  • if you're getting a stack trace, also the output of
    ansible-playbook --syntax-check playbook

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions