我是新來的ansible,我試圖從一個目錄到一個遠程RH機器上的另一個目錄使用ansible。Ansible劇本複製失敗 - msg:無法找到src
---
- hosts: all
user: root
sudo: yes
tasks:
- name: touch
file: path=/home/user/test1.txt state=touch
- name: file
file: path=/home/user/test1.txt mode=777
- name: copy
copy: src=/home/user/test1.txt dest=/home/user/Desktop/test1.txt
但它會引發如下錯誤
[[email protected] ansible]# ansible-playbook a.yml -i hosts
SSH password:
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
ok: [auto-0000000190]
TASK: [touch] *****************************************************************
changed: [auto-0000000190]
TASK: [file] ******************************************************************
ok: [auto-0000000190]
TASK: [copy] ******************************************************************
failed: [auto-0000000190] => {"failed": true}
msg: could not find src=/home/user/test1.txt
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/root/a.retry
auto-0000000190 : ok=3 changed=1 unreachable=0 failed=1
[[email protected] ansible]#
該文件已在目錄中創建和這兩個文件和目錄已得到許可777
我收到同樣的錯誤信息如果我嘗試使用ansible來複制已經存在的文件。
我試過非root用戶,但沒有成功。
非常感謝提前,
天使
剛纔我讀到「複製模塊複製本地框上的文件到遠程位置」。我期待它會將文件從一個位置複製到遠程機器上的另一個位置。複製命令在本地機器中查找文件,在我的情況下它不在那裏。因此,我所看到的錯誤信息是明智的。 – Angel