- name: List DeReKo-KorAP Releases | |
hosts: worker-03 | |
run_once: true | |
tasks: | |
- name: Get current year | |
set_fact: | |
current_year: "{{ ansible_date_time.year }}" | |
- name: Receive new relevant list from database | |
community.mysql.mysql_query: | |
login_host: klinux10 | |
login_db: corpora | |
login_user: viewer | |
query: > | |
SELECT concat('/vol/corpora/DeReKo/incoming/KorAP/zip/', replace(name,'.i5.xml','.zip')) as cname | |
FROM fileMeta{{ current_year }}I, basename | |
WHERE (fileMeta{{ current_year }}I.name LIKE 'pp-%' or fileMeta{{ current_year }}I.rsr = 1 or | |
(fileMeta{{ current_year }}I.name like '%2_.i5.xml' and (basename.rsr=1 or basename.inkorap=1))) and | |
fileMeta{{ current_year }}I.base=basename.id | |
ORDER by name | |
register: sqlresult | |
- name: Find all changed from the last 200 days | |
ansible.builtin.find: | |
paths: | |
- "/vol/corpora/DeReKo/incoming/KorAP/zip/" | |
age: "-200d" | |
age_stamp: "mtime" | |
use_regex: true | |
follow: true | |
file_type: "any" | |
patterns: | |
- "^[^\\.]*\\.zip$" | |
register: newfiles | |
- name: Compare both lists and show intersection | |
ansible.legacy.copy: | |
content: "{{ newfiles.files | map(attribute='path') | sort() | intersect( sqlresult.query_result[0] | map(attribute='cname') ) | join('\n') }}" | |
dest: dereko-ingestion.txt | |
delegate_to: localhost |