Add Krawfish Playbook

Change-Id: I7f7439b362284c9022364daed2a178ac1af00391
diff --git a/ansible.cfg b/ansible.cfg
new file mode 100644
index 0000000..aef1d29
--- /dev/null
+++ b/ansible.cfg
@@ -0,0 +1,2 @@
+[defaults]
+INVENTORY = inventory
\ No newline at end of file
diff --git a/deploy-krawfish.yml b/deploy-krawfish.yml
new file mode 100644
index 0000000..90d2485
--- /dev/null
+++ b/deploy-krawfish.yml
@@ -0,0 +1,56 @@
+- name: Deploy Krawfish
+  hosts:
+    10.0.10.57
+    10.0.10.58
+    10.0.10.59
+  user: korap
+  serial: 1
+  tasks:
+    - name: Save docker image
+      local_action: ansible.builtin.command docker save korap/krawfish:latest -o ./krawfish-latest.tar
+    - name: Copy docker image to hosts
+      ansible.builtin.copy:
+        src: ./krawfish-latest.tar
+        dest: /opt/korap/krawfish/krawfish-latest.tar
+        mode: '0644'
+    - name: Load docker images on hosts
+      ansible.builtin.command: docker load -i /opt/korap/krawfish/krawfish-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: krawfish
+        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/krawfish:latest
+        restart_policy: "unless-stopped"
+        # pull: true
+        name: krawfish
+        user: "{{ ansible_facts.getent_passwd[\"korap\"].1 }}"
+        init: true
+        detach: true
+        mounts:
+          - type: bind
+            source: "/opt/korap/krawfish/log"
+            target: "/log"
+          - type: bind
+            source: "/opt/korap/krawfish/index"
+            target: "/index"
+          - type: bind
+            read_only: true
+            source: "/opt/korap/krawfish/conf.yml"
+            target: "/conf.yml"
+        ports:
+          - "9328:9328"
+          - "9329:9329"
+          - "9587:9587"
+        command: ["-c", "conf.yml"]
+        comparisons:
+          image: ignore   # do not restart containers with older versions of the image
diff --git a/inventory b/inventory
new file mode 100644
index 0000000..984d502
--- /dev/null
+++ b/inventory
@@ -0,0 +1,7 @@
+[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