blob: 64aebcc6c454250951078f4d53485bc0d1260f30 [file] [log] [blame]
Akrone53ef3a2024-03-19 11:27:11 +01001- name: Deploy Kalamar-Plugin-ExternalResources
Akrona79b6ff2024-03-15 12:32:44 +01002 hosts:
Akron6c26c6a2024-03-19 14:19:53 +01003 - test
4 - main
Akrona79b6ff2024-03-15 12:32:44 +01005 serial: 1
Akron6c26c6a2024-03-19 14:19:53 +01006 run_once: true
Akrona79b6ff2024-03-15 12:32:44 +01007 tasks:
8 - name: Save docker image
9 local_action: ansible.builtin.command docker save korap/kalamar-plugin-externalresources:latest -o ./kalamar-plugin-externalresources-latest.tar
Akrone53ef3a2024-03-19 11:27:11 +010010
Akrona79b6ff2024-03-15 12:32:44 +010011 - name: Copy docker image to hosts
12 ansible.builtin.copy:
13 src: ./kalamar-plugin-externalresources-latest.tar
Akron6c26c6a2024-03-19 14:19:53 +010014 dest: "{{ external_path }}/kalamar-plugin-externalresources-latest.tar"
Akrona79b6ff2024-03-15 12:32:44 +010015 mode: '0644'
Akrone53ef3a2024-03-19 11:27:11 +010016
17 - name: Delete docker image tar
18 local_action:
19 module: ansible.builtin.file
20 path: ./kalamar-plugin-externalresources-latest.tar
21 state: absent
22
Akrona79b6ff2024-03-15 12:32:44 +010023 - name: Load docker image on host
Akron6c26c6a2024-03-19 14:19:53 +010024 ansible.builtin.command: "docker load -i {{ external_path }}/kalamar-plugin-externalresources-latest.tar"
Akrone53ef3a2024-03-19 11:27:11 +010025
Akrona79b6ff2024-03-15 12:32:44 +010026 - name: Get UID for KorAP user
27 getent:
28 database: passwd
29 key: korap
Akrone53ef3a2024-03-19 11:27:11 +010030
Akrona79b6ff2024-03-15 12:32:44 +010031 - name: Gracefully stop and remove old docker container, if existing
32 community.docker.docker_container:
33 state: "absent"
Akron6c26c6a2024-03-19 14:19:53 +010034 name: "{{ external_container_name }}"
Akrona79b6ff2024-03-15 12:32:44 +010035 recreate: true
36 keep_volumes: true
37 comparisons:
38 image: ignore # do not restart containers with older versions of the image
Akrone53ef3a2024-03-19 11:27:11 +010039
Akrona79b6ff2024-03-15 12:32:44 +010040 - name: Restart docker container
41 community.docker.docker_container:
42 image: korap/kalamar-plugin-externalresources:latest
43 restart_policy: "unless-stopped"
44 pull: false
Akron6c26c6a2024-03-19 14:19:53 +010045 name: "{{ external_container_name }}"
Akrona79b6ff2024-03-15 12:32:44 +010046 user: "{{ ansible_facts.getent_passwd[\"korap\"].1 }}"
47 init: true
48 detach: true
49 mounts:
50 - type: bind
Akron6c26c6a2024-03-19 14:19:53 +010051 source: "{{ external_path }}/db"
Akrona79b6ff2024-03-15 12:32:44 +010052 target: "/db"
53 - type: bind
Akron6c26c6a2024-03-19 14:19:53 +010054 source: "{{ external_path }}/.env"
Akrona79b6ff2024-03-15 12:32:44 +010055 target: "/.env"
56 ports:
57 - "5722:5722"
58 comparisons:
59 image: ignore # do not restart containers with older versions of the image