|
|
@ -16,16 +16,16 @@
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
- set_fact: output_dir_test={{output_dir}}/test_find
|
|
|
|
- set_fact: remote_tmp_dir_test={{remote_tmp_dir}}/test_find
|
|
|
|
|
|
|
|
|
|
|
|
- name: make sure our testing sub-directory does not exist
|
|
|
|
- name: make sure our testing sub-directory does not exist
|
|
|
|
file:
|
|
|
|
file:
|
|
|
|
path: "{{ output_dir_test }}"
|
|
|
|
path: "{{ remote_tmp_dir_test }}"
|
|
|
|
state: absent
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
|
|
|
|
- name: create our testing sub-directory
|
|
|
|
- name: create our testing sub-directory
|
|
|
|
file:
|
|
|
|
file:
|
|
|
|
path: "{{ output_dir_test }}"
|
|
|
|
path: "{{ remote_tmp_dir_test }}"
|
|
|
|
state: directory
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
##
|
|
|
@ -34,7 +34,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- name: make some directories
|
|
|
|
- name: make some directories
|
|
|
|
file:
|
|
|
|
file:
|
|
|
|
path: "{{ output_dir_test }}/{{ item }}"
|
|
|
|
path: "{{ remote_tmp_dir_test }}/{{ item }}"
|
|
|
|
state: directory
|
|
|
|
state: directory
|
|
|
|
with_items:
|
|
|
|
with_items:
|
|
|
|
- a/b/c/d
|
|
|
|
- a/b/c/d
|
|
|
@ -42,7 +42,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- name: make some files
|
|
|
|
- name: make some files
|
|
|
|
copy:
|
|
|
|
copy:
|
|
|
|
dest: "{{ output_dir_test }}/{{ item }}"
|
|
|
|
dest: "{{ remote_tmp_dir_test }}/{{ item }}"
|
|
|
|
content: 'data'
|
|
|
|
content: 'data'
|
|
|
|
with_items:
|
|
|
|
with_items:
|
|
|
|
- a/1.txt
|
|
|
|
- a/1.txt
|
|
|
@ -56,7 +56,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- name: find the directories
|
|
|
|
- name: find the directories
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
paths: "{{ output_dir_test }}"
|
|
|
|
paths: "{{ remote_tmp_dir_test }}"
|
|
|
|
file_type: directory
|
|
|
|
file_type: directory
|
|
|
|
recurse: yes
|
|
|
|
recurse: yes
|
|
|
|
register: find_test0
|
|
|
|
register: find_test0
|
|
|
@ -75,7 +75,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- name: find the xml and img files
|
|
|
|
- name: find the xml and img files
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
paths: "{{ output_dir_test }}"
|
|
|
|
paths: "{{ remote_tmp_dir_test }}"
|
|
|
|
file_type: file
|
|
|
|
file_type: file
|
|
|
|
patterns: "*.xml,*.img"
|
|
|
|
patterns: "*.xml,*.img"
|
|
|
|
recurse: yes
|
|
|
|
recurse: yes
|
|
|
@ -89,7 +89,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- name: find the xml file
|
|
|
|
- name: find the xml file
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
paths: "{{ output_dir_test }}"
|
|
|
|
paths: "{{ remote_tmp_dir_test }}"
|
|
|
|
patterns: "*.xml"
|
|
|
|
patterns: "*.xml"
|
|
|
|
recurse: yes
|
|
|
|
recurse: yes
|
|
|
|
register: find_test2
|
|
|
|
register: find_test2
|
|
|
@ -103,7 +103,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- name: find the xml file with empty excludes
|
|
|
|
- name: find the xml file with empty excludes
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
paths: "{{ output_dir_test }}"
|
|
|
|
paths: "{{ remote_tmp_dir_test }}"
|
|
|
|
patterns: "*.xml"
|
|
|
|
patterns: "*.xml"
|
|
|
|
recurse: yes
|
|
|
|
recurse: yes
|
|
|
|
excludes: []
|
|
|
|
excludes: []
|
|
|
@ -119,7 +119,7 @@
|
|
|
|
- name: Copy some files into the test dir
|
|
|
|
- name: Copy some files into the test dir
|
|
|
|
copy:
|
|
|
|
copy:
|
|
|
|
src: "{{ item }}"
|
|
|
|
src: "{{ item }}"
|
|
|
|
dest: "{{ output_dir_test }}/{{ item }}"
|
|
|
|
dest: "{{ remote_tmp_dir_test }}/{{ item }}"
|
|
|
|
mode: 0644
|
|
|
|
mode: 0644
|
|
|
|
with_items:
|
|
|
|
with_items:
|
|
|
|
- a.txt
|
|
|
|
- a.txt
|
|
|
@ -127,7 +127,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- name: Ensure '$' only matches the true end of the file with read_whole_file, not a line
|
|
|
|
- name: Ensure '$' only matches the true end of the file with read_whole_file, not a line
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
paths: "{{ output_dir_test }}"
|
|
|
|
paths: "{{ remote_tmp_dir_test }}"
|
|
|
|
patterns: "*.txt"
|
|
|
|
patterns: "*.txt"
|
|
|
|
contains: "KO$"
|
|
|
|
contains: "KO$"
|
|
|
|
read_whole_file: true
|
|
|
|
read_whole_file: true
|
|
|
@ -141,7 +141,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- name: Match the end of the file successfully
|
|
|
|
- name: Match the end of the file successfully
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
paths: "{{ output_dir_test }}"
|
|
|
|
paths: "{{ remote_tmp_dir_test }}"
|
|
|
|
patterns: "*.txt"
|
|
|
|
patterns: "*.txt"
|
|
|
|
contains: "OK$"
|
|
|
|
contains: "OK$"
|
|
|
|
read_whole_file: true
|
|
|
|
read_whole_file: true
|
|
|
@ -155,7 +155,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- name: When read_whole_file=False, $ should match an individual line
|
|
|
|
- name: When read_whole_file=False, $ should match an individual line
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
paths: "{{ output_dir_test }}"
|
|
|
|
paths: "{{ remote_tmp_dir_test }}"
|
|
|
|
patterns: "*.txt"
|
|
|
|
patterns: "*.txt"
|
|
|
|
contains: ".*KO$"
|
|
|
|
contains: ".*KO$"
|
|
|
|
read_whole_file: false
|
|
|
|
read_whole_file: false
|
|
|
@ -169,7 +169,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- name: When read_whole_file=True, match across line boundaries
|
|
|
|
- name: When read_whole_file=True, match across line boundaries
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
paths: "{{ output_dir_test }}"
|
|
|
|
paths: "{{ remote_tmp_dir_test }}"
|
|
|
|
patterns: "*.txt"
|
|
|
|
patterns: "*.txt"
|
|
|
|
contains: "has\na few"
|
|
|
|
contains: "has\na few"
|
|
|
|
read_whole_file: true
|
|
|
|
read_whole_file: true
|
|
|
@ -183,7 +183,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- name: When read_whole_file=False, do not match across line boundaries
|
|
|
|
- name: When read_whole_file=False, do not match across line boundaries
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
paths: "{{ output_dir_test }}"
|
|
|
|
paths: "{{ remote_tmp_dir_test }}"
|
|
|
|
patterns: "*.txt"
|
|
|
|
patterns: "*.txt"
|
|
|
|
contains: "has\na few"
|
|
|
|
contains: "has\na few"
|
|
|
|
read_whole_file: false
|
|
|
|
read_whole_file: false
|
|
|
@ -214,7 +214,7 @@
|
|
|
|
block:
|
|
|
|
block:
|
|
|
|
- name: Get all files/directories in the path
|
|
|
|
- name: Get all files/directories in the path
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
paths: "{{ output_dir_test }}"
|
|
|
|
paths: "{{ remote_tmp_dir_test }}"
|
|
|
|
recurse: yes
|
|
|
|
recurse: yes
|
|
|
|
file_type: any
|
|
|
|
file_type: any
|
|
|
|
register: total_contents
|
|
|
|
register: total_contents
|
|
|
@ -226,7 +226,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- name: Get files and directories with depth
|
|
|
|
- name: Get files and directories with depth
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
paths: "{{ output_dir_test }}"
|
|
|
|
paths: "{{ remote_tmp_dir_test }}"
|
|
|
|
recurse: yes
|
|
|
|
recurse: yes
|
|
|
|
file_type: any
|
|
|
|
file_type: any
|
|
|
|
depth: 2
|
|
|
|
depth: 2
|
|
|
@ -241,7 +241,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- name: Find files with depth
|
|
|
|
- name: Find files with depth
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
paths: "{{ output_dir_test }}"
|
|
|
|
paths: "{{ remote_tmp_dir_test }}"
|
|
|
|
depth: 2
|
|
|
|
depth: 2
|
|
|
|
recurse: yes
|
|
|
|
recurse: yes
|
|
|
|
register: files_with_depth
|
|
|
|
register: files_with_depth
|
|
|
@ -254,7 +254,7 @@
|
|
|
|
- files_with_depth.examined == 12
|
|
|
|
- files_with_depth.examined == 12
|
|
|
|
- name: exclude with regex
|
|
|
|
- name: exclude with regex
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
paths: "{{ output_dir_test }}"
|
|
|
|
paths: "{{ remote_tmp_dir_test }}"
|
|
|
|
recurse: yes
|
|
|
|
recurse: yes
|
|
|
|
use_regex: true
|
|
|
|
use_regex: true
|
|
|
|
exclude: .*\.ogg
|
|
|
|
exclude: .*\.ogg
|
|
|
@ -266,32 +266,32 @@
|
|
|
|
- name: assert we skipped the ogg file
|
|
|
|
- name: assert we skipped the ogg file
|
|
|
|
assert:
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
that:
|
|
|
|
- '"{{ output_dir_test }}/e/f/g/h/8.ogg" not in find_test3_list'
|
|
|
|
- '"{{ remote_tmp_dir_test }}/e/f/g/h/8.ogg" not in find_test3_list'
|
|
|
|
|
|
|
|
|
|
|
|
- name: create our age/size testing sub-directory
|
|
|
|
- name: create our age/size testing sub-directory
|
|
|
|
file:
|
|
|
|
file:
|
|
|
|
path: "{{ output_dir_test }}/astest"
|
|
|
|
path: "{{ remote_tmp_dir_test }}/astest"
|
|
|
|
state: directory
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
|
|
|
|
- name: create test file with old timestamps
|
|
|
|
- name: create test file with old timestamps
|
|
|
|
file:
|
|
|
|
file:
|
|
|
|
path: "{{ output_dir_test }}/astest/old.txt"
|
|
|
|
path: "{{ remote_tmp_dir_test }}/astest/old.txt"
|
|
|
|
state: touch
|
|
|
|
state: touch
|
|
|
|
modification_time: "202001011200.0"
|
|
|
|
modification_time: "202001011200.0"
|
|
|
|
|
|
|
|
|
|
|
|
- name: create test file with current timestamps
|
|
|
|
- name: create test file with current timestamps
|
|
|
|
file:
|
|
|
|
file:
|
|
|
|
path: "{{ output_dir_test }}/astest/new.txt"
|
|
|
|
path: "{{ remote_tmp_dir_test }}/astest/new.txt"
|
|
|
|
state: touch
|
|
|
|
state: touch
|
|
|
|
|
|
|
|
|
|
|
|
- name: create hidden test file with current timestamps
|
|
|
|
- name: create hidden test file with current timestamps
|
|
|
|
file:
|
|
|
|
file:
|
|
|
|
path: "{{ output_dir_test }}/astest/.hidden.txt"
|
|
|
|
path: "{{ remote_tmp_dir_test }}/astest/.hidden.txt"
|
|
|
|
state: touch
|
|
|
|
state: touch
|
|
|
|
|
|
|
|
|
|
|
|
- name: find files older than 1 week
|
|
|
|
- name: find files older than 1 week
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
path: "{{ output_dir_test }}/astest"
|
|
|
|
path: "{{ remote_tmp_dir_test }}/astest"
|
|
|
|
age: 1w
|
|
|
|
age: 1w
|
|
|
|
hidden: true
|
|
|
|
hidden: true
|
|
|
|
register: result
|
|
|
|
register: result
|
|
|
@ -303,11 +303,11 @@
|
|
|
|
assert:
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
that:
|
|
|
|
- result.matched == 1
|
|
|
|
- result.matched == 1
|
|
|
|
- '"{{ output_dir_test }}/astest/old.txt" in astest_list'
|
|
|
|
- '"{{ remote_tmp_dir_test }}/astest/old.txt" in astest_list'
|
|
|
|
|
|
|
|
|
|
|
|
- name: find files newer than 1 week
|
|
|
|
- name: find files newer than 1 week
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
path: "{{ output_dir_test }}/astest"
|
|
|
|
path: "{{ remote_tmp_dir_test }}/astest"
|
|
|
|
age: -1w
|
|
|
|
age: -1w
|
|
|
|
register: result
|
|
|
|
register: result
|
|
|
|
|
|
|
|
|
|
|
@ -318,14 +318,14 @@
|
|
|
|
assert:
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
that:
|
|
|
|
- result.matched == 1
|
|
|
|
- result.matched == 1
|
|
|
|
- '"{{ output_dir_test }}/astest/new.txt" in astest_list'
|
|
|
|
- '"{{ remote_tmp_dir_test }}/astest/new.txt" in astest_list'
|
|
|
|
|
|
|
|
|
|
|
|
- name: add some content to the new file
|
|
|
|
- name: add some content to the new file
|
|
|
|
shell: "echo hello world > {{ output_dir_test }}/astest/new.txt"
|
|
|
|
shell: "echo hello world > {{ remote_tmp_dir_test }}/astest/new.txt"
|
|
|
|
|
|
|
|
|
|
|
|
- name: find files with MORE than 5 bytes, also get checksums
|
|
|
|
- name: find files with MORE than 5 bytes, also get checksums
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
path: "{{ output_dir_test }}/astest"
|
|
|
|
path: "{{ remote_tmp_dir_test }}/astest"
|
|
|
|
size: 5
|
|
|
|
size: 5
|
|
|
|
hidden: true
|
|
|
|
hidden: true
|
|
|
|
get_checksum: true
|
|
|
|
get_checksum: true
|
|
|
@ -338,12 +338,12 @@
|
|
|
|
assert:
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
that:
|
|
|
|
- result.matched == 1
|
|
|
|
- result.matched == 1
|
|
|
|
- '"{{ output_dir_test }}/astest/new.txt" in astest_list'
|
|
|
|
- '"{{ remote_tmp_dir_test }}/astest/new.txt" in astest_list'
|
|
|
|
- '"checksum" in result.files[0]'
|
|
|
|
- '"checksum" in result.files[0]'
|
|
|
|
|
|
|
|
|
|
|
|
- name: find ANY item with LESS than 5 bytes, also get checksums
|
|
|
|
- name: find ANY item with LESS than 5 bytes, also get checksums
|
|
|
|
find:
|
|
|
|
find:
|
|
|
|
path: "{{ output_dir_test }}/astest"
|
|
|
|
path: "{{ remote_tmp_dir_test }}/astest"
|
|
|
|
size: -5
|
|
|
|
size: -5
|
|
|
|
hidden: true
|
|
|
|
hidden: true
|
|
|
|
get_checksum: true
|
|
|
|
get_checksum: true
|
|
|
@ -357,6 +357,6 @@
|
|
|
|
assert:
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
that:
|
|
|
|
- result.matched == 2
|
|
|
|
- result.matched == 2
|
|
|
|
- '"{{ output_dir_test }}/astest/old.txt" in astest_list'
|
|
|
|
- '"{{ remote_tmp_dir_test }}/astest/old.txt" in astest_list'
|
|
|
|
- '"{{ output_dir_test }}/astest/.hidden.txt" in astest_list'
|
|
|
|
- '"{{ remote_tmp_dir_test }}/astest/.hidden.txt" in astest_list'
|
|
|
|
- '"checksum" in result.files[0]'
|
|
|
|
- '"checksum" in result.files[0]'
|
|
|
|