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

IndexError is thrown from jinja.py with basic profile and --write=all option #3739

Closed
TamiTakamiya opened this issue Sep 16, 2023 · 2 comments · Fixed by #3747
Closed

IndexError is thrown from jinja.py with basic profile and --write=all option #3739

TamiTakamiya opened this issue Sep 16, 2023 · 2 comments · Fixed by #3747
Assignees
Labels
AAP Ansible Automation Platform bug critical

Comments

@TamiTakamiya
Copy link

Summary

IndexError is thrown from jinja.py with basic profile and --write=all option

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint 6.19.0 using ansible-core:2.15.4 ansible-compat:4.1.10 ruamel-yaml:0.17.32 ruamel-yaml-clib:0.2.7
  • ansible installation method: pip
  • ansible-lint installation method: pip
STEPS TO REPRODUCE
git clone https://github.com/IBM/Ansible-OpenShift-Provisioning.git
cd Ansible-OpenShift-Provisioning.git
ansible-lint --profile basic --write=all playbooks/5_setup_bastion.yaml
Desired Behavior

No error occurs.

Actual Behavior

IndexError: list index out of range error occurs.

  • minimized playbook to reproduce the error
---
- name: Sample
  hosts: all
  tasks:
    - name: Generate keypair
      community.crypto.openssh_keypair:
        path: "{{ env.path }}"
      when: ( env.path is not none )
  • the output of running ansible-lint including the command line used
ansible-lint --profile basic --write=all playbooks/5_setup_bastion.yaml
INFO     Identified /var/tmp/work/Ansible-OpenShift-Provisioning as project root due config file /var/tmp/work/Ansible-OpenShift-Provisioning/.ansible-lint.
INFO     Set ANSIBLE_LIBRARY=/home/ttakamiy/.cache/ansible-compat/184aba/modules:/home/ttakamiy/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/ttakamiy/.cache/ansible-compat/184aba/collections:/home/ttakamiy/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/ttakamiy/.cache/ansible-compat/184aba/roles:roles:/var/tmp/work/Ansible-OpenShift-Provisioning/roles
INFO     Set ANSIBLE_LIBRARY=/home/ttakamiy/.cache/ansible-compat/184aba/modules:/home/ttakamiy/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/ttakamiy/.cache/ansible-compat/184aba/collections:/home/ttakamiy/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/ttakamiy/.cache/ansible-compat/184aba/roles:roles:/var/tmp/work/Ansible-OpenShift-Provisioning/roles
INFO     Executing syntax check on playbook playbooks/5_setup_bastion.yaml (0.41s)
Traceback (most recent call last):
  File "/var/tmp/work/venv/bin/ansible-lint", line 8, in <module>
    sys.exit(_run_cli_entrypoint())
             ^^^^^^^^^^^^^^^^^^^^^
  File "/var/tmp/work/venv/lib64/python3.11/site-packages/ansiblelint/__main__.py", line 317, in _run_cli_entrypoint
    sys.exit(main(sys.argv))
             ^^^^^^^^^^^^^^
  File "/var/tmp/work/venv/lib64/python3.11/site-packages/ansiblelint/__main__.py", line 281, in main
    _do_transform(result, options)
  File "/var/tmp/work/venv/lib64/python3.11/site-packages/ansiblelint/__main__.py", line 192, in _do_transform
    transformer.run()
  File "/var/tmp/work/venv/lib64/python3.11/site-packages/ansiblelint/transformer.py", line 110, in run
    self._do_transforms(file, ruamel_data or data, file_is_yaml, matches)
  File "/var/tmp/work/venv/lib64/python3.11/site-packages/ansiblelint/transformer.py", line 147, in _do_transforms
    match.rule.transform(match, file, data)
  File "/var/tmp/work/venv/lib64/python3.11/site-packages/ansiblelint/rules/jinja.py", line 422, in transform
    self._transform_spacing(match, data)
  File "/var/tmp/work/venv/lib64/python3.11/site-packages/ansiblelint/rules/jinja.py", line 461, in _transform_spacing
    obj[path[-1]][key] = match.transform_meta.fixed
        ~~~~^^^^
IndexError: list index out of range
  • if you're getting a stack trace, also the output of
    ansible-playbook --syntax-check playbook
ansible-playbook --syntax-check playbooks/5_setup_bastion.yaml
[WARNING]: Unable to parse /var/tmp/work/Ansible-OpenShift-Provisioning/inventories/default as an inventory
source
[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'
[WARNING]: Could not match supplied host pattern, ignoring: jumphost
[WARNING]: Could not match supplied host pattern, ignoring: bastion
[WARNING]: Could not match supplied host pattern, ignoring: kvm_host

playbook: playbooks/5_setup_bastion.yaml
@TamiTakamiya TamiTakamiya added bug new Triage required labels Sep 16, 2023
@TamiTakamiya
Copy link
Author

TamiTakamiya commented Sep 16, 2023

@ganeshrn ganeshrn added AAP Ansible Automation Platform critical labels Sep 18, 2023
@ssbarnea ssbarnea self-assigned this Sep 18, 2023
@ssbarnea ssbarnea removed the new Triage required label Sep 18, 2023
ssbarnea added a commit that referenced this issue Sep 19, 2023
@TamiTakamiya
Copy link
Author

@ssbarnea Thank you for your quick fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AAP Ansible Automation Platform bug critical
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants