Generate OKK/Ratskorpus VC from database
Change-Id: I8041f3413fc2184b134ddb83f113f9bb0819c5e8
diff --git a/generate-okk-vc.yml b/generate-okk-vc.yml
new file mode 100644
index 0000000..6271f7d
--- /dev/null
+++ b/generate-okk-vc.yml
@@ -0,0 +1,34 @@
+- name: generate-okk-vc
+ hosts: worker-03
+ run_once: true
+ tasks:
+ - name: Get current year
+ set_fact:
+ current_year: "{{ ansible_date_time.year }}"
+
+ - name: Receive OKK list from database
+ community.mysql.mysql_query:
+ login_host: klinux10
+ login_db: corpora
+ login_user: viewer
+ query: >
+ SELECT upper(replace(name,'.i5.xml','')) as sname
+ FROM fileMeta{{ current_year }}I, basename
+ WHERE fileMeta{{ current_year }}I.base=basename.id
+ AND basename.rsr
+ AND fileMeta{{ current_year }}I.name NOT REGEXP '([4-8][0-9]|90|91|92|93|94)'
+ ORDER BY sname;
+ register: sqlresult
+
+ - name: Convert result to KoralQuery
+ ansible.builtin.command:
+ cmd: "cosmasvc2koralquery -" # | gzip -vc
+ stdin: "{{ sqlresult.query_result[0] | map(attribute='sname') | join('\n') }}"
+ stdin_add_newline: true
+ register: generated_vc
+
+ - name: Copy KoralQuery to localhost
+ ansible.legacy.copy:
+ content: "{{ generated_vc.stdout }}"
+ dest: ratskorpus-{{ current_year }}.jsonld
+ delegate_to: localhost