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
Use installed node version #7
Conversation
Dan, Wanted to call your attention to this part of the documentation which I had updated a few weeks ago.
This is what the |
Sure, but I would argue that without the
"nodejs_version" seems like it's intended to be the canonical version of node you want the server to be using, not just a version you want to be also installed. In fact, that's what happens the first time you run the role, it works as expected. But if "nodejs_version" doesn't also set the default to that version, it's effectively useless for the most-common use case I can think of (upgrading to a new version using NVM). It's also useless for the second most-common use case I can think of (maintaining multiple versions). What, then is definition and use of this parameter? Maybe it makes sense to have "nodejs_version" be the version that is installed and set as default, and offer a second optional parameter for "installed_nodejs_versions" for a list of versions you want installed but not necessarily set to default? Let me know if any of that makes sense/is appealing and I can modify the PR, or if I'm completely off-base about how that param is intended to be used. |
The goal of this role was designed for installation of NVM and configuration while also leveraging the NVM interface to set up/run a project. The end result of that goal was that I never thought of installing multiple versions of Node in one go. I view this role as a scalpel rather than a hammer. So iterating over a list of Node versions to install, while possible, is not a use case I would use. Regardless, the role allows for you to do this by including the role multiple times as shown in the More Complex example. Also, I had never really thought about setting the version you install as default. If you look at the More Complex example for instance:
this is where you could technically use
However, I believe (please correct me if I'm wrong), the default functionality for To sum it up, perhaps what you are suggesting is that there should be a new role variable that is something like:
The added benefit is that if there are other versions on the machine that you want to leverage, you could then take advantage of the |
Hm, so I was running under the impression that At any rate, I do like your suggestion about adding a |
While I don't know anything about your infrastructure, if the OS includes NodeJS as part of their base install, or Node was added via their Package Management feature, that will always be the default version of Node. Because at this level, Node is part of the OS infrastructure. NVM can short circuit this functionality because of the addition to the .bashrc file which loads and overwrites/supplements Node paths to the environment when the user logs in (meaning it's user specific).
Because NVM is inherently stateless, coming back as the user who installed NVM in a later playbook or even a later play, means you sort of start over right? It's the reason I pointed out In any case, if you don't explicitly set Having just reread the NMV documentation it does state: the
|
That absolutely explains what I'm seeing, and I definitely should have understood it sooner, I feel. It makes total sense. There's no rush to update that package, as I have a workaround in my ansible script in place, but I do appreciate the conversation and the update. |
Currently, when installing a new version of node on a system that has had an existing version installed already,
nvm use
is not issued, which leads to the old version continuing to be used, even though the desired version is installed.