blob: d77ef5d18591267c90aa8de133f09bad196694f6 [file] [log] [blame]
Akrone53ef3a2024-03-19 11:27:11 +01001- name: Deploy Kalamar-Plugin-ExternalResources
Akrona79b6ff2024-03-15 12:32:44 +01002 hosts:
3 test-instance
4 user: korap
5 serial: 1
6 tasks:
Akrone53ef3a2024-03-19 11:27:11 +01007 - name: Set instance
8 set_fact:
9 instance_path: "/opt/korap/instance-test/Kalamar-External"
10 instance_name: "kalamar-plugin-externalresources-test"
11
Akrona79b6ff2024-03-15 12:32:44 +010012 - name: Save docker image
13 local_action: ansible.builtin.command docker save korap/kalamar-plugin-externalresources:latest -o ./kalamar-plugin-externalresources-latest.tar
Akrone53ef3a2024-03-19 11:27:11 +010014
Akrona79b6ff2024-03-15 12:32:44 +010015 - name: Copy docker image to hosts
16 ansible.builtin.copy:
17 src: ./kalamar-plugin-externalresources-latest.tar
Akrone53ef3a2024-03-19 11:27:11 +010018 dest: "{{ instance_path}}/kalamar-plugin-externalresources-latest.tar"
Akrona79b6ff2024-03-15 12:32:44 +010019 mode: '0644'
Akrone53ef3a2024-03-19 11:27:11 +010020
21 - name: Delete docker image tar
22 local_action:
23 module: ansible.builtin.file
24 path: ./kalamar-plugin-externalresources-latest.tar
25 state: absent
26
Akrona79b6ff2024-03-15 12:32:44 +010027 - name: Load docker image on host
Akrone53ef3a2024-03-19 11:27:11 +010028 ansible.builtin.command: "docker load -i {{ instance_path}}/kalamar-plugin-externalresources-latest.tar"
29
Akrona79b6ff2024-03-15 12:32:44 +010030 - name: Get UID for KorAP user
31 getent:
32 database: passwd
33 key: korap
Akrone53ef3a2024-03-19 11:27:11 +010034
Akrona79b6ff2024-03-15 12:32:44 +010035 - name: Gracefully stop and remove old docker container, if existing
36 community.docker.docker_container:
37 state: "absent"
Akrone53ef3a2024-03-19 11:27:11 +010038 name: "{{ instance_name }}"
Akrona79b6ff2024-03-15 12:32:44 +010039 recreate: true
40 keep_volumes: true
41 comparisons:
42 image: ignore # do not restart containers with older versions of the image
Akrone53ef3a2024-03-19 11:27:11 +010043
Akrona79b6ff2024-03-15 12:32:44 +010044 - name: Restart docker container
45 community.docker.docker_container:
46 image: korap/kalamar-plugin-externalresources:latest
47 restart_policy: "unless-stopped"
48 pull: false
Akrone53ef3a2024-03-19 11:27:11 +010049 name: "{{ instance_name }}"
Akrona79b6ff2024-03-15 12:32:44 +010050 user: "{{ ansible_facts.getent_passwd[\"korap\"].1 }}"
51 init: true
52 detach: true
53 mounts:
54 - type: bind
Akrone53ef3a2024-03-19 11:27:11 +010055 source: "{{ instance_path }}/db"
Akrona79b6ff2024-03-15 12:32:44 +010056 target: "/db"
57 - type: bind
Akrone53ef3a2024-03-19 11:27:11 +010058 source: "{{ instance_path }}/.env"
Akrona79b6ff2024-03-15 12:32:44 +010059 target: "/.env"
60 ports:
61 - "5722:5722"
62 comparisons:
63 image: ignore # do not restart containers with older versions of the image