Copy 命令不适用于通配符。
剧本:
- name: Copy Delta Updated Files To All ABC
copy:
src: /opt/SP/users/runner/DEV/ABC/DRF221/DELTA_UPDATE/
dest: ~/JEE/ABC/config_files/ABC-FULL/ABC*_1_DRF221
mode: preserve
tags:
- storage
错误:
fatal: [DEV_ABC]: FAILED! => {"failed": true, "msg": "Failed to get information on remote file (/opt/SP/users/dev/JEE/ABC/config_files/ABC-FULL/ABC_*_1_DRF221/Text.xml): Not a directory"}**
不能在复制命令中使用通配符。您需要先找到目录,然后复制。
- name: find files
find:
paths: /opt/SP/users/dev/JEE/ABC/config_files/ABC-FULL/
file_type: directory
patterns: "ABC_*_1_DRF221"
register: output
- name: copy
copy:
src: /opt/SP/users/runner/DEV/ABC/DRF221/DELTA_UPDATE/
dest: "{{item.path}}"
with_items: "{{output.files}}"
如果 src 文件是远程文件,请使用 remote_src:true