我的 ansible 脚本中有一个命令可以替换文件中的一行。该命令在我的机器上运行时运行良好。然而,当它与我的 ansible 脚本一起运行时,它会显示
No such file or directory
。问题是,该文件确实存在,并且“sed”确实替换了该行。那么命令确实运行成功,但仍然给我一个错误?有谁知道这可能是什么原因造成的?
Ansible 任务
- name: Update path in plotly package
become: true
shell:
cmd:
sed -e '2s/.*/DIR="$( cd "$( \/usr\/bin\/dirname "${BASH_SOURCE[0]}" )" >\/dev\/null 2>\&1 \&\& pwd )"/' -i '' /plotly/app/venv/lib64/python3.9/site-packages/kaleido/executable/kaleido
错误
TASK [packages/plotly : Replace line in plotly package] ********************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": true, "cmd": "sed -e '2s/.*/DIR=\"$( cd \"$( \\/usr\\/bin\\/dirname \"${BASH_SOURCE[0]}\" )\" >\\/dev\\/null 2>\\&1 \\&\\& pwd )\"/' -i '' /plotly/app/venv/lib64/python3.9/site-packages/kaleido/executable/kaleido", "delta": "0:00:00.004789", "end": "2024-07-30 16:16:24.704142", "msg": "non-zero return code", "rc": 2, "start": "2024-07-30 16:16:24.699353", "stderr": "sed: can't read : No such file or directory", "stderr_lines": ["sed: can't read : No such file or directory"], "stdout": "", "stdout_lines": []}
也许您需要发送的完整路径?