test fix cd multiple hosts

This commit is contained in:
Matt Reeves 2025-02-14 02:40:09 -05:00
parent 41d91e3cc3
commit e54adf5b2b
2 changed files with 34 additions and 23 deletions
.forgejo/workflows
ansible/playbooks

View file

@ -36,71 +36,82 @@ jobs:
shell: bash shell: bash
run: | run: |
IFS=' ' read -r -a folder_array <<< "${{ steps.detect-changes.outputs.folders }}" IFS=' ' read -r -a folder_array <<< "${{ steps.detect-changes.outputs.folders }}"
hosts=""
folders=""
for folder in "${folder_array[@]}"; do for folder in "${folder_array[@]}"; do
case $folder in case $folder in
actual) actual)
target_host="ubu.lan" host="ubu.lan"
;; ;;
arrs) arrs)
target_host="arrs.lan" host="arrs.lan"
;; ;;
arm) arm)
target_host="arm.lan" host="arm.lan"
;; ;;
AI) AI)
target_host="ai.lan" host="ai.lan"
;; ;;
authentik) authentik)
target_host="auth.lan" host="auth.lan"
;; ;;
ag-main) ag-main)
target_host="dns.lan" host="dns.lan"
;; ;;
exporters) exporters)
target_host="all" host="all"
;; ;;
grafana) grafana)
target_host="ubu.lan" host="ubu.lan"
;; ;;
jellyfin) jellyfin)
target_host="jf.lan" host="jf.lan"
;; ;;
kasm) kasm)
target_host="kasm.lan" host="kasm.lan"
;; ;;
netboot) netboot)
target_host="netboot.lan" host="netboot.lan"
;; ;;
nexterm) nexterm)
target_host="ubu.lan" host="ubu.lan"
;; ;;
npm) npm)
target_host="npm.lan" host="npm.lan"
;; ;;
plex) plex)
target_host="plex.lan" host="plex.lan"
;; ;;
paperless) paperless)
target_host="ubu.lan" host="ubu.lan"
;; ;;
portainer) portainer)
target_host="port.lan" host="port.lan"
;; ;;
runner) runner)
target_host="runner.lan" host="runner.lan"
;; ;;
# Add cases for other folders/hosts
*) *)
echo "Unknown folder: $folder" echo "Unknown folder: $folder"
exit 1 exit 1
;; ;;
esac esac
echo "Deploying to $target_host for folder $folder"
echo "target_host=$target_host" >> $GITHUB_ENV if [ -z "$hosts" ]; then
echo "folder=$folder" >> $GITHUB_ENV hosts="$host"
folders="$folder"
else
hosts="$hosts,$host"
folders="$folders,$folder"
fi
done done
echo "Deploying to hosts: $hosts for folders: $folders"
echo "target_host=$hosts" >> $GITHUB_ENV
echo "folder=$folders" >> $GITHUB_ENV
- name: Get Secrets from Bitwarden - name: Get Secrets from Bitwarden
id: bitwarden-secrets id: bitwarden-secrets
uses: https://github.com/bitwarden/sm-action@v2 uses: https://github.com/bitwarden/sm-action@v2

View file

@ -1,7 +1,7 @@
- name: Deploy application - name: Deploy application
hosts: "{{ target_host }}" hosts: "{{ target_host.split(',') | join(',') }}"
vars: vars:
repo_path: "/home/{{ ansible_user }}/iac/docker/{{ folder }}" repo_path: "/home/{{ ansible_user }}/iac/docker/{{ folder.split(',') | join(',') }}"
secrets_mapping_file: "/home/{{ ansible_user }}/iac/docker/secret-mappings.yml" secrets_mapping_file: "/home/{{ ansible_user }}/iac/docker/secret-mappings.yml"
tasks: tasks:
- name: Ensure the repository is up-to-date - name: Ensure the repository is up-to-date