gpt4 book ai didi

ansible - 设置符号链接(symbolic link)错误 - Ansible

转载 作者:行者123 更新时间:2023-12-01 11:22:00 24 4
gpt4 key购买 nike

我正在尝试设置从源到目标的符号链接(symbolic link),但继续点击

fatal: [default]: FAILED! => {"changed": false, "failed": true, "msg": "Error while linking: [Errno 2] No such file or directory", "path": "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/config.h", "state": "absent"}



观察到显示 状态缺席即使状态是作为链接给出的。

这是执行的任务:
 - name: "Create ruby config.h symlink"
file:
src: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin15/ruby/config.h"
dest: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/config.h"
state: link
force: yes
when: xcode_version != "8.0"

文件已存在:
ls -l /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin15/ruby/config.h
-rw-r--r-- 2 root wheel 7805 Jan 31 2016 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin15/ruby/config.h

注意:根据此处的讨论,包括强制是 - Ansbible github issue

任何帮助表示赞赏!

最佳答案

我的回答可能无法解决 OP 问题,但它确实会导致这个问题,因此可能会解释另一个人遇到这个问题。我经常发现这样的错误可能是由尾随的 / 引起的。在链接名称中。

例如,创建如下目录的任务将成功。

- name: ensure foobar directory exists
file:
state: directory
path: '/tmp/foobar/'
owner: 'foo'
group: 'bar'
mode: 0777

但是,后续的链接创建任务,如果编写如下,将导致您遇到的错误。
- name: Establish link to foobar
file:
src: '/tmp/foobar/'
dest: '/local/baz/'
state: link

导致以下错误。

fatal: [default]: FAILED! => {"changed": false, "failed": true, "msg": "Error while linking: [Errno 2] No such file or directory", "path": "...", "state": "absent"}



删除 /按照下面,可以解决这个问题。
- name: Establish link to foobar
file:
src: '/tmp/foobar/'
dest: '/local/baz'
state: link

关于ansible - 设置符号链接(symbolic link)错误 - Ansible,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41231122/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com