Getting Started with a Chef Community Cookbook for NVM

  • So I am trying to use a Chef Community Cookbook for deploying NVM, which in turn deploys Node.js on Linux.

    This is the NVM Cookbook that I am trying to use.

    I've added it to the code repo but this is my first time working with a community cookbook and I am not sure where to go from here. Clearly I need to modify it to tell it what to do but I am not sure what the pattern is for what I want it to do. Has anyone worked with this or one like it before?

  • The Readme says "For more usage examples, have a look to the recipes in test/cookbooks/nvm_test/recipes/" but no such directory exists.

  • And the verdict was that I was able to get it to "work" but it had deep dependencies that I did not want to be introducing for this one, very simple small task. So I had to step away from the "Chef" was to do it, and instead went with a completely custom Chef cookbook and recipe that just use a script resource to run a BASH few liner that downloads and processes NVM directly, the sources it and installs the Node.js verion(s) that I want.

    It might look krufty but it is super simple to use and to understand and to support long term and while it doesn't have any checks in it, the actual result retains idempotence.

  • This is the scripting guide that I worked from:

  • Really quite simple since NVM is so simple itself. Just used the standard curl + bash command to run the NVM install of the version of my choice (handling updates will have to come in a later version.) I use the install directory relocation option and that puts NVM into /usr/local/nvm rather than into the user's own folder. Then just source the newly installed file and run the NVM Node.js install command as usual. Voila.