blob: 95d83227bb190d32ab4dd66117373b81136cfa05 [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
Akron700679f2024-03-19 16:41:36 +01009 local_action: ansible.builtin.command docker save {{ external_image }} -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:
Akron700679f2024-03-19 16:41:36 +010033 image: "{{ external_image }}"
Akrona79b6ff2024-03-15 12:32:44 +010034 state: "absent"
Akron6c26c6a2024-03-19 14:19:53 +010035 name: "{{ external_container_name }}"
Akrona79b6ff2024-03-15 12:32:44 +010036 recreate: true
37 keep_volumes: true
38 comparisons:
39 image: ignore # do not restart containers with older versions of the image
Akrone53ef3a2024-03-19 11:27:11 +010040
Akrona79b6ff2024-03-15 12:32:44 +010041 - name: Restart docker container
42 community.docker.docker_container:
Akron700679f2024-03-19 16:41:36 +010043 image: "{{ external_image }}"
Akrona79b6ff2024-03-15 12:32:44 +010044 restart_policy: "unless-stopped"
45 pull: false
Akron6c26c6a2024-03-19 14:19:53 +010046 name: "{{ external_container_name }}"
Akrona79b6ff2024-03-15 12:32:44 +010047 user: "{{ ansible_facts.getent_passwd[\"korap\"].1 }}"
48 init: true
49 detach: true
50 mounts:
51 - type: bind
Akron6c26c6a2024-03-19 14:19:53 +010052 source: "{{ external_path }}/db"
Akrona79b6ff2024-03-15 12:32:44 +010053 target: "/db"
54 - type: bind
Akron6c26c6a2024-03-19 14:19:53 +010055 source: "{{ external_path }}/.env"
Akrona79b6ff2024-03-15 12:32:44 +010056 target: "/.env"
57 ports:
Akron700679f2024-03-19 16:41:36 +010058 - "{{ external_port }}"
Akrona79b6ff2024-03-15 12:32:44 +010059 comparisons:
60 image: ignore # do not restart containers with older versions of the image