tobami / littlechef

Cook with Chef without a Chef Server
Apache License 2.0
472 stars 71 forks source link

Adds options to run littlechef outside of kitchen, fixes library usage #252

Open iashwash opened 8 years ago

iashwash commented 8 years ago

Library usage was difficult since littlechef needed to be run within the kitchen working directory.

I added an option to specify the path to kitchen and to skip node data bag building. With this and assuming a repository with prebuilt berks path, littlechef can be invoked without knife being installed on the system.

I also updated the library usage example. It contained an old way to invoke the deploy_chef function, and I added a link to a more detailed working example of invoking littlechef (since you have to specify many env variables to get it to run).

Tested fix and library invocations manually. Added setting of the kitchen_path and current test suite passes. If you have advice for setting up additional test cases I would be much obliged.

tobami commented 8 years ago

This looks really great. Path to the kitchen was something has needed more robustness for a long time now.

As tests i would suggest one for each of the two new options --skip_node_data_bag, and --kitchen-path. You could test test_runner directly (as a library) instead of testing the fix command (which requires a subprocess and is slow).

tobami commented 8 years ago

Btw., your "Simple example of using littlechef as a library" gist denotes how involved it still is to use it. Did you really need to set so many options?

A more simpler option would be to set in code the kitchen path and have a littlechef.cfg there. Or reading configuration from a ~/.littlechef.cfg.

iashwash commented 8 years ago

Thanks for the feedback. I'll add the additional tests this week (I found another issue with the node files that I'll be pushing up a fix for now).

You make a good point about how involved the example is, and I didn't think about just dropping in the config even for just library usage. Let me play with that as well and see if I can get rid of the complicated gist.