Improve inventory to make deployment targets definable
Change-Id: Ib83479773b8a8024c40c0dac36ded2b0ff2747c4
diff --git a/deploy-kalamar-plugin-externalresources.yml b/deploy-kalamar-plugin-externalresources.yml
index d77ef5d..64aebcc 100644
--- a/deploy-kalamar-plugin-externalresources.yml
+++ b/deploy-kalamar-plugin-externalresources.yml
@@ -1,21 +1,17 @@
- name: Deploy Kalamar-Plugin-ExternalResources
hosts:
- test-instance
- user: korap
+ - test
+ - main
serial: 1
+ run_once: true
tasks:
- - name: Set instance
- set_fact:
- instance_path: "/opt/korap/instance-test/Kalamar-External"
- instance_name: "kalamar-plugin-externalresources-test"
-
- name: Save docker image
local_action: ansible.builtin.command docker save korap/kalamar-plugin-externalresources:latest -o ./kalamar-plugin-externalresources-latest.tar
- name: Copy docker image to hosts
ansible.builtin.copy:
src: ./kalamar-plugin-externalresources-latest.tar
- dest: "{{ instance_path}}/kalamar-plugin-externalresources-latest.tar"
+ dest: "{{ external_path }}/kalamar-plugin-externalresources-latest.tar"
mode: '0644'
- name: Delete docker image tar
@@ -25,7 +21,7 @@
state: absent
- name: Load docker image on host
- ansible.builtin.command: "docker load -i {{ instance_path}}/kalamar-plugin-externalresources-latest.tar"
+ ansible.builtin.command: "docker load -i {{ external_path }}/kalamar-plugin-externalresources-latest.tar"
- name: Get UID for KorAP user
getent:
@@ -35,7 +31,7 @@
- name: Gracefully stop and remove old docker container, if existing
community.docker.docker_container:
state: "absent"
- name: "{{ instance_name }}"
+ name: "{{ external_container_name }}"
recreate: true
keep_volumes: true
comparisons:
@@ -46,16 +42,16 @@
image: korap/kalamar-plugin-externalresources:latest
restart_policy: "unless-stopped"
pull: false
- name: "{{ instance_name }}"
+ name: "{{ external_container_name }}"
user: "{{ ansible_facts.getent_passwd[\"korap\"].1 }}"
init: true
detach: true
mounts:
- type: bind
- source: "{{ instance_path }}/db"
+ source: "{{ external_path }}/db"
target: "/db"
- type: bind
- source: "{{ instance_path }}/.env"
+ source: "{{ external_path }}/.env"
target: "/.env"
ports:
- "5722:5722"