|
|
|
@ -1488,3 +1488,612 @@
|
|
|
|
|
- 'new_sub_dir1/foo.txt'
|
|
|
|
|
loop_control:
|
|
|
|
|
loop_var: 'dest'
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Recursive copying on remote host
|
|
|
|
|
#
|
|
|
|
|
## prepare for test
|
|
|
|
|
- block:
|
|
|
|
|
|
|
|
|
|
- name: execute - Create a test src dir
|
|
|
|
|
file:
|
|
|
|
|
path: '{{ remote_dir }}/remote_dir_src'
|
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the remote_dir_src
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/remote_dir_src'
|
|
|
|
|
register: stat_remote_dir_src_before
|
|
|
|
|
|
|
|
|
|
- name: execute - Create a subdir
|
|
|
|
|
file:
|
|
|
|
|
path: '{{ remote_dir }}/remote_dir_src/subdir'
|
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the remote_dir_src/subdir
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/remote_dir_src/subdir'
|
|
|
|
|
register: stat_remote_dir_src_subdir_before
|
|
|
|
|
|
|
|
|
|
- name: execute - Create a file in the top of src
|
|
|
|
|
copy:
|
|
|
|
|
dest: '{{ remote_dir }}/remote_dir_src/file1'
|
|
|
|
|
content: 'hello world 1'
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the remote_dir_src/file1
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/remote_dir_src/file1'
|
|
|
|
|
register: stat_remote_dir_src_file1_before
|
|
|
|
|
|
|
|
|
|
- name: execute - Create a file in the subdir
|
|
|
|
|
copy:
|
|
|
|
|
dest: '{{ remote_dir }}/remote_dir_src/subdir/file12'
|
|
|
|
|
content: 'hello world 12'
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the remote_dir_src/subdir/file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/remote_dir_src/subdir/file12'
|
|
|
|
|
register: stat_remote_dir_src_subdir_file12_before
|
|
|
|
|
|
|
|
|
|
- name: execute - Create a link to the file12
|
|
|
|
|
file:
|
|
|
|
|
path: '{{ remote_dir }}/remote_dir_src/link_file12'
|
|
|
|
|
src: '{{ remote_dir }}/remote_dir_src/subdir/file12'
|
|
|
|
|
state: link
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the remote_dir_src/link_file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/remote_dir_src/link_file12'
|
|
|
|
|
register: stat_remote_dir_src_link_file12_before
|
|
|
|
|
|
|
|
|
|
### test when src endswith os.sep and dest isdir
|
|
|
|
|
- block:
|
|
|
|
|
|
|
|
|
|
### local_follow: True
|
|
|
|
|
- name: execute - Create a test dest dir
|
|
|
|
|
file:
|
|
|
|
|
path: '{{ remote_dir }}/testcase1_local_follow_true'
|
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
|
|
- name: execute - Copy the directory on remote with local_follow True
|
|
|
|
|
copy:
|
|
|
|
|
remote_src: True
|
|
|
|
|
src: '{{ remote_dir }}/remote_dir_src/'
|
|
|
|
|
dest: '{{ remote_dir }}/testcase1_local_follow_true'
|
|
|
|
|
local_follow: True
|
|
|
|
|
register: testcase1
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the testcase1_local_follow_true
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase1_local_follow_true'
|
|
|
|
|
register: stat_testcase1_local_follow_true
|
|
|
|
|
- name: gather - Stat the testcase1_local_follow_true/subdir
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase1_local_follow_true/subdir'
|
|
|
|
|
register: stat_testcase1_local_follow_true_subdir
|
|
|
|
|
- name: gather - Stat the testcase1_local_follow_true/file1
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase1_local_follow_true/file1'
|
|
|
|
|
register: stat_testcase1_local_follow_true_file1
|
|
|
|
|
- name: gather - Stat the testcase1_local_follow_true/subdir/file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase1_local_follow_true/subdir/file12'
|
|
|
|
|
register: stat_testcase1_local_follow_true_subdir_file12
|
|
|
|
|
- name: gather - Stat the testcase1_local_follow_true/link_file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase1_local_follow_true/link_file12'
|
|
|
|
|
register: stat_testcase1_local_follow_true_link_file12
|
|
|
|
|
|
|
|
|
|
- name: assert - remote_dir_src has copied with local_follow True.
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- testcase1 is changed
|
|
|
|
|
- "stat_testcase1_local_follow_true.stat.isdir"
|
|
|
|
|
- "stat_testcase1_local_follow_true_subdir.stat.isdir"
|
|
|
|
|
- "stat_testcase1_local_follow_true_file1.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_file1_before.stat.checksum == stat_testcase1_local_follow_true_file1.stat.checksum"
|
|
|
|
|
- "stat_testcase1_local_follow_true_subdir_file12.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.checksum == stat_testcase1_local_follow_true_subdir_file12.stat.checksum"
|
|
|
|
|
- "stat_testcase1_local_follow_true_link_file12.stat.exists"
|
|
|
|
|
- "not stat_testcase1_local_follow_true_link_file12.stat.islnk"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.checksum == stat_testcase1_local_follow_true_link_file12.stat.checksum"
|
|
|
|
|
|
|
|
|
|
### local_follow: False
|
|
|
|
|
- name: execute - Create a test dest dir
|
|
|
|
|
file:
|
|
|
|
|
path: '{{ remote_dir }}/testcase1_local_follow_false'
|
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
|
|
- name: execute - Copy the directory on remote with local_follow False
|
|
|
|
|
copy:
|
|
|
|
|
remote_src: True
|
|
|
|
|
src: '{{ remote_dir }}/remote_dir_src/'
|
|
|
|
|
dest: '{{ remote_dir }}/testcase1_local_follow_false'
|
|
|
|
|
local_follow: False
|
|
|
|
|
register: testcase1
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the testcase1_local_follow_false
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase1_local_follow_false'
|
|
|
|
|
register: stat_testcase1_local_follow_false
|
|
|
|
|
- name: gather - Stat the testcase1_local_follow_false/subdir
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase1_local_follow_false/subdir'
|
|
|
|
|
register: stat_testcase1_local_follow_false_subdir
|
|
|
|
|
- name: gather - Stat the testcase1_local_follow_false/file1
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase1_local_follow_false/file1'
|
|
|
|
|
register: stat_testcase1_local_follow_false_file1
|
|
|
|
|
- name: gather - Stat the testcase1_local_follow_false/subdir/file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase1_local_follow_false/subdir/file12'
|
|
|
|
|
register: stat_testcase1_local_follow_false_subdir_file12
|
|
|
|
|
- name: gather - Stat the testcase1_local_follow_false/link_file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase1_local_follow_false/link_file12'
|
|
|
|
|
register: stat_testcase1_local_follow_false_link_file12
|
|
|
|
|
|
|
|
|
|
- name: assert - remote_dir_src has copied with local_follow True.
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- testcase1 is changed
|
|
|
|
|
- "stat_testcase1_local_follow_false.stat.isdir"
|
|
|
|
|
- "stat_testcase1_local_follow_false_subdir.stat.isdir"
|
|
|
|
|
- "stat_testcase1_local_follow_false_file1.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_file1_before.stat.checksum == stat_testcase1_local_follow_false_file1.stat.checksum"
|
|
|
|
|
- "stat_testcase1_local_follow_false_subdir_file12.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.checksum == stat_testcase1_local_follow_false_subdir_file12.stat.checksum"
|
|
|
|
|
- "stat_testcase1_local_follow_false_link_file12.stat.exists"
|
|
|
|
|
- "stat_testcase1_local_follow_false_link_file12.stat.islnk"
|
|
|
|
|
|
|
|
|
|
## test when src endswith os.sep and dest not exists
|
|
|
|
|
|
|
|
|
|
- block:
|
|
|
|
|
- name: execute - Copy the directory on remote with local_follow True
|
|
|
|
|
copy:
|
|
|
|
|
remote_src: True
|
|
|
|
|
src: '{{ remote_dir }}/remote_dir_src/'
|
|
|
|
|
dest: '{{ remote_dir }}/testcase2_local_follow_true'
|
|
|
|
|
local_follow: True
|
|
|
|
|
register: testcase2
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the testcase2_local_follow_true
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase2_local_follow_true'
|
|
|
|
|
register: stat_testcase2_local_follow_true
|
|
|
|
|
- name: gather - Stat the testcase2_local_follow_true/subdir
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase2_local_follow_true/subdir'
|
|
|
|
|
register: stat_testcase2_local_follow_true_subdir
|
|
|
|
|
- name: gather - Stat the testcase2_local_follow_true/file1
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase2_local_follow_true/file1'
|
|
|
|
|
register: stat_testcase2_local_follow_true_file1
|
|
|
|
|
- name: gather - Stat the testcase2_local_follow_true/subdir/file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase2_local_follow_true/subdir/file12'
|
|
|
|
|
register: stat_testcase2_local_follow_true_subdir_file12
|
|
|
|
|
- name: gather - Stat the testcase2_local_follow_true/link_file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase2_local_follow_true/link_file12'
|
|
|
|
|
register: stat_testcase2_local_follow_true_link_file12
|
|
|
|
|
|
|
|
|
|
- name: assert - remote_dir_src has copied with local_follow True.
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- testcase2 is changed
|
|
|
|
|
- "stat_testcase2_local_follow_true.stat.isdir"
|
|
|
|
|
- "stat_testcase2_local_follow_true_subdir.stat.isdir"
|
|
|
|
|
- "stat_testcase2_local_follow_true_file1.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_file1_before.stat.checksum == stat_testcase2_local_follow_true_file1.stat.checksum"
|
|
|
|
|
- "stat_testcase2_local_follow_true_subdir_file12.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.checksum == stat_testcase2_local_follow_true_subdir_file12.stat.checksum"
|
|
|
|
|
- "stat_testcase2_local_follow_true_link_file12.stat.exists"
|
|
|
|
|
- "not stat_testcase2_local_follow_true_link_file12.stat.islnk"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.checksum == stat_testcase2_local_follow_true_link_file12.stat.checksum"
|
|
|
|
|
|
|
|
|
|
### local_follow: False
|
|
|
|
|
- name: execute - Copy the directory on remote with local_follow False
|
|
|
|
|
copy:
|
|
|
|
|
remote_src: True
|
|
|
|
|
src: '{{ remote_dir }}/remote_dir_src/'
|
|
|
|
|
dest: '{{ remote_dir }}/testcase2_local_follow_false'
|
|
|
|
|
local_follow: False
|
|
|
|
|
register: testcase2
|
|
|
|
|
|
|
|
|
|
- name: execute - Copy the directory on remote with local_follow False
|
|
|
|
|
copy:
|
|
|
|
|
remote_src: True
|
|
|
|
|
src: '{{ remote_dir }}/remote_dir_src/'
|
|
|
|
|
dest: '{{ remote_dir }}/testcase2_local_follow_false'
|
|
|
|
|
local_follow: False
|
|
|
|
|
register: testcase1
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the testcase2_local_follow_false
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase2_local_follow_false'
|
|
|
|
|
register: stat_testcase2_local_follow_false
|
|
|
|
|
- name: gather - Stat the testcase2_local_follow_false/subdir
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase2_local_follow_false/subdir'
|
|
|
|
|
register: stat_testcase2_local_follow_false_subdir
|
|
|
|
|
- name: gather - Stat the testcase2_local_follow_false/file1
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase2_local_follow_false/file1'
|
|
|
|
|
register: stat_testcase2_local_follow_false_file1
|
|
|
|
|
- name: gather - Stat the testcase2_local_follow_false/subdir/file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase2_local_follow_false/subdir/file12'
|
|
|
|
|
register: stat_testcase2_local_follow_false_subdir_file12
|
|
|
|
|
- name: gather - Stat the testcase2_local_follow_false/link_file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase2_local_follow_false/link_file12'
|
|
|
|
|
register: stat_testcase2_local_follow_false_link_file12
|
|
|
|
|
|
|
|
|
|
- name: assert - remote_dir_src has copied with local_follow True.
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- testcase2 is changed
|
|
|
|
|
- "stat_testcase2_local_follow_false.stat.isdir"
|
|
|
|
|
- "stat_testcase2_local_follow_false_subdir.stat.isdir"
|
|
|
|
|
- "stat_testcase2_local_follow_false_file1.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_file1_before.stat.checksum == stat_testcase2_local_follow_false_file1.stat.checksum"
|
|
|
|
|
- "stat_testcase2_local_follow_false_subdir_file12.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.checksum == stat_testcase2_local_follow_false_subdir_file12.stat.checksum"
|
|
|
|
|
- "stat_testcase2_local_follow_false_link_file12.stat.exists"
|
|
|
|
|
- "stat_testcase2_local_follow_false_link_file12.stat.islnk"
|
|
|
|
|
|
|
|
|
|
## test when src not endswith os.sep and dest isdir
|
|
|
|
|
- block:
|
|
|
|
|
|
|
|
|
|
### local_follow: True
|
|
|
|
|
- name: execute - Create a test dest dir
|
|
|
|
|
file:
|
|
|
|
|
path: '{{ remote_dir }}/testcase3_local_follow_true'
|
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
|
|
- name: execute - Copy the directory on remote with local_follow True
|
|
|
|
|
copy:
|
|
|
|
|
remote_src: True
|
|
|
|
|
src: '{{ remote_dir }}/remote_dir_src'
|
|
|
|
|
dest: '{{ remote_dir }}/testcase3_local_follow_true'
|
|
|
|
|
local_follow: True
|
|
|
|
|
register: testcase3
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the testcase3_local_follow_true
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase3_local_follow_true/remote_dir_src'
|
|
|
|
|
register: stat_testcase3_local_follow_true_remote_dir_src
|
|
|
|
|
- name: gather - Stat the testcase3_local_follow_true/remote_dir_src/subdir
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase3_local_follow_true/remote_dir_src/subdir'
|
|
|
|
|
register: stat_testcase3_local_follow_true_remote_dir_src_subdir
|
|
|
|
|
- name: gather - Stat the testcase3_local_follow_true/remote_dir_src/file1
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase3_local_follow_true/remote_dir_src/file1'
|
|
|
|
|
register: stat_testcase3_local_follow_true_remote_dir_src_file1
|
|
|
|
|
- name: gather - Stat the testcase3_local_follow_true/remote_dir_src/subdir/file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase3_local_follow_true/remote_dir_src/subdir/file12'
|
|
|
|
|
register: stat_testcase3_local_follow_true_remote_dir_src_subdir_file12
|
|
|
|
|
- name: gather - Stat the testcase3_local_follow_true/remote_dir_src/link_file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase3_local_follow_true/remote_dir_src/link_file12'
|
|
|
|
|
register: stat_testcase3_local_follow_true_remote_dir_src_link_file12
|
|
|
|
|
|
|
|
|
|
- name: assert - remote_dir_src has copied with local_follow True.
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- testcase3 is changed
|
|
|
|
|
- "stat_testcase3_local_follow_true_remote_dir_src.stat.isdir"
|
|
|
|
|
- "stat_testcase3_local_follow_true_remote_dir_src_subdir.stat.isdir"
|
|
|
|
|
- "stat_testcase3_local_follow_true_remote_dir_src_file1.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_file1_before.stat.checksum == stat_testcase3_local_follow_true_remote_dir_src_file1.stat.checksum"
|
|
|
|
|
- "stat_testcase3_local_follow_true_remote_dir_src_subdir_file12.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.checksum == stat_testcase3_local_follow_true_remote_dir_src_subdir_file12.stat.checksum"
|
|
|
|
|
- "stat_testcase3_local_follow_true_remote_dir_src_link_file12.stat.exists"
|
|
|
|
|
- "not stat_testcase3_local_follow_true_remote_dir_src_link_file12.stat.islnk"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.checksum == stat_testcase3_local_follow_true_remote_dir_src_link_file12.stat.checksum"
|
|
|
|
|
|
|
|
|
|
### local_follow: False
|
|
|
|
|
- name: execute - Create a test dest dir
|
|
|
|
|
file:
|
|
|
|
|
path: '{{ remote_dir }}/testcase3_local_follow_false'
|
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
|
|
- name: execute - Copy the directory on remote with local_follow False
|
|
|
|
|
copy:
|
|
|
|
|
remote_src: True
|
|
|
|
|
src: '{{ remote_dir }}/remote_dir_src'
|
|
|
|
|
dest: '{{ remote_dir }}/testcase3_local_follow_false'
|
|
|
|
|
local_follow: False
|
|
|
|
|
register: testcase3
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the testcase3_local_follow_false
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase3_local_follow_false/remote_dir_src'
|
|
|
|
|
register: stat_testcase3_local_follow_false_remote_dir_src
|
|
|
|
|
- name: gather - Stat the testcase3_local_follow_false/remote_dir_src/subdir
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase3_local_follow_false/remote_dir_src/subdir'
|
|
|
|
|
register: stat_testcase3_local_follow_false_remote_dir_src_subdir
|
|
|
|
|
- name: gather - Stat the testcase3_local_follow_false/remote_dir_src/file1
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase3_local_follow_false/remote_dir_src/file1'
|
|
|
|
|
register: stat_testcase3_local_follow_false_remote_dir_src_file1
|
|
|
|
|
- name: gather - Stat the testcase3_local_follow_false/remote_dir_src/subdir/file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase3_local_follow_false/remote_dir_src/subdir/file12'
|
|
|
|
|
register: stat_testcase3_local_follow_false_remote_dir_src_subdir_file12
|
|
|
|
|
- name: gather - Stat the testcase3_local_follow_false/remote_dir_src/link_file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase3_local_follow_false/remote_dir_src/link_file12'
|
|
|
|
|
register: stat_testcase3_local_follow_false_remote_dir_src_link_file12
|
|
|
|
|
|
|
|
|
|
- name: assert - remote_dir_src has copied with local_follow False.
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- testcase3 is changed
|
|
|
|
|
- "stat_testcase3_local_follow_false_remote_dir_src.stat.isdir"
|
|
|
|
|
- "stat_testcase3_local_follow_false_remote_dir_src_subdir.stat.isdir"
|
|
|
|
|
- "stat_testcase3_local_follow_false_remote_dir_src_file1.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_file1_before.stat.checksum == stat_testcase3_local_follow_false_remote_dir_src_file1.stat.checksum"
|
|
|
|
|
- "stat_testcase3_local_follow_false_remote_dir_src_subdir_file12.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.checksum == stat_testcase3_local_follow_false_remote_dir_src_subdir_file12.stat.checksum"
|
|
|
|
|
- "stat_testcase3_local_follow_false_remote_dir_src_link_file12.stat.exists"
|
|
|
|
|
- "stat_testcase3_local_follow_false_remote_dir_src_link_file12.stat.islnk"
|
|
|
|
|
|
|
|
|
|
## test when src not endswith os.sep and dest not exists
|
|
|
|
|
- block:
|
|
|
|
|
### local_follow: True
|
|
|
|
|
- name: execute - Copy the directory on remote with local_follow True
|
|
|
|
|
copy:
|
|
|
|
|
remote_src: True
|
|
|
|
|
src: '{{ remote_dir }}/remote_dir_src'
|
|
|
|
|
dest: '{{ remote_dir }}/testcase4_local_follow_true'
|
|
|
|
|
local_follow: True
|
|
|
|
|
register: testcase4
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the testcase4_local_follow_true
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase4_local_follow_true/remote_dir_src'
|
|
|
|
|
register: stat_testcase4_local_follow_true_remote_dir_src
|
|
|
|
|
- name: gather - Stat the testcase4_local_follow_true/remote_dir_src/subdir
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase4_local_follow_true/remote_dir_src/subdir'
|
|
|
|
|
register: stat_testcase4_local_follow_true_remote_dir_src_subdir
|
|
|
|
|
- name: gather - Stat the testcase4_local_follow_true/remote_dir_src/file1
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase4_local_follow_true/remote_dir_src/file1'
|
|
|
|
|
register: stat_testcase4_local_follow_true_remote_dir_src_file1
|
|
|
|
|
- name: gather - Stat the testcase4_local_follow_true/remote_dir_src/subdir/file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase4_local_follow_true/remote_dir_src/subdir/file12'
|
|
|
|
|
register: stat_testcase4_local_follow_true_remote_dir_src_subdir_file12
|
|
|
|
|
- name: gather - Stat the testcase4_local_follow_true/remote_dir_src/link_file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase4_local_follow_true/remote_dir_src/link_file12'
|
|
|
|
|
register: stat_testcase4_local_follow_true_remote_dir_src_link_file12
|
|
|
|
|
|
|
|
|
|
- name: assert - remote_dir_src has copied with local_follow True.
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- testcase4 is changed
|
|
|
|
|
- "stat_testcase4_local_follow_true_remote_dir_src.stat.isdir"
|
|
|
|
|
- "stat_testcase4_local_follow_true_remote_dir_src_subdir.stat.isdir"
|
|
|
|
|
- "stat_testcase4_local_follow_true_remote_dir_src_file1.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_file1_before.stat.checksum == stat_testcase4_local_follow_true_remote_dir_src_file1.stat.checksum"
|
|
|
|
|
- "stat_testcase4_local_follow_true_remote_dir_src_subdir_file12.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.checksum == stat_testcase4_local_follow_true_remote_dir_src_subdir_file12.stat.checksum"
|
|
|
|
|
- "stat_testcase4_local_follow_true_remote_dir_src_link_file12.stat.exists"
|
|
|
|
|
- "not stat_testcase4_local_follow_true_remote_dir_src_link_file12.stat.islnk"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.checksum == stat_testcase4_local_follow_true_remote_dir_src_link_file12.stat.checksum"
|
|
|
|
|
|
|
|
|
|
### local_follow: False
|
|
|
|
|
- name: execute - Copy the directory on remote with local_follow False
|
|
|
|
|
copy:
|
|
|
|
|
remote_src: True
|
|
|
|
|
src: '{{ remote_dir }}/remote_dir_src'
|
|
|
|
|
dest: '{{ remote_dir }}/testcase4_local_follow_false'
|
|
|
|
|
local_follow: False
|
|
|
|
|
register: testcase4
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the testcase4_local_follow_false
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase4_local_follow_false/remote_dir_src'
|
|
|
|
|
register: stat_testcase4_local_follow_false_remote_dir_src
|
|
|
|
|
- name: gather - Stat the testcase4_local_follow_false/remote_dir_src/subdir
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase4_local_follow_false/remote_dir_src/subdir'
|
|
|
|
|
register: stat_testcase4_local_follow_false_remote_dir_src_subdir
|
|
|
|
|
- name: gather - Stat the testcase4_local_follow_false/remote_dir_src/file1
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase4_local_follow_false/remote_dir_src/file1'
|
|
|
|
|
register: stat_testcase4_local_follow_false_remote_dir_src_file1
|
|
|
|
|
- name: gather - Stat the testcase4_local_follow_false/remote_dir_src/subdir/file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase4_local_follow_false/remote_dir_src/subdir/file12'
|
|
|
|
|
register: stat_testcase4_local_follow_false_remote_dir_src_subdir_file12
|
|
|
|
|
- name: gather - Stat the testcase4_local_follow_false/remote_dir_src/link_file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/testcase4_local_follow_false/remote_dir_src/link_file12'
|
|
|
|
|
register: stat_testcase4_local_follow_false_remote_dir_src_link_file12
|
|
|
|
|
|
|
|
|
|
- name: assert - remote_dir_src has copied with local_follow False.
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- testcase4 is changed
|
|
|
|
|
- "stat_testcase4_local_follow_false_remote_dir_src.stat.isdir"
|
|
|
|
|
- "stat_testcase4_local_follow_false_remote_dir_src_subdir.stat.isdir"
|
|
|
|
|
- "stat_testcase4_local_follow_false_remote_dir_src_file1.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_file1_before.stat.checksum == stat_testcase4_local_follow_false_remote_dir_src_file1.stat.checksum"
|
|
|
|
|
- "stat_testcase4_local_follow_false_remote_dir_src_subdir_file12.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.checksum == stat_testcase4_local_follow_false_remote_dir_src_subdir_file12.stat.checksum"
|
|
|
|
|
- "stat_testcase4_local_follow_false_remote_dir_src_link_file12.stat.exists"
|
|
|
|
|
- "stat_testcase4_local_follow_false_remote_dir_src_link_file12.stat.islnk"
|
|
|
|
|
|
|
|
|
|
## test copying the directory on remote with chown
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- block:
|
|
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
|
ansible_copy_test_user_name: 'ansible_copy_test_{{ 100000 | random }}'
|
|
|
|
|
|
|
|
|
|
- name: execute - create a user for test
|
|
|
|
|
user:
|
|
|
|
|
name: '{{ ansible_copy_test_user_name }}'
|
|
|
|
|
state: present
|
|
|
|
|
register: ansible_copy_test_user
|
|
|
|
|
|
|
|
|
|
- name: execute - create a group for test
|
|
|
|
|
group:
|
|
|
|
|
name: '{{ ansible_copy_test_user_name }}'
|
|
|
|
|
state: present
|
|
|
|
|
register: ansible_copy_test_group
|
|
|
|
|
|
|
|
|
|
- name: execute - Copy the directory on remote with chown
|
|
|
|
|
copy:
|
|
|
|
|
remote_src: True
|
|
|
|
|
src: '{{ remote_dir }}/remote_dir_src/'
|
|
|
|
|
dest: '{{ remote_dir }}/new_dir_with_chown'
|
|
|
|
|
owner: '{{ ansible_copy_test_user_name }}'
|
|
|
|
|
group: '{{ ansible_copy_test_user_name }}'
|
|
|
|
|
register: testcase5
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the new_dir_with_chown
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/new_dir_with_chown'
|
|
|
|
|
register: stat_new_dir_with_chown
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the new_dir_with_chown/file1
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/new_dir_with_chown/file1'
|
|
|
|
|
register: stat_new_dir_with_chown_file1
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the new_dir_with_chown/subdir
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/new_dir_with_chown/subdir'
|
|
|
|
|
register: stat_new_dir_with_chown_subdir
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the new_dir_with_chown/subdir/file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/new_dir_with_chown/subdir/file12'
|
|
|
|
|
register: stat_new_dir_with_chown_subdir_file12
|
|
|
|
|
|
|
|
|
|
- name: gather - Stat the new_dir_with_chown/link_file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/new_dir_with_chown/link_file12'
|
|
|
|
|
register: stat_new_dir_with_chown_link_file12
|
|
|
|
|
|
|
|
|
|
- name: assert - owner and group have changed
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- testcase5 is changed
|
|
|
|
|
- "stat_new_dir_with_chown.stat.uid == {{ ansible_copy_test_user.uid }}"
|
|
|
|
|
- "stat_new_dir_with_chown.stat.gid == {{ ansible_copy_test_group.gid }}"
|
|
|
|
|
- "stat_new_dir_with_chown.stat.pw_name == '{{ ansible_copy_test_user_name }}'"
|
|
|
|
|
- "stat_new_dir_with_chown.stat.gr_name == '{{ ansible_copy_test_user_name }}'"
|
|
|
|
|
- "stat_new_dir_with_chown_file1.stat.uid == {{ ansible_copy_test_user.uid }}"
|
|
|
|
|
- "stat_new_dir_with_chown_file1.stat.gid == {{ ansible_copy_test_group.gid }}"
|
|
|
|
|
- "stat_new_dir_with_chown_file1.stat.pw_name == '{{ ansible_copy_test_user_name }}'"
|
|
|
|
|
- "stat_new_dir_with_chown_file1.stat.gr_name == '{{ ansible_copy_test_user_name }}'"
|
|
|
|
|
- "stat_new_dir_with_chown_subdir.stat.uid == {{ ansible_copy_test_user.uid }}"
|
|
|
|
|
- "stat_new_dir_with_chown_subdir.stat.gid == {{ ansible_copy_test_group.gid }}"
|
|
|
|
|
- "stat_new_dir_with_chown_subdir.stat.pw_name == '{{ ansible_copy_test_user_name }}'"
|
|
|
|
|
- "stat_new_dir_with_chown_subdir.stat.gr_name == '{{ ansible_copy_test_user_name }}'"
|
|
|
|
|
- "stat_new_dir_with_chown_subdir_file12.stat.uid == {{ ansible_copy_test_user.uid }}"
|
|
|
|
|
- "stat_new_dir_with_chown_subdir_file12.stat.gid == {{ ansible_copy_test_group.gid }}"
|
|
|
|
|
- "stat_new_dir_with_chown_subdir_file12.stat.pw_name == '{{ ansible_copy_test_user_name }}'"
|
|
|
|
|
- "stat_new_dir_with_chown_subdir_file12.stat.gr_name == '{{ ansible_copy_test_user_name }}'"
|
|
|
|
|
- "stat_new_dir_with_chown_link_file12.stat.uid == {{ ansible_copy_test_user.uid }}"
|
|
|
|
|
- "stat_new_dir_with_chown_link_file12.stat.gid == {{ ansible_copy_test_group.gid }}"
|
|
|
|
|
- "stat_new_dir_with_chown_link_file12.stat.pw_name == '{{ ansible_copy_test_user_name }}'"
|
|
|
|
|
- "stat_new_dir_with_chown_link_file12.stat.gr_name == '{{ ansible_copy_test_user_name }}'"
|
|
|
|
|
|
|
|
|
|
always:
|
|
|
|
|
- name: execute - remove the user for test
|
|
|
|
|
user:
|
|
|
|
|
name: '{{ ansible_copy_test_user_name }}'
|
|
|
|
|
state: absent
|
|
|
|
|
remove: yes
|
|
|
|
|
|
|
|
|
|
- name: execute - remove the group for test
|
|
|
|
|
group:
|
|
|
|
|
name: '{{ ansible_copy_test_user_name }}'
|
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
|
|
## testcase last - make sure remote_dir_src not change
|
|
|
|
|
- block:
|
|
|
|
|
- name: Stat the remote_dir_src
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/remote_dir_src'
|
|
|
|
|
register: stat_remote_dir_src_after
|
|
|
|
|
|
|
|
|
|
- name: Stat the remote_dir_src/subdir
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/remote_dir_src/subdir'
|
|
|
|
|
register: stat_remote_dir_src_subdir_after
|
|
|
|
|
|
|
|
|
|
- name: Stat the remote_dir_src/file1
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/remote_dir_src/file1'
|
|
|
|
|
register: stat_remote_dir_src_file1_after
|
|
|
|
|
|
|
|
|
|
- name: Stat the remote_dir_src/subdir/file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/remote_dir_src/subdir/file12'
|
|
|
|
|
register: stat_remote_dir_src_subdir_file12_after
|
|
|
|
|
|
|
|
|
|
- name: Stat the remote_dir_src/link_file12
|
|
|
|
|
stat:
|
|
|
|
|
path: '{{ remote_dir }}/remote_dir_src/link_file12'
|
|
|
|
|
register: stat_remote_dir_src_link_file12_after
|
|
|
|
|
|
|
|
|
|
- name: Assert that remote_dir_src not change.
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- "stat_remote_dir_src_after.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_after.stat.isdir"
|
|
|
|
|
- "stat_remote_dir_src_before.stat.uid == stat_remote_dir_src_after.stat.uid"
|
|
|
|
|
- "stat_remote_dir_src_before.stat.gid == stat_remote_dir_src_after.stat.gid"
|
|
|
|
|
- "stat_remote_dir_src_before.stat.pw_name == stat_remote_dir_src_after.stat.pw_name"
|
|
|
|
|
- "stat_remote_dir_src_before.stat.gr_name == stat_remote_dir_src_after.stat.gr_name"
|
|
|
|
|
- "stat_remote_dir_src_before.stat.path == stat_remote_dir_src_after.stat.path"
|
|
|
|
|
- "stat_remote_dir_src_before.stat.mode == stat_remote_dir_src_after.stat.mode"
|
|
|
|
|
|
|
|
|
|
- "stat_remote_dir_src_subdir_after.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_subdir_after.stat.isdir"
|
|
|
|
|
- "stat_remote_dir_src_subdir_before.stat.uid == stat_remote_dir_src_subdir_after.stat.uid"
|
|
|
|
|
- "stat_remote_dir_src_subdir_before.stat.gid == stat_remote_dir_src_subdir_after.stat.gid"
|
|
|
|
|
- "stat_remote_dir_src_subdir_before.stat.pw_name == stat_remote_dir_src_subdir_after.stat.pw_name"
|
|
|
|
|
- "stat_remote_dir_src_subdir_before.stat.gr_name == stat_remote_dir_src_subdir_after.stat.gr_name"
|
|
|
|
|
- "stat_remote_dir_src_subdir_before.stat.path == stat_remote_dir_src_subdir_after.stat.path"
|
|
|
|
|
- "stat_remote_dir_src_subdir_before.stat.mode == stat_remote_dir_src_subdir_after.stat.mode"
|
|
|
|
|
|
|
|
|
|
- "stat_remote_dir_src_file1_after.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_file1_before.stat.uid == stat_remote_dir_src_file1_after.stat.uid"
|
|
|
|
|
- "stat_remote_dir_src_file1_before.stat.gid == stat_remote_dir_src_file1_after.stat.gid"
|
|
|
|
|
- "stat_remote_dir_src_file1_before.stat.pw_name == stat_remote_dir_src_file1_after.stat.pw_name"
|
|
|
|
|
- "stat_remote_dir_src_file1_before.stat.gr_name == stat_remote_dir_src_file1_after.stat.gr_name"
|
|
|
|
|
- "stat_remote_dir_src_file1_before.stat.path == stat_remote_dir_src_file1_after.stat.path"
|
|
|
|
|
- "stat_remote_dir_src_file1_before.stat.mode == stat_remote_dir_src_file1_after.stat.mode"
|
|
|
|
|
- "stat_remote_dir_src_file1_before.stat.checksum == stat_remote_dir_src_file1_after.stat.checksum"
|
|
|
|
|
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_after.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.uid == stat_remote_dir_src_subdir_file12_after.stat.uid"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.gid == stat_remote_dir_src_subdir_file12_after.stat.gid"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.pw_name == stat_remote_dir_src_subdir_file12_after.stat.pw_name"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.gr_name == stat_remote_dir_src_subdir_file12_after.stat.gr_name"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.path == stat_remote_dir_src_subdir_file12_after.stat.path"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.mode == stat_remote_dir_src_subdir_file12_after.stat.mode"
|
|
|
|
|
- "stat_remote_dir_src_subdir_file12_before.stat.checksum == stat_remote_dir_src_subdir_file12_after.stat.checksum"
|
|
|
|
|
|
|
|
|
|
- "stat_remote_dir_src_link_file12_after.stat.exists"
|
|
|
|
|
- "stat_remote_dir_src_link_file12_after.stat.islnk"
|
|
|
|
|
- "stat_remote_dir_src_link_file12_before.stat.uid == stat_remote_dir_src_link_file12_after.stat.uid"
|
|
|
|
|
- "stat_remote_dir_src_link_file12_before.stat.gid == stat_remote_dir_src_link_file12_after.stat.gid"
|
|
|
|
|
- "stat_remote_dir_src_link_file12_before.stat.pw_name == stat_remote_dir_src_link_file12_after.stat.pw_name"
|
|
|
|
|
- "stat_remote_dir_src_link_file12_before.stat.gr_name == stat_remote_dir_src_link_file12_after.stat.gr_name"
|
|
|
|
|
- "stat_remote_dir_src_link_file12_before.stat.path == stat_remote_dir_src_link_file12_after.stat.path"
|
|
|
|
|
- "stat_remote_dir_src_link_file12_before.stat.mode == stat_remote_dir_src_link_file12_after.stat.mode"
|