Ansible中的Git模块在tmp目录上获取权限被拒绝

先生

我正在尝试使用模块通过Ansible克隆远程存储库git这是任务配置:

- name: Clone repo
  git:
    repo: "{{ repository }}"
    dest: "/home/{{ username }}/abc"
    key_file: "{{ git_key_file }}"
  register: code_update

但不幸的是,它失败并显示以下错误:

fatal: [xyz]: FAILED! => {"changed": false, "cmd": "/usr/bin/git clone --origin origin '' /home/xyz/abc", "msg": "Cloning into '/home/xyz/abc'...\nfatal: cannot exec '/tmp/tmpm9mfdkci': Permission denied\nfatal: cannot exec '/tmp/tmpm9mfdkci': Permission denied\nfatal: unable to fork", "rc": 128, "stderr": "Cloning into '/home/xyz/abc'...\nfatal: cannot exec '/tmp/tmpm9mfdkci': Permission denied\nfatal: cannot exec '/tmp/tmpm9mfdkci': Permission denied\nfatal: unable to fork\n", "stderr_lines": ["Cloning into '/home/xyz/abc'...", "fatal: cannot exec '/tmp/tmpm9mfdkci': Permission denied", "fatal: cannot exec '/tmp/tmpm9mfdkci': Permission denied", "fatal: unable to fork"], "stdout": "", "stdout_lines": []}

值得一提的是,我可以直接在远程服务器上克隆存储库。我也尝试更改TMPTMPDIR使用environment设置,但未更改。

任何回应将不胜感激...

博士

/tmp在服务器上安装了选项,noexec因此ansible无法执行自己的临时脚本。推荐的解决方法是设置环境变量TMPDIR

 - name: Clone the git repo in a temporary directory
      environment:
        TMPDIR: "/home/{{ username }}/tmp"
      git:
        repo: "{{ repository }}"
        dest: "/home/{{ username }}/abc"
        key_file: "{{ git_key_file }}"

确保目录存在。

参见https://github.com/ansible/ansible/issues/30064,尤其是。https://github.com/ansible/ansible/issues/30064#issuecomment-487149251

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章