Akron | c607238 | 2023-11-07 12:54:54 +0100 | [diff] [blame] | 1 | - name: Deploy Krawfish |
| 2 | hosts: |
Akron | 643c2a0 | 2024-08-07 13:47:41 +0200 | [diff] [blame^] | 3 | - krawfish |
Akron | c607238 | 2023-11-07 12:54:54 +0100 | [diff] [blame] | 4 | user: korap |
| 5 | serial: 1 |
| 6 | tasks: |
| 7 | - name: Save docker image |
| 8 | local_action: ansible.builtin.command docker save korap/krawfish:latest -o ./krawfish-latest.tar |
| 9 | - name: Copy docker image to hosts |
| 10 | ansible.builtin.copy: |
| 11 | src: ./krawfish-latest.tar |
| 12 | dest: /opt/korap/krawfish/krawfish-latest.tar |
| 13 | mode: '0644' |
| 14 | - name: Load docker images on hosts |
| 15 | ansible.builtin.command: docker load -i /opt/korap/krawfish/krawfish-latest.tar |
| 16 | - name: Get UID for KorAP user |
| 17 | getent: |
| 18 | database: passwd |
| 19 | key: korap |
| 20 | - name: Gracefully stop and remove old docker container, if existing |
| 21 | community.docker.docker_container: |
| 22 | state: "absent" |
| 23 | name: krawfish |
| 24 | recreate: true |
| 25 | keep_volumes: true |
| 26 | comparisons: |
| 27 | image: ignore # do not restart containers with older versions of the image |
| 28 | - name: Restart docker container |
| 29 | community.docker.docker_container: |
| 30 | image: korap/krawfish:latest |
| 31 | restart_policy: "unless-stopped" |
| 32 | # pull: true |
| 33 | name: krawfish |
| 34 | user: "{{ ansible_facts.getent_passwd[\"korap\"].1 }}" |
| 35 | init: true |
| 36 | detach: true |
Akron | 6eb7147 | 2023-11-09 20:51:44 +0100 | [diff] [blame] | 37 | network_mode: "host" |
Akron | c607238 | 2023-11-07 12:54:54 +0100 | [diff] [blame] | 38 | mounts: |
| 39 | - type: bind |
| 40 | source: "/opt/korap/krawfish/log" |
| 41 | target: "/log" |
| 42 | - type: bind |
| 43 | source: "/opt/korap/krawfish/index" |
| 44 | target: "/index" |
| 45 | - type: bind |
| 46 | read_only: true |
| 47 | source: "/opt/korap/krawfish/conf.yml" |
| 48 | target: "/conf.yml" |
| 49 | ports: |
| 50 | - "9328:9328" |
| 51 | - "9329:9329" |
| 52 | - "9587:9587" |
| 53 | command: ["-c", "conf.yml"] |
| 54 | comparisons: |
| 55 | image: ignore # do not restart containers with older versions of the image |