- name: Deploy Kalamar-Plugin-ExternalResources | |
hosts: | |
- test | |
- main | |
serial: 1 | |
run_once: true | |
tasks: | |
- name: Save docker image | |
local_action: ansible.builtin.command docker save {{ external_image }} -o ./kalamar-plugin-externalresources-latest.tar | |
- name: Copy docker image to hosts | |
ansible.builtin.copy: | |
src: ./kalamar-plugin-externalresources-latest.tar | |
dest: "{{ external_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 {{ external_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: | |
image: "{{ external_image }}" | |
state: "absent" | |
name: "{{ external_container_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: "{{ external_image }}" | |
restart_policy: "unless-stopped" | |
pull: false | |
name: "{{ external_container_name }}" | |
user: "{{ ansible_facts.getent_passwd[\"korap\"].1 }}" | |
init: true | |
detach: true | |
mounts: | |
- type: bind | |
source: "{{ external_path }}/db" | |
target: "/db" | |
- type: bind | |
source: "{{ external_path }}/.env" | |
target: "/.env" | |
ports: | |
- "{{ external_port }}" | |
comparisons: | |
image: ignore # do not restart containers with older versions of the image |