-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
enhancement: ansible-lint - Improved activation by checking for .ansible-lint
config file
#3697
Conversation
The reasoning seems good, but I still don't understand completely what are the implications, as ansible is not an ecosystem I understand well. I will try to reread all the issues again later or in a couple days. Maybe @nvuillam knows better? |
I hope you don't mind me reaching out to you directly. Given your expertise with Ansible, I wanted to see if I could get your thoughts on this PR I've been working on. Would you be willing to take a look and share any input? Thank you for your time, |
Looks good to me but let's wait for a real expert's opinion: @alexanderbazhenoff :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok to me :)
Hi @TommyE123 @nvuillam Sorry for late reply. Overall the tests look good. |
ansible-lint - Improved activation by checking for
.ansible-lint
config fileFixes #1252 and #2132 and #3424 (all 3 already closed)
Context:
While testing a previous issue for ansible-lint I noticed that even using
ANSIBLE_DIRECTORY: .
I couldn’t get it to activate properly onGitlab
orAzure
Looking at the suggested directory layout I don’t think it makes sense to use the
files_sub_directory: ansible
as a default as this folder isn’t mentioned. All this appears to be currently doing is acting as a method to keep ansible-lint switched off unless the.mega-linter.yml
is adjusted as a workaround to activate.I’ve avoid checking for the Rules folder as currently there wasn’t a method in megalinter I could see to easily check for this folder. Also setting it to a sub directory could mean false detections and possibly only scanning that one folder. I’m open to suggestions if this sounds like an issue.
Reading others comments I personally think a better approach would be to harness the existing megalinter functionality to check if a file is present. In this case the
.ansible-lint
.Changes:
• Removed unrequired default
files_sub_directory: ansible
property inansible.megalinter-descriptor.yml
• Added:
active_only_if_file_found:
- ".ansible-lint"
• Added a default
.ansible-lint
file in templates.• Simplified the tests.
Testing:
I've done a mixture of tests through different pipelines.
AZURE
Scenario 1: – Not Activated
No .ansible-lint File
Scenario 2: – Activated
Root .ansible-lint
Scenario 3: – Activated
LINTER_RULES_PATH: "/_Pipelines/LinterRules"
GITHUB
Scenario 1: – Activated
ANSIBLE_ANSIBLE_LINT_RULES_PATH: config
GITLAB
Scenario 1: – Not Activated
No .ansible-lint File
Scenario 2: – Activated
Root .ansible-lint
Scenario 3: – Activated
ANSIBLE_ANSIBLE_LINT_RULES_PATH: "/_Pipelines/LinterRules"
Scenario 4: – Activated (note missing . at front of filename)
ANSIBLE_ANSIBLE_LINT_RULES_PATH: "/_Pipelines/LinterRules"
ANSIBLE_ANSIBLE_LINT_CONFIG_FILE: ansible-lint
Scenario 5: – Activated
ANSIBLE_ANSIBLE_LINT_RULES_PATH: config
ANSIBLE_ANSIBLE_LINT_CONFIG_FILE: ansible-lint
I'm happy to do more test scenarios on request!
If there are any issues or concerns, please let me know, and I will address them promptly.
Thank you for reviewing this PR and I look forward to your feedback.
Tom