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

skip_list syntax-check is ignored #1594

Closed
roosterfish opened this issue Jun 1, 2021 · 3 comments · Fixed by #1606
Closed

skip_list syntax-check is ignored #1594

roosterfish opened this issue Jun 1, 2021 · 3 comments · Fixed by #1606
Labels

Comments

@roosterfish
Copy link

Summary

When trying to disable the syntax-check with skip_list: in the config file, the linter is completely ignoring it. Adding syntax-check to warn_list: works like expected.

Issue Type
  • Bug Report
Ansible and Ansible Lint details
# ansible --version
ansible 2.9.20

# ansible-lint --version
ansible-lint 5.0.11 using ansible 2.9.20
  • ansible installation method: pip
  • ansible-lint installation method: pip
OS / ENVIRONMENT

Ubuntu 20

STEPS TO REPRODUCE

Create a config file under ~/.ansible-lint.yml

skip_list:
  - syntax-check
kinds:
  - playbook: "**/*.yml"

Create a playbook that leads to an error during ansible-playbook --syntax-check playbook.yml:

- name: Play name
  hosts: "{{ some_unset_variable }}"

Run ansible-lint -c ~/.ansible-lint.yml playbook.yml

Desired Behaviour

The linter should skip the syntax-check.

Actual Behaviour
INFO     Added ANSIBLE_ROLES_PATH=~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:roles:roles
INFO     Executing syntax check on playbook.yml (1.85s)
WARNING  Listing 1 violation(s) that are fatal
syntax-check: The field 'hosts' has an invalid value, which includes an undefined variable. The error was: 'some_unset_variable' is undefined
playbook.yml:1:3 [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! The field 'hosts' has an invalid value, which includes an undefined variable. The error was: 'some_unset_variable' is undefined

The error appears to be in '/.../playbook.yml': line 1, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Play name
  ^ here


You can skip specific rules or tags by adding them to your configuration file:
# .ansible-lint
warn_list:  # or 'skip_list' to silence them completely
  - syntax-check  # Ansible syntax check failed

Finished with 1 failure(s), 0 warning(s) on 1 files.
@roosterfish roosterfish added the bug label Jun 1, 2021
@ssbarnea
Copy link
Member

ssbarnea commented Jun 2, 2021

This is exactly a bug, syntax-check cannot be skipped but I will keep it open as the message gives is misleading users to believe they can skip this one. You can only exclude files but their syntax must be valid, that comes from ansible itself.

@roosterfish
Copy link
Author

@ssbarnea thanks for the clarification.

Found this whilst having the inventory information separated from the code. Might it be possible to add an option like -i (--inventory) also to ansible-lint? This way you can be sure ansible-playbook --syntax-check --inventory [pass in the information here] can find your inventory.

@ssbarnea
Copy link
Member

ssbarnea commented Jun 2, 2021

There is no need to pass extra args as you can use ANSIBLE_INVENTORY or specify inventory file in ansible.cfg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants