Ansible 无法在目录之间创建符号链接,即使使用 force=true

问题描述 投票:0回答:0

我有一个非常简单的 Ansible 任务,它试图在两个目录之间创建一个符号链接。这些文件还不存在,所以现在我只是创建指向目标目录的符号链接。即使我使用

force: true
,它仍然失败。根据我对 Ansible 文档的理解,这应该在以下情况下使用:

Force the creation of the symlinks in two cases: the source file does not exist (but will appear later).

参考: Ansible 文件文档

当我尝试在具有绝对路径的测试服务器上创建符号链接时,它工作得很好,就像这样:

ln -s /src/mydir /mydir

我在 Ansible 中做同样的事情,像这样:

- name: Create symlink
  file:
    source: /src/mydir
    dest: /mydir
    state: link
    force: true

在我的剧本中,我也在使用

become:true
.

但是,在 Ansible 中,这失败了,因为 Ansible 似乎正在尝试创建临时目录和文件,并且失败并显示无法访问的错误消息:

UNREACHABLE! => {"changed": false, "msg": "Failed to create temporary directory.
In some cases, you may have been able to authenticate and did not have permissions on the target directory. 
Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\", for more error information use -vvv. 

Failed command was: 
( umask 77 && mkdir -p \"` echo /src/mydir/.ansible/tmp `\"&& mkdir \"` echo /src/mydir/.ansible/tmp/ansible-tmp `\" && echo ansible-tmp-\"` echo /src/mydir/.ansible/tmp/ansible-tmp `\" ), 
exited with result 1", "unreachable": true}

奇怪的是,到目前为止,剧本中的所有其他任务都成功运行。从输出中可以看出,此任务返回为无法访问:

default: ok=18   changed=15   unreachable=1    failed=0    skipped=7    rescued=0    ignored=0
ansible ansible-2.x configuration-management
© www.soinside.com 2019 - 2024. All rights reserved.