Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto fix mode results in stack trace for invalid playbook #3840

Closed
ganeshrn opened this issue Oct 13, 2023 · 0 comments · Fixed by #3844
Closed

Auto fix mode results in stack trace for invalid playbook #3840

ganeshrn opened this issue Oct 13, 2023 · 0 comments · Fixed by #3844
Assignees
Labels
AAP Ansible Automation Platform bug

Comments

@ganeshrn
Copy link
Member

ganeshrn commented Oct 13, 2023

Summary
Issue Type
  • Bug Report
OS / ENVIRONMENT
% ansible-lint --version
ansible-lint 6.20.3 using ansible-core:2.15.1 ansible-compat:4.1.10 ruamel-yaml:0.17.26 ruamel-yaml-clib:0.2.7
  • ansible installation method: one of source, pip, OS package
  • ansible-lint installation method: one of source, pip, OS package
STEPS TO REPRODUCE
---
- name: Test
  hosts: localhost
  gather_facts: false

  tasks:
    - name: Print hello message
      ansible.builtin.debug:
            msg: "Hello!"
          register: vm_output

Run ansible-lint for above playbook

ansible-lint playbooks/test.yml --fix all
Desired Behavior

Should report syntax-error rule violation without stacktrace

Actual Behavior

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
% ansible-playbook --syntax-check playbooks/test.yml 
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
  did not find expected key

The error appears to be in '/Users/test/Documents/ansible-lightspeed-bot/sample/lightspeed_demos_private/playbooks/test.yml': line 10, column 11, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

            msg: "Hello!"
          register: vm_output
          ^ here

Stacktrace


  File "/Users/test/Documents/venv/plugin/lib/python3.10/site-packages/ruamel/yaml/parser.py", line 585, in parse_block_mapping_key
    raise ParserError(
ruamel.yaml.parser.ParserError: while parsing a block mapping
  in "<unicode string>", line 7, column 7:
        - name: Print hello message
          ^ (line: 7)
expected <block end>, but found '<block mapping start>'
  in "<unicode string>", line 10, column 11:
              register: vm_output
              ^ (line: 10)
@ganeshrn ganeshrn added new Triage required bug labels Oct 13, 2023
@ganeshrn ganeshrn added the AAP Ansible Automation Platform label Oct 13, 2023
@audgirka audgirka self-assigned this Oct 16, 2023
@audgirka audgirka removed the new Triage required label Oct 16, 2023
@audgirka audgirka moved this to In Progress in 🧰 devtools project board Oct 16, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in 🧰 devtools project board Oct 16, 2023
@cognifloyd cognifloyd moved this from Backlog to Done in ansible-lint --fix Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AAP Ansible Automation Platform bug
Projects
Status: Done
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants