Improve deploy script for externalresources
Change-Id: I6da45429ea1b82d73f0845e5925eeb37539dccf6
diff --git a/deploy-kalamar-plugin-externalresources.yml b/deploy-kalamar-plugin-externalresources.yml
index 549607e..d77ef5d 100644
--- a/deploy-kalamar-plugin-externalresources.yml
+++ b/deploy-kalamar-plugin-externalresources.yml
@@ -1,45 +1,61 @@
-- name: Deploy Kalamar-Plugin-ExternalResources to Test instance
+- name: Deploy Kalamar-Plugin-ExternalResources
hosts:
test-instance
user: korap
serial: 1
tasks:
+ - name: Set instance
+ set_fact:
+ instance_path: "/opt/korap/instance-test/Kalamar-External"
+ instance_name: "kalamar-plugin-externalresources-test"
+
- 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
+ dest: "{{ instance_path}}/kalamar-plugin-externalresources-latest.tar"
mode: '0644'
+
+ - name: Delete docker image tar
+ local_action:
+ module: ansible.builtin.file
+ path: ./kalamar-plugin-externalresources-latest.tar
+ state: absent
+
- name: Load docker image on host
- ansible.builtin.command: docker load -i /opt/korap/instance-test/Kalamar-External/kalamar-plugin-externalresources-latest.tar
+ ansible.builtin.command: "docker load -i {{ instance_path}}/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
+ name: "{{ instance_name }}"
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
+ name: "{{ instance_name }}"
user: "{{ ansible_facts.getent_passwd[\"korap\"].1 }}"
init: true
detach: true
mounts:
- type: bind
- source: "/opt/korap/instance-test/Kalamar-External/db"
+ source: "{{ instance_path }}/db"
target: "/db"
- type: bind
- source: "/opt/korap/instance-test/Kalamar-External/.env"
+ source: "{{ instance_path }}/.env"
target: "/.env"
ports:
- "5722:5722"