gpt4 book ai didi

node.js - 使用 nvm Ansible 安装 Node

转载 作者:行者123 更新时间:2023-12-02 04:50:42 25 4
gpt4 key购买 nike

我正在寻找一种通过ansible和nvm安装给定版本的 Node 的方法,nvm的安装按预期工作,因为如果我与root用户连接,我可以执行命令nvm install 8.11.3但是同样的命令不适用于 Ansible,我不明白为什么。

---
- name: Install nvm
git: repo=https://github.com/creationix/nvm.git dest=~/.nvm version=v0.33.11
tags: nvm

- name: Source nvm in ~/.{{ item }}
lineinfile: >
dest=~/.{{ item }}
line="source ~/.nvm/nvm.sh"
create=yes
tags: nvm
with_items:
- bashrc
- profile

- name: Install node and set version
become: yes
become_user: root
shell: nvm install 8.11.3
...

错误日志

TASK [node : Install node and set version] *************************************************************************************
fatal: [51.15.128.164]: FAILED! => {"changed": true, "cmd": "nvm install 8.11.3", "delta": "0:00:00.005883", "end": "2018-12-03 15:05:10.394433", "msg": "non-zero return code", "rc": 127, "start": "2018-12-03 15:05:10.388550", "stderr": "/bin/sh: 1: nvm: not found", "stderr_lines": ["/bin/sh: 1: nvm: not found"], "stdout": "", "stdout_lines": []}
to retry, use: --limit .../.../ansible/stater-debian/playbook.retry

最佳答案

没关系,这是有效的配置

- name: Install node and set version
become: yes
become_user: root
shell: "source /root/.nvm/nvm.sh && nvm install 8.11.3"
args:
executable: /bin/bash

关于node.js - 使用 nvm Ansible 安装 Node ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53596477/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com