Closed kamaradclimber closed 9 years ago
@kamaradclimber If a role filename is different the the name contained in the role wouldn't this cause problems in terms of tracking what role is in source and which role is on the Chef server? I think this would cause confusion and is not the path of least surprise.
@stephenlauck chef does not use the role filename, knife-inspect should not add this additional constraint.
For instance we store related roles in subfolders which is their prefix. To avoid repetition filename is only the moving part:
roles:
elasticsearch:
dedicated_master.rb (role name is elasticsearch_dedicated_mater)
data_holder.rb (role name is elasticsearch_data_holder)
This goes against the source code being the source of truth if the role name on the server is different than the file name in source control. I also think in general @kamaradclimber is overloading roles and should think about moving things into separate Organizations on the Chef server instead of sub-dir the roles.
@stephenlauck We already support loading roles in subdirectories because some people do that (#18), as long as it doesn't make the code more complicated I'm fine with adding this feature.
My bad, I didn't read correctly. I don't think it makes sense to have files that have a different file name than the roles. You can use subfolders but I think the code should be simplified, not made more complicated.
So, Chef::Role.from_disk
cannot be used here anyway, it's trying to load files with a regexp (https://github.com/opscode/chef/blob/ee7f79f699beaf136d93970734a0ec552aabc11b/lib/chef/role.rb#L239-L240), so you'd get an error about duplication when you have a "load_balancer" and "other_load_balancer" roles.
@gregkare agreed that Chef::Role.from_disk
cannot be used because of the several limitations.
However, both chef in general and chef_fs (now part of chef) do not enforce any kind of rule on role file naming.
Otherwise having a name property in a role file would be redundant with the filename.
If you want, I can try to make the code less complicated and/or use more chef parts
@stephenlauck we are not doing any role overloading here. As I mentioned earlier, it is purely a matter a concision in file tree.
Closing this PR since I got no feedback for a few months. Feel free to reopen if you are interested in the exchange.
This patch mimic the Chef::Role.from_disk method which unable to read in subdir (how sad!)