diff --git a/roles/apps/tasks/main.yml b/roles/apps/tasks/main.yml index 62e3f78..9f24c9a 100644 --- a/roles/apps/tasks/main.yml +++ b/roles/apps/tasks/main.yml @@ -30,3 +30,10 @@ app_name: "{{ item }}" app_vars: "{{ apps_vars[item] }}" loop: "{{ apps_include }}" + +- name: Copy deploy.sh + ansible.builtin.template: + src: scripts/deploy.sh.j2 + dest: /usr/local/bin/deploy.sh + owner: root + mode: u=rwx,g=rx,o=rx diff --git a/roles/apps/templates/scripts/deploy.sh.j2 b/roles/apps/templates/scripts/deploy.sh.j2 new file mode 100644 index 0000000..abd6f92 --- /dev/null +++ b/roles/apps/templates/scripts/deploy.sh.j2 @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# code: language=bash + +ARG="$1" +APPS_DIR="{{ apps_data_root }}" + +case $ARG in +start) + for app in $APPS_DIR/*; do + docker compose -f $app/docker-compose.yml up --remove-orphans -d + done + ;; +stop) + for app in $APPS_DIR/*; do + docker compose -f $app/docker-compose.yml down --remove-orphans + done + ;; +restart) + for app in $APPS_DIR/*; do + docker compose -f $app/docker-compose.yml restart + done + ;; +*) + echo "Unrecognized argument" + exit 1 + ;; +esac