0

When I run this command from inside a cookbook's directory on my Chef workstation I get an error:

knife list roles/
ERROR: roles: No such file or directory

I need to cd back up to the root of the chef directory and run the command for it to work.

Is there way to configure a roles path with knife the same way I have a cookbook directory so no matter where I am I can run that command?

red888
  • 27,709
  • 55
  • 204
  • 392
  • 1
    `knife role list`? – StephenKing Aug 30 '16 at 14:43
  • yes that works. so I guest the difference here is that I'm in the role context with this command as apposed to knife list which just lists all objects? – red888 Aug 30 '16 at 14:53
  • Ah okay, actually didn't ever use that. But it works inside your chef-repo dir, does it? In contrast to [`solo.rb`](https://docs.chef.io/config_rb_solo.html), the docs for [`knife.rb`](https://docs.chef.io/config_rb_knife.html) don't list a `roles_path` config option. – StephenKing Aug 30 '16 at 15:02

1 Answers1

1

The command you give is one of the "Chef FS" commands, so no you can't really customize it. Things like the *_path (except chef_repo_path) options don't apply to ChefFS.

coderanger
  • 52,400
  • 4
  • 52
  • 75
  • So `knife list...` is a Chef FS command but `knife role` is not? Is there definitive doc on Chef FS and what the heck it is? If I google I can find the class definition, some errors people posted and thats about it. Have the Chef FS commands been deprecated? – red888 Aug 30 '16 at 19:10
  • No, there are only sparse docs. The ChefFS commands are newer and generally better to use, but they are limited in some ways in that they require standard file system layout. – coderanger Aug 30 '16 at 19:28
  • OK, just making sure I'm getting this, the fist command I tried was Chef FS and the second one that "worked" was not right? – red888 Aug 30 '16 at 19:38
  • Correct, the `knife list` command is generally better since it's a unified interface to all data, rather than individual subcommands for each Chef data type, sometimes with mismatching options et al. But the downside is it is sensitive to both cwd and directory layout. – coderanger Aug 30 '16 at 19:48