-
Notifications
You must be signed in to change notification settings - Fork 37
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
"Inventory is broken" message when processing group_vars
files.
#21
Comments
You might need to turn on some extra verbose logging by running with What version of ansible are you using? We expect ansible-review to process inventory/group_vars. What is not clear is why it then decides to open ansible.log, as that seems nowhere near ansible. It might be that ansible's inventory processing is finding ansible.log, but as you're not experiencing this issue running Ansible itself, this shouldn't be happening with ansible-review Can you see if you can boil this down to a test case that you're able to share. At the moment there is nothing I can do about this as I simply don't understand why this is happening, and can't reproduce it to diagnose further. |
I tried running with
The I'll see if I can come up with a reduced test case. |
OK, so here's the reduced test case: https://github.com/dflock/ansible-review-testcase It looks like this:
Running this:
The current contents of the
if I change it to this:
Then the
I'm not actually using a virtualenv for this, but the
which are the versions that I have installed. |
Looking at this structure, I think it's because it expects group_vars to be in an inventory directory. Your ansible.cfg suggests that the inventory directory is elsewhere, so not quite sure what you're trying to do with the group_vars. I usually use an inventory directory and then have group_vars underneath. I haven't done much digging into what ansible.inventory.Inventory does in your case, but as I'm not sure what you're trying to achieve, it's difficult to know how best to fix finding group_vars in an unexpected (not necessarily wrong) location |
We're just using the Standard Ansible directory layout. I think you're talking about/expecting the Alternate Directory Layout? Our inventory file, at least for our dev env, is created by vagrant, and put into I haven't thought much about our directory layout since I set it up ~3yrs ago; I'll give the alternate layout some thought, because I'd like to split up our gigantic |
I'm not really talking about the alternate directory layout We just use a directory (in our case called inventory) that has a bunch of hosts files and host_vars and group_vars as children. Our ansible.cfg points to that inventory directory. However, I'm not trying to make you change how you use Ansible, more understand how you use it, I didn't even know group_vars could be under the root directory, even though it's perfectly well documented. The problem is here: https://github.com/willthames/ansible-review/blob/master/lib/ansiblereview/groupvars.py#L49-L50 It's impossible for that check to work if group_vars isn't within an inventory directory containing the host files (it can't check if two groups are competing if it doesn't know the group structure), so I'd just recommend removing the Patches accepted that fix the exception at the end of that test to give a more helpful error message |
If I let
ansible-review
process mygroup_vars
files, I get messages like this in the output:I'm running
ansible-review
like this:git ls-files ansible/. | xargs ansible-review
.Two things puzzle me about this:
ansible.log
- which is.gitignored
and thus not in the output fromgit ls-files ansible/.
- so I guessansible-review
isn't using that list as a list of files to process, but reading the filesystem itself? Is there a way to makeansible-review
ignore some files?group_vars
, or with the inventory, for that matter? Is it assumingansible.log
is my inventory file?If I exclude the
group_vars
folder, this problem goes away:git ls-files ansible/. | grep -v group_vars | xargs ansible-review
- which indicates that maybeansible-review
does use the list of files?The text was updated successfully, but these errors were encountered: