-
Notifications
You must be signed in to change notification settings - Fork 669
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
Determine if passed arguments are playbooks or not #2912
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssbarnea
added
enhancement
feedback-needed
Divergent oppinions, additional feedback is desired in order to unblock it.
and removed
bug
labels
Jan 18, 2023
Should we do detection similar to the extension? https://github.com/ansible/vscode-ansible#without-file-inspection as a backup to a playbook that isn't valid but is intended to be a playbook? |
It looks sane, but I'm having trouble testing it, see #2909 |
ssbarnea
force-pushed
the
fix/rulebook
branch
from
January 19, 2023 12:56
d1d174a
to
d4f6003
Compare
LGTM, but I didnt run the automated tests (https://github.com/ansible/ansible-lint/actions/runs/3958630702) vagrant@ubuntu-jammy:~/ansible-lint$ pip3 install -U .
Defaulting to user installation because normal site-packages is not writeable
Processing /home/vagrant/ansible-lint
[...]
Successfully installed ansible-lint-6.11.1.dev4
vagrant@ubuntu-jammy:~/ansible-lint$ cd ..
vagrant@ubuntu-jammy:~$ git clone https://github.com/konstruktoid/ansible-event-otx
[...]
vagrant@ubuntu-jammy:~$ cd ansible-event-otx/
vagrant@ubuntu-jammy:~/ansible-event-otx$ ansible-lint .
WARNING Passed '.github/FUNDING.yml' positional argument was identified as generic 'yaml' file kind.
WARNING Passed '.github/workflows/codeql.yml' positional argument was identified as generic 'yaml' file kind.
WARNING Passed '.github/workflows/issues.yml' positional argument was identified as generic 'yaml' file kind.
WARNING Passed '.github/workflows/slsa.yml' positional argument was identified as generic 'yaml' file kind.
Passed with production profile: 0 failure(s), 0 warning(s) on 1 files.
You are using a pre-release version of ansible-lint.
vagrant@ubuntu-jammy:~/ansible-event-otx$ ansible-lint otx.yml
Passed with production profile: 0 failure(s), 0 warning(s) on 1 files.
You are using a pre-release version of ansible-lint.
vagrant@ubuntu-jammy:~/ansible-event-otx$ ansible-lint ../ansible-lint/playbook.yml
Passed with production profile: 0 failure(s), 0 warning(s) on 0 files.
You are using a pre-release version of ansible-lint.
vagrant@ubuntu-jammy:~/ansible-event-otx$ ansible-lint ../ansible-lint/examples/broken/yaml-with-tabs/invalid-due-tabs.yaml
Failed to load YAML file
vagrant@ubuntu-jammy:~/ansible-event-otx$ ansible-lint ../ansible-lint/examples/playbooks/rule-no-tabs.yml
Passed with production profile: 0 failure(s), 0 warning(s) on 0 files.
You are using a pre-release version of ansible-lint.
vagrant@ubuntu-jammy:~/ansible-event-otx$ ansible-lint -v otx.yml
INFO Set ANSIBLE_LIBRARY=/home/vagrant/.cache/ansible-compat/ad5374/modules:/home/vagrant/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO Set ANSIBLE_COLLECTIONS_PATH=/home/vagrant/.cache/ansible-compat/ad5374/collections:/home/vagrant/.ansible/collections:/usr/share/ansible/collections
INFO Set ANSIBLE_ROLES_PATH=/home/vagrant/.cache/ansible-compat/ad5374/roles:/home/vagrant/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
Passed with production profile: 0 failure(s), 0 warning(s) on 1 files.
You are using a pre-release version of ansible-lint.
vagrant@ubuntu-jammy:~/ansible-event-otx$ ansible-lint -v otx_ufw.yml
INFO Set ANSIBLE_LIBRARY=/home/vagrant/.cache/ansible-compat/ad5374/modules:/home/vagrant/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO Set ANSIBLE_COLLECTIONS_PATH=/home/vagrant/.cache/ansible-compat/ad5374/collections:/home/vagrant/.ansible/collections:/usr/share/ansible/collections
INFO Set ANSIBLE_ROLES_PATH=/home/vagrant/.cache/ansible-compat/ad5374/roles:/home/vagrant/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO Executing syntax check on otx_ufw.yml (0.62s)
WARNING Listing 1 violation(s) that are fatal
syntax-check[specific]: couldn't resolve module/action 'community.general.ufw'. This often indicates a misspelling, missing collection, or incorrect module path.
otx_ufw.yml:5:7
You can skip specific rules or tags by adding them to your configuration file:
# .config/ansible-lint.yml
warn_list: # or 'skip_list' to silence them completely
- syntax-check[specific] # Ansible syntax check failed.
Rule Violation Summary
count tag profile rule associated tags
1 syntax-check[specific] min core
Failed after : 1 failure(s), 0 warning(s) on 1 files.
You are using a pre-release version of ansible-lint.
vagrant@ubuntu-jammy:~/ansible-event-otx$ ansible-lint ../ansible-lint/examples/rulebooks/rulebook.yml
Passed with production profile: 0 failure(s), 0 warning(s) on 0 files. Fails on: ~/ansible-lint$ ansible-lint examples/playbooks/rulebook.yml
WARNING Listing 1 violation(s) that are fatal
syntax-check[specific]: 'sources' is not a valid attribute for a Play
examples/playbooks/rulebook.yml:4:3
You can skip specific rules or tags by adding them to your configuration file:
# .config/ansible-lint.yml
warn_list: # or 'skip_list' to silence them completely
- syntax-check[specific] # Ansible syntax check failed.
Rule Violation Summary
count tag profile rule associated tags
1 syntax-check[specific] min core
Failed after : 1 failure(s), 0 warning(s) on 1 files. Passes on: $ ansible-lint examples/rulebooks/rulebook.yml
Passed with production profile: 0 failure(s), 0 warning(s) on 1 files. |
ssbarnea
force-pushed
the
fix/rulebook
branch
3 times, most recently
from
January 19, 2023 18:17
831ef53
to
eb2acce
Compare
ssbarnea
requested review from
a team,
audgirka,
priyamsahoo and
shatakshiiii
January 19, 2023 18:18
ssbarnea
removed
bug
feedback-needed
Divergent oppinions, additional feedback is desired in order to unblock it.
labels
Jan 19, 2023
ssbarnea
force-pushed
the
fix/rulebook
branch
from
January 19, 2023 18:26
eb2acce
to
29c61c2
Compare
From now on, ansible-lint will no longer assume that a passed argument must be a playbook. This addressed multiple bug reports where people were confused that the linter reported errors when they passed a taskfile as an argument. The downside is that an invalid playbook that is a valid YAML file might not raise an error and just report a warning and be treated as a generic yaml file. Fixes: #2892
ssbarnea
force-pushed
the
fix/rulebook
branch
from
January 19, 2023 18:29
29c61c2
to
84ee5a2
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
From now on, ansible-lint will no longer assume that a passed argument
must be a playbook. This addressed multiple bug reports where people
were confused that the linter reported errors when they passed a
taskfile as an argument.
The downside is that an invalid playbook that is a valid YAML file
might not raise an error and just report a warning and be treated as
a generic yaml file.
Fixes: #2892
Fixes: #2888