Sourcing a shell script for other states (installing nvm)

38 views
Skip to first unread message

Weydson Lima

unread,
Oct 4, 2017, 2:12:36 PM10/4/17
to Salt-users
Hi,

I'm looking for a way to properly install nvm (Node Version Manager, https://github.com/creationix/nvm) and have it available for other states. Installing nvm is trivial but requires to source a bash script to make the Node.js executable file available in the PATH. I have other states that require Node.js and currently the only way for these states to run successfully is to log out and back in into the shell session, therefore causing them to fail on the first runs.

I'm using a masterless configuration on Vagrant.

Thank you,
Weydson

Daniel Wallace

unread,
Oct 4, 2017, 3:27:15 PM10/4/17
to Salt-users
You will need to use `cmd.shell` or pass `python_shell: True` to the cmd module (this is always passed for the cmd.run state, so no need to do anything there)  But then you need to add the sourcing to the bashrc or /etc/profile for the user that is going to be running the nvm commands.

Alternatively you could set the options inside the salt environment using the setenv state, but otherwise, this feature request sounds like what you want.


And it doesn't exist yet.

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/3467a198-8651-47ac-9fea-1375aa42cb12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages