Skip to content

Converting to builtin.command from shell removes code comments #4655

@kkmuffme

Description

@kkmuffme
Summary

When changing "shell:" to "ansible.builtin.command:" when using --fix it removes all code comments in the shell but also any code comments that are not even part of the shell but above the next "- name"

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint 25.6.1
STEPS TO REPRODUCE
- name: foo
  shell: "whatever"

# a comment
- name: bar
  shell: |
   something
#  shell: "foobar"
  register: hello

Run ansible-lint --fix --profile production

Results in:

- name: Foo
  ansible.builtin.command: "whatever"
- name: Bar
  ansible.builtin.command: |
    something
  register: hello
Desired Behavior

Don't remove code comments for and after shell

Actual Behavior

Removes code comments in and after shell

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions