Akron | e53ef3a | 2024-03-19 11:27:11 +0100 | [diff] [blame^] | 1 | - name: Deploy Kalamar-Plugin-ExternalResources |
Akron | a79b6ff | 2024-03-15 12:32:44 +0100 | [diff] [blame] | 2 | hosts: |
| 3 | test-instance |
| 4 | user: korap |
| 5 | serial: 1 |
| 6 | tasks: |
Akron | e53ef3a | 2024-03-19 11:27:11 +0100 | [diff] [blame^] | 7 | - name: Set instance |
| 8 | set_fact: |
| 9 | instance_path: "/opt/korap/instance-test/Kalamar-External" |
| 10 | instance_name: "kalamar-plugin-externalresources-test" |
| 11 | |
Akron | a79b6ff | 2024-03-15 12:32:44 +0100 | [diff] [blame] | 12 | - name: Save docker image |
| 13 | local_action: ansible.builtin.command docker save korap/kalamar-plugin-externalresources:latest -o ./kalamar-plugin-externalresources-latest.tar |
Akron | e53ef3a | 2024-03-19 11:27:11 +0100 | [diff] [blame^] | 14 | |
Akron | a79b6ff | 2024-03-15 12:32:44 +0100 | [diff] [blame] | 15 | - name: Copy docker image to hosts |
| 16 | ansible.builtin.copy: |
| 17 | src: ./kalamar-plugin-externalresources-latest.tar |
Akron | e53ef3a | 2024-03-19 11:27:11 +0100 | [diff] [blame^] | 18 | dest: "{{ instance_path}}/kalamar-plugin-externalresources-latest.tar" |
Akron | a79b6ff | 2024-03-15 12:32:44 +0100 | [diff] [blame] | 19 | mode: '0644' |
Akron | e53ef3a | 2024-03-19 11:27:11 +0100 | [diff] [blame^] | 20 | |
| 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 | |
Akron | a79b6ff | 2024-03-15 12:32:44 +0100 | [diff] [blame] | 27 | - name: Load docker image on host |
Akron | e53ef3a | 2024-03-19 11:27:11 +0100 | [diff] [blame^] | 28 | ansible.builtin.command: "docker load -i {{ instance_path}}/kalamar-plugin-externalresources-latest.tar" |
| 29 | |
Akron | a79b6ff | 2024-03-15 12:32:44 +0100 | [diff] [blame] | 30 | - name: Get UID for KorAP user |
| 31 | getent: |
| 32 | database: passwd |
| 33 | key: korap |
Akron | e53ef3a | 2024-03-19 11:27:11 +0100 | [diff] [blame^] | 34 | |
Akron | a79b6ff | 2024-03-15 12:32:44 +0100 | [diff] [blame] | 35 | - name: Gracefully stop and remove old docker container, if existing |
| 36 | community.docker.docker_container: |
| 37 | state: "absent" |
Akron | e53ef3a | 2024-03-19 11:27:11 +0100 | [diff] [blame^] | 38 | name: "{{ instance_name }}" |
Akron | a79b6ff | 2024-03-15 12:32:44 +0100 | [diff] [blame] | 39 | recreate: true |
| 40 | keep_volumes: true |
| 41 | comparisons: |
| 42 | image: ignore # do not restart containers with older versions of the image |
Akron | e53ef3a | 2024-03-19 11:27:11 +0100 | [diff] [blame^] | 43 | |
Akron | a79b6ff | 2024-03-15 12:32:44 +0100 | [diff] [blame] | 44 | - name: Restart docker container |
| 45 | community.docker.docker_container: |
| 46 | image: korap/kalamar-plugin-externalresources:latest |
| 47 | restart_policy: "unless-stopped" |
| 48 | pull: false |
Akron | e53ef3a | 2024-03-19 11:27:11 +0100 | [diff] [blame^] | 49 | name: "{{ instance_name }}" |
Akron | a79b6ff | 2024-03-15 12:32:44 +0100 | [diff] [blame] | 50 | user: "{{ ansible_facts.getent_passwd[\"korap\"].1 }}" |
| 51 | init: true |
| 52 | detach: true |
| 53 | mounts: |
| 54 | - type: bind |
Akron | e53ef3a | 2024-03-19 11:27:11 +0100 | [diff] [blame^] | 55 | source: "{{ instance_path }}/db" |
Akron | a79b6ff | 2024-03-15 12:32:44 +0100 | [diff] [blame] | 56 | target: "/db" |
| 57 | - type: bind |
Akron | e53ef3a | 2024-03-19 11:27:11 +0100 | [diff] [blame^] | 58 | source: "{{ instance_path }}/.env" |
Akron | a79b6ff | 2024-03-15 12:32:44 +0100 | [diff] [blame] | 59 | target: "/.env" |
| 60 | ports: |
| 61 | - "5722:5722" |
| 62 | comparisons: |
| 63 | image: ignore # do not restart containers with older versions of the image |