-
Notifications
You must be signed in to change notification settings - Fork 94
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
reclass can't file node definition, if it defined in subdirectory #10
Comments
Thank you for taking your time to file this issue! Subdirectories are currently not implemented, and I am hesitant to implement them because I have not worked out the namespacing issues. For instance, what should happen when This would be a nice way to implement node groups (see pull request #9), but first the namespacing should be worked out, and we need to figure out if subdirectories are the best approach for this. I think that there would be a benefit for implementing this for classes, though, e.g.: |
In case of my pull request reclass simply throws exception. I think that namespace has not sense at all. |
I mean, for nodes. For classes namespaces are ok, because they can naturally implement environments for salt. |
So how about we implement this for classes, but not for nodes? |
I can fix my pull request, and it will support namespaces for classes and uniqueness for nodes. My idea is that: classes are immutable, they don't know about nodes at all. They can be part of salt states for examples. And nodes inventory - it is a dynamic thing, and directories needed here to arrange nodes for large installations (I have a couple of clusters with more then 2k nodes as total) and place all nodes definitions in one directory - bad idea. |
I suggest we keep the two issues separate: namespaces/subdirectories, and node groups. Ideally, there would be two pull requests too, if this isn't asking too much. With modern filesystems, you can have thousands of files in a directory and that works just fine thanks to B-Trees. Or is the issue more from a human side? |
We can split issues, it is ok. But they somehow depends on each other. Concerning filesystems there a couple of issues:
|
Yes, they depend on each other, which is why I am trying to get small, logical changes implemented one after another. About your issues:
|
One more thought, why you want to hardcode meaning for directories for nodes? May be it can be more flexible to allow admins place node in any order they want. Moreover, we can allow to create _dir.yaml (for example) definitions, which a merged from top to down into node definition. In that case admin can do whatever he wants, for example assign classes for its own physical structure of network. |
Please have a look at the This should already do almost everything you want, except it cannot enumerate nodes, obviously. Put into your config file:
and then call e.g. This does not hardcode the meaning of directories. But directories have a special meaning anyway for nodes, as a node can only be defined in one subdirectory, so essentially, the directory name is just a prefix to the node name, not a hierarchical element (like it could be for classes). Once we implement subdirectory scanning for nodes and classes, then you can create node files as well to assist in enumeration, and I will also think more about other means to enumerate, including your suggested group files. Your example I am willing to entertain ideas about making |
Thank you for clarification. I've understood your point. Idea with dc/queue/rack can be dropped, I agree. That is over engineering, okay. Right now I stick with my solution in my branch, it fits me well and allows to extend further (I think about validations and aggregators). Thank you. |
The current master branch now implements reading nodes from subdirectories using yaml_fs. |
Use isinstance() insted of type()
In case of node definition resides in subdirectory within nodes, reclass fails, can't find node definition file.
%%
$ mkdir examples/nodes/subdir
$ cp examples/nodes/localhost.yml examples/nodes/subdir/n1.yml
$ ./reclass.py -b examples -i
No such file: reclass/examples/nodes/n1.yml
$ ./reclass.py -b examples -n localhost
... correct output
$ ./reclass.py -b examples -n n1
No such file: reclass/examples/nodes/n1.yml
The text was updated successfully, but these errors were encountered: