工作代码:
---
- name: figure out what we are moving
find:
paths={{ A }}
recurse=no
age={{ 1h }}
file_type=directory
excludes={{excludelist}}
register: tomove_list
- name: check if this already exists at destination
with_items: "{{ tomove_list.files }}"
stat: path={{ C }}{{ item.path | basename }}
register: check_existing_dirs
- name: warn about existing dirs
with_items: "{{ check_existing_dirs.results }}"
when: "{{ item.stat.exists }}"
debug: msg="{{ item.stat.path }} conflicts with an existing run! {{
tomove_list.files }}"
register: duplicates_with_existing
- name: Move the run dirs to temporary target
synchronize:
mode: pull
src: "{{ item.path }}"
dest: "{{ B }}"
recursive: yes
with_items: "{{ tomove_list.files }}"
当前此代码复制了所有内容,但想添加一个条件以排除现有目录列表,我们只是在第3步中发出警告。