Skip to content

Make ansible-lint recognize inventory.yml files #1631

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

Merged
merged 1 commit into from
Jun 17, 2021
Merged

Make ansible-lint recognize inventory.yml files #1631

merged 1 commit into from
Jun 17, 2021

Conversation

ssbarnea
Copy link
Member

@ssbarnea ssbarnea commented Jun 16, 2021

This fixes a bug that was originally reported on vscode-ansible, where it was observed that inventory files reported problems. From now on we do assume inventory.yml named files are inventory files.

Fixes: ansible/vscode-ansible#126

This fixes a bug that was originally reported on vscode-ansible, where
it was observed that inventory files reported problems. From now
on we do assume inventory.yml named files are inventory files.

Fixes: ansible/vscode-ansible#126
@ssbarnea ssbarnea added the bug label Jun 16, 2021
@ssbarnea ssbarnea changed the title Make ansible-lint recognize inventory files Make ansible-lint recognize inventory.yml files Jun 16, 2021
@ssbarnea ssbarnea merged commit cfc91b9 into master Jun 17, 2021
@ssbarnea ssbarnea deleted the devel branch June 17, 2021 12:02
@tadeboro
Copy link
Contributor

This PR is just bad because it makes assumptions out of thin air. There are no naming rules for things like inventory and playbook files and this change is overfitted to one specific use case. Plus, if I now create inventory.yml playbook, that playbook does not get linted at all.

I would suggest that we revert this change and find another way of solving the original issue.

@ssbarnea
Copy link
Member Author

Let's see if we can find a way to address this issue without the downside you mentioned. The reality is that before that patch ansible-lint would give an error if given an inventory yaml file as argument.

If a file is at the root of the repository we are in a gray area, for example we treat requirements.yml as requirement files. What if you would create a playbook with that name? ;)

I did read the official docs about inventories again and i noted that I made a mistake, the examples given do mention an inventory/ folder. This means that I could fix it by only recognizing inventory files from within those folders.

While this approach will still give an error for the user that put the inventory at root of the repo, at least it will give him a different escape route than adding it to the exclude list.

I already considered reading ansible config in order to find inventory filename but that would not work well as people may have any number of inventory files.

What should ansible-lint do if called with an yaml file that is not a playbook? (not hosted under a playbooks/ folder).

ssbarnea added a commit that referenced this pull request Jun 18, 2021
Address regression introduced by #1631 where a playbook named
`inventory.yml `could wrongly be evaluated as an inventory file.

Related: #1631
ssbarnea added a commit that referenced this pull request Jun 18, 2021
Address regression introduced by #1631 where a playbook named
`inventory.yml `could wrongly be evaluated as an inventory file.

Related: #1631
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 this pull request may close these issues.

The top element in the inventory is highlighted with an error
2 participants