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