-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_finder.yml
40 lines (35 loc) · 1.03 KB
/
file_finder.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
- name: Find stuff
hosts: localhost
connection: local
gather_facts: False
tasks:
- name: Find all files
find:
file_type: file
hidden: True
recurse: True
paths: ..
register: files
- name: Extract file names
set_fact:
file_names: "{{ file_names | default([]) + [ item.path ] }}"
loop: "{{ files.files }}"
loop_control:
label: "{{ item.path }}"
when:
- "'/.git/' not in item.path"
- "'/project/' not in item.path"
register: all_file_names
- name: Get names of modified/new files in project
shell:
cmd: "git status --short | cut -c4-"
register: modified_project_files
- name: Extract file content
set_fact:
file_content: "{{ file_content | default({}) | combine({ item.path: lookup('file', item) }) }}"
loop: "{{ all_file_names + modified_project_files.stdout_lines | default([]) }}"
- name: Set job stats
set_stats:
data:
files: "{{ file_content }}"