当运行运行npm
命令从git存储库安装模块的ansible playbook(作为root
(时,我得到目录/root/tmp/..
的Permission denied
错误
以下是npm
:的完整错误
11 verbose stack Error: exited with error code: 128
11 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/util/finished.js:12:19)
11 verbose stack at ChildProcess.emit (events.js:182:13)
11 verbose stack at maybeClose (internal/child_process.js:962:16)
11 verbose stack at Socket.stream.socket.on (internal/child_process.js:381:11)
11 verbose stack at Socket.emit (events.js:182:13)
11 verbose stack at Pipe._handle.close (net.js:606:12)
12 verbose cwd /root/tmp
13 verbose Linux 3.10.0-957.1.3.el7.x86_64
14 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "git+ssh://git@bitbucket.org/user/repo.git"
15 verbose node v10.14.1
16 verbose npm v6.4.1
17 error Error while executing:
17 error /bin/git ls-remote -h -t ssh://git@bitbucket.org/user/repo.git
17 error
17 error fatal: Cannot change to '/root/tmp/..': Permission denied
17 error
17 error exited with error code: 128
18 verbose exit [ 1, true ]
以下是Ansible的战术手册:
- name: top-name
hosts: myhost
tasks:
- name: task-name
become: true
environment:
PATH: /usr/local/bin:/bin:{{ ansible_env.PATH }}
command: npm i git+ssh://git@bitbucket.org/user/repo.git
args:
chdir: /root/tmp
register: out
根不应该有拒绝权限的错误
有什么想法吗?
当用户不是根时,您正试图写入根文件夹
17 error fatal: Cannot change to '/root/tmp/..': Permission denied
更改文件夹herE:
args:
chdir: /root/tmp
将其更改为/tmp
而不是root/tmp
最近我遇到了类似的问题。我了解到:
...
command: "npm install"
args:
chdir: "/mydir"
这个:
...
command: "npm install /mydir"
不一样。第一个抛出"拒绝访问"消息,第二个有效。我不明白为什么,但我希望它能有所帮助。