與NVM

2016-05-16 43 views
1

Ansible指揮艙我試圖執行使用Ansible此命令:與NVM

- name: install node v5.5.0 
    sudo: yes 
    shell: nvm ls-remote 
    environment: 
    http_proxy: http://17.99.193.229:3128 
    https_proxy: http://17.99.193.229:3128 

我試過外殼和命令。

當使用命令:我得到這個錯誤:

"[Errno 2] No such file or directory", "rc": 2" 

當使用shell:我得到這個錯誤:

"fatal: [gocdagent-dev-01.rno.apple.com]: FAILED! => {"changed": true, "cmd": "nvm ls-remote", "delta": "0:00:00.016365", "end": "2016-05-16 18:26:07.259729", "failed": true, "rc": 127, "start": "2016-05-16 18:26:07.243364", "stderr": "/bin/sh: nvm: command not found", "stdout": "", "stdout_lines": [], "warnings": []}" 

我可以在系統上nvm命令直接執行。爲什麼Ansible無法運行nvm

回答

1

因爲你在Ansible腳本中運行它爲root(sudo:是)。確保nvm位於根目錄的PATH中,或在shell命令中輸入/full/path/to/nvm

1

NVM不是二進制,你必須先加載:

- name: install node v5.5.0 
    shell: . <NVM_DIR>/.nvm/nvm.sh && nvm ls-remote 
    environment: 
    http_proxy: http://17.99.193.229:3128 
    https_proxy: http://17.99.193.229:3128