morgangraphics / ansible-role-nvm

Installs NVM & Node.js on Debian/Ubuntu and RHEL/CentOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Check NVM Version: "bash: nvm: command not found"

swoodford opened this issue · comments

Hi,
I'm trying this role for the first time on an AWS EC2 instance, Amazon Linux AMI 2018.03.0.20180811 x86_64 HVM GP2 and running into this error while executing the playbook through a Jenkins job, using the latest build of Jenkins (ver. 2.150). Any suggestions would be appreciated, thanks!

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [ec2-foo-bar.compute-1.amazonaws.com]

TASK [include_role] ************************************************************

TASK [../roles/ansible-role-nvm : Check if wget or curl is installed] **********
changed: [ec2-foo-bar.compute-1.amazonaws.com]

TASK [../roles/ansible-role-nvm : Determine if install type wget] **************
ok: [ec2-foo-bar.compute-1.amazonaws.com]

TASK [../roles/ansible-role-nvm : Determine if install type curl] **************
skipping: [ec2-foo-bar.compute-1.amazonaws.com]

TASK [../roles/ansible-role-nvm : Install NVM] *********************************
 [WARNING]: Consider using the get_url or uri module rather than running wget.
If you need to use command because get_url or uri is insufficient you can add
warn=False to this command task or set command_warnings=False in ansible.cfg to
get rid of this message.
changed: [ec2-foo-bar.compute-1.amazonaws.com]

TASK [../roles/ansible-role-nvm : Check if git is installed] *******************
skipping: [ec2-foo-bar.compute-1.amazonaws.com]

TASK [../roles/ansible-role-nvm : Remove NVM to nvm_profile] *******************
skipping: [ec2-foo-bar.compute-1.amazonaws.com]

TASK [../roles/ansible-role-nvm : Install via git] *****************************
skipping: [ec2-foo-bar.compute-1.amazonaws.com]

TASK [../roles/ansible-role-nvm : Add NVM to nvm_profile] **********************
skipping: [ec2-foo-bar.compute-1.amazonaws.com]

TASK [../roles/ansible-role-nvm : Check NVM Version] ***************************
fatal: [ec2-foo-bar.compute-1.amazonaws.com]: FAILED! => {"changed": true, "cmd": "bash -ic \"nvm --version\"", "delta": "0:00:00.012111", "end": "2018-11-05 22:45:00.754177", "msg": "non-zero return code", "rc": 127, "start": "2018-11-05 22:45:00.742066", "stderr": "bash: no job control in this shell\nbash: nvm: command not found", "stderr_lines": ["bash: no job control in this shell", "bash: nvm: command not found"], "stdout": "", "stdout_lines": []}

PLAY RECAP *********************************************************************
ec2-foo-bar.compute-1.amazonaws.com : ok=7    changed=2    unreachable=0    failed=1   

FATAL: command execution failed
hudson.AbortException: Ansible playbook execution failed
	at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(AnsiblePlaybookBuilder.java:262)
	at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(AnsiblePlaybookBuilder.java:232)
	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
	at hudson.model.Build$BuildExecution.build(Build.java:206)
	at hudson.model.Build$BuildExecution.doRun(Build.java:163)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
	at hudson.model.Run.execute(Run.java:1810)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)
$ ssh-agent -k
unset SSH_AUTH_SOCK;
unset SSH_AGENT_PID;
echo Agent pid 31494 killed;
[ssh-agent] Stopped.
ERROR: Ansible playbook execution failed
Finished: FAILURE

My playbook looked like this:

  tasks:

    - include_role:
         name: ../roles/ansible-role-nvm
      vars:
        nodejs_version: "LTS"

Once I removed the vars: nodejs_version: "LTS" it seems to have worked.

Thanks for pointing this out. I'll take a look.

This might be an issue with the documentation telling you to use LTS when it should be lts. In any event the nodejs_version variable defaults to lts.

If you could try using the lowercase version and confirm that works, I'll update the documentation accordingly

Updated the documentation to reflect defaults.

Hello I am encountering this problem on an Ubuntu 18.04 machine. Setting or unsetting the nodejs_version does not seem to have an effect.

Ansible Version:
fotis➜ ansible : development ✘ :✖✹✭ ᐅ ansible --version ansible 2.8.3 executable location = /usr/local/bin/ansible python version = 3.7.4 (default, Jul 9 2019, 18:13:23) [Clang 10.0.1 (clang-1001.0.46.4)]

This is the output.
TASK [ansible-role-nvm : Check NVM Version] ************************************ fatal: [default]: FAILED! => {"changed": true, "cmd": "bash -ic \"nvm --version\"", "delta": "0:00:00.088530", "end": "2020-01-11 13:08:13.807246", "msg": "non-zero return code", "rc": 127, "start": "2020-01-11 13:08:13.718716", "stderr": "\nCommand 'nvm' not found, did you mean:\n\n command 'gvm' from snap gvm (1.1.0)\n command 'nsm' from snap nift (2.0.1)\n command 'npm' from deb npm\n command 'nvme' from deb nvme-cli\n command 'nm' from deb binutils\n command 'nim' from deb nim\n command 'nam' from deb nam\n command 'kvm' from deb qemu-kvm\n command 'nvim' from deb neovim\n command 'lvm' from deb lvm2\n command 'num' from deb quickcal\n command 'pvm' from deb pvm\n command 'vm' from deb mgetty-voice\n command 'nvi' from deb nvi\n\nSee 'snap info <snapname>' for additional versions.", "stderr_lines": ["", "Command 'nvm' not found, did you mean:", "", " command 'gvm' from snap gvm (1.1.0)", " command 'nsm' from snap nift (2.0.1)", " command 'npm' from deb npm", " command 'nvme' from deb nvme-cli", " command 'nm' from deb binutils", " command 'nim' from deb nim", " command 'nam' from deb nam", " command 'kvm' from deb qemu-kvm", " command 'nvim' from deb neovim", " command 'lvm' from deb lvm2", " command 'num' from deb quickcal", " command 'pvm' from deb pvm", " command 'vm' from deb mgetty-voice", " command 'nvi' from deb nvi", "", "See 'snap info <snapname>' for additional versions."], "stdout": "", "stdout_lines": []}

Fill out a new issue.