Merge "Ignore everything other than playbooks"
diff --git a/deploy-kalamar-plugin-externalresources.yml b/deploy-kalamar-plugin-externalresources.yml
new file mode 100644
index 0000000..549607e
--- /dev/null
+++ b/deploy-kalamar-plugin-externalresources.yml
@@ -0,0 +1,47 @@
+- name: Deploy Kalamar-Plugin-ExternalResources to Test instance
+  hosts:
+    test-instance
+  user: korap
+  serial: 1
+  tasks:
+    - name: Save docker image
+      local_action: ansible.builtin.command docker save korap/kalamar-plugin-externalresources:latest -o ./kalamar-plugin-externalresources-latest.tar
+    - name: Copy docker image to hosts
+      ansible.builtin.copy:
+        src: ./kalamar-plugin-externalresources-latest.tar
+        dest: /opt/korap/instance-test/Kalamar-External/kalamar-plugin-externalresources-latest.tar
+        mode: '0644'
+    - name: Load docker image on host
+      ansible.builtin.command: docker load -i /opt/korap/instance-test/Kalamar-External/kalamar-plugin-externalresources-latest.tar
+    - name: Get UID for KorAP user
+      getent:
+        database: passwd
+        key: korap
+    - name: Gracefully stop and remove old docker container, if existing
+      community.docker.docker_container:
+        state: "absent"
+        name: kalamar-plugin-externalresources-test
+        recreate: true
+        keep_volumes: true
+        comparisons:
+          image: ignore   # do not restart containers with older versions of the image
+    - name: Restart docker container
+      community.docker.docker_container:
+        image: korap/kalamar-plugin-externalresources:latest
+        restart_policy: "unless-stopped"
+        pull: false
+        name: kalamar-plugin-externalresources-test
+        user: "{{ ansible_facts.getent_passwd[\"korap\"].1 }}"
+        init: true
+        detach: true
+        mounts:
+          - type: bind
+            source: "/opt/korap/instance-test/Kalamar-External/db"
+            target: "/db"
+          - type: bind
+            source: "/opt/korap/instance-test/Kalamar-External/.env"
+            target: "/.env"
+        ports:
+          - "5722:5722"
+        comparisons:
+          image: ignore   # do not restart containers with older versions of the image
diff --git a/inventory b/inventory
index 984d502..785727d 100644
--- a/inventory
+++ b/inventory
@@ -1,7 +1,25 @@
+[korap]
+10.0.10.55
+
+[main-instance]
+10.0.10.51
+
+[test-instance]
+10.0.10.52
+
 [krawfish]
 10.0.10.57
 10.0.10.58
 10.0.10.59
 
 [krawfish:vars]
-ansible_python_interpreter=/usr/bin/python3
\ No newline at end of file
+ansible_python_interpreter=/usr/bin/python3
+
+[korap:vars]
+ansible_python_interpreter=/usr/bin/python3
+
+[main-instance:vars]
+ansible_python_interpreter=/usr/bin/python3
+
+[test-instance:vars]
+ansible_python_interpreter=/usr/bin/python3
diff --git a/list-dereko-korap-release.yml b/list-dereko-korap-release.yml
new file mode 100644
index 0000000..4bbffb6
--- /dev/null
+++ b/list-dereko-korap-release.yml
@@ -0,0 +1,40 @@
+- name: List DeReKo-KorAP Releases
+  hosts: 10.0.10.55
+  user: korap
+  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