[英]Setting up symlink error - Ansible
我想設置一個從源到目的地的符號鏈接,但一直打
致命:[默認]:失敗! => {“已更改”:false,“failed”:true,“msg”:“鏈接時出錯:[Errno 2]沒有這樣的文件或目錄”,“path”:“/ Applications / Xcode.app / Constate / Develox /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“,”州“:”缺席“}
觀察到它顯示狀態缺席,即使狀態是作為鏈接給出的。
這是執行的任務:
- 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問題
任何幫助表示贊賞!
我不確定丟失的目錄是否是導致此問題的原因,但在創建指向該目錄的鏈接之前,確保目標目錄存在是一種很好的做法:
- name: Ensure that the directory exist
file:
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"
state: directory
mode: 0755
owner: root
group: wheel
- name: "Create ruby config.h symlink"
file:
...
我的回答可能無法解決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
結果出現以下錯誤。
致命:[默認]:失敗! => {“已更改”:false,“failed”:true,“msg”:“鏈接時出錯:[Errno 2]沒有此類文件或目錄”,“path”:“...”,“state”:“缺席”}
刪除/
如下所示,可以解決此問題。
- name: Establish link to foobar
file:
src: '/tmp/foobar/'
dest: '/local/baz'
state: link
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.