blob: 6271f7d2ef50ef9caeeacfa6871a8ad6b01c6832 [file] [log] [blame]
Akronaf896512024-04-10 12:40:19 +02001- name: generate-okk-vc
2 hosts: worker-03
3 run_once: true
4 tasks:
5 - name: Get current year
6 set_fact:
7 current_year: "{{ ansible_date_time.year }}"
8
9 - name: Receive OKK list from database
10 community.mysql.mysql_query:
11 login_host: klinux10
12 login_db: corpora
13 login_user: viewer
14 query: >
15 SELECT upper(replace(name,'.i5.xml','')) as sname
16 FROM fileMeta{{ current_year }}I, basename
17 WHERE fileMeta{{ current_year }}I.base=basename.id
18 AND basename.rsr
19 AND fileMeta{{ current_year }}I.name NOT REGEXP '([4-8][0-9]|90|91|92|93|94)'
20 ORDER BY sname;
21 register: sqlresult
22
23 - name: Convert result to KoralQuery
24 ansible.builtin.command:
25 cmd: "cosmasvc2koralquery -" # | gzip -vc
26 stdin: "{{ sqlresult.query_result[0] | map(attribute='sname') | join('\n') }}"
27 stdin_add_newline: true
28 register: generated_vc
29
30 - name: Copy KoralQuery to localhost
31 ansible.legacy.copy:
32 content: "{{ generated_vc.stdout }}"
33 dest: ratskorpus-{{ current_year }}.jsonld
34 delegate_to: localhost