当运行ansible playbook(如 root
)运行 npm
命令从git存储库安装模块时,我得到 Permission denied
错误的dir /root/tmp/..
这是 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
Root不应该有权限被拒绝错误 .
什么想法可能是错的?
1 回答
您尝试在用户不是root用户时写入根文件夹
更改文件夹herE:
将其更改为
/tmp
而不是root/tmp