我正在使用可行的2.1將rsync或將文件從主機複製到遠程計算機。該文件位於目錄中,但其名稱中包含一個隨機字符串。我曾嘗試使用ls -d通過shell命令獲取名稱,並試圖註冊此值,但顯然,我正在使用的語法導致該角色失敗。有關我可能做錯什麼的想法?ansible rsync或將隨機命名的文件複製到遠程計算機
---
- name: copying file to server
- local_action: shell cd /tmp/directory/my-server/target/
- local_action: shell ls -d myfile*.jar
register: test_build
- debug: msg={{ test_build.stdout }}
- copy: src=/tmp/directory/my-server/target/{{ test_build.stdout }} dest=/home/ubuntu/ owner=ubuntu group=ubuntu mode=644 backup=yes
become: true
become_user: ubuntu
become_method: sudo
例外
fatal: [testserver]: FAILED! => {"failed": true, "reason": "no action detected in task. This often indicates a misspelled module name, or incorrect module path.\n\nThe error appears to have been in '/home/user/test/roles/test-server/tasks/move.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: transferring file to server\n^here\n\n\nThe error appears to have been in '/home/user/test/roles/test-server/tasks/synchronize.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: transferring artifact to server\n^here\n"}
謝謝@avalon - 會試着回來。你太棒了! –
就像一個魅力 - 真棒的東西! –