All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 0s
47 lines
1.4 KiB
Bash
Executable File
47 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
|
|
source /root/.bashrc
|
|
|
|
export PYENV_ROOT="$HOME/.pyenv"
|
|
export PATH="$PYENV_ROOT/bin:$PATH"
|
|
eval "$(/root/.pyenv/bin/pyenv init --path)"
|
|
eval "$(/root/.pyenv/bin/pyenv virtualenv-init -)"
|
|
pyenv global 3.14.0
|
|
|
|
ANSIBLE_CONFIG=/usr/share/ansible-repo/ansible.cfg
|
|
|
|
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
|
|
|
|
PLAYBOOKS_TO_RUN=()
|
|
PLAYBOOKS_TO_RUN_JUST_CREATED=()
|
|
|
|
# Check for changes in specific directories and add corresponding playbooks
|
|
if echo "$CHANGED_FILES" | grep -q "files/prometheus/"; then
|
|
PLAYBOOKS_TO_RUN+=("playbooks/software/prometheus.yml")
|
|
fi
|
|
|
|
if echo "$CHANGED_FILES" | grep -q "environments/just-created/"; then
|
|
PLAYBOOKS_TO_RUN_JUST_CREATED+=("playbooks/_common-setup.yml")
|
|
fi
|
|
|
|
|
|
PLAYBOOKS_TO_RUN2=( $(printf "%s\n" "${PLAYBOOKS_TO_RUN[@]}" | sort -u) )
|
|
|
|
# Run the identified playbooks
|
|
if [ ${#PLAYBOOKS_TO_RUN2[@]} -gt 0 ]; then
|
|
for playbook in "${PLAYBOOKS_TO_RUN2[@]}"; do
|
|
echo "Running playbook: $playbook"
|
|
ARA_API_CLIENT="http" ARA_API_SERVER="http://192.168.0.55:8000" ansible-playbook "$playbook" -i environments/proxmoxes/hosts.yml
|
|
done
|
|
fi
|
|
|
|
if [ ${#PLAYBOOKS_TO_RUN_JUST_CREATED[@]} -gt 0 ]; then
|
|
for playbook in "${PLAYBOOKS_TO_RUN_JUST_CREATED[@]}"; do
|
|
echo "Running playbook: $playbook"
|
|
ARA_API_CLIENT="http" ARA_API_SERVER="http://192.168.0.55:8000" ansible-playbook "$playbook" -i environments/just-created/hosts.yml
|
|
done
|
|
else
|
|
echo "No relevant playbooks modified. Skipping Ansible run."
|
|
fi
|