ceph-metrics
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 0s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 0s
This commit is contained in:
27
playbooker.sh
Normal file
27
playbooker.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get the list of changed files
|
||||
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
|
||||
|
||||
# Initialize an array for playbooks to run
|
||||
PLAYBOOKS_TO_RUN=()
|
||||
|
||||
# Check for changes in specific directories and add corresponding playbooks
|
||||
if echo "$CHANGED_FILES" | grep -q "roles/webserver/"; then
|
||||
PLAYBOOKS_TO_RUN+=("playbooks/webserver.yml")
|
||||
fi
|
||||
|
||||
if echo "$CHANGED_FILES" | grep -q "roles/database/"; then
|
||||
PLAYBOOKS_TO_RUN+=("playbooks/database.yml")
|
||||
fi
|
||||
|
||||
# Run the identified playbooks
|
||||
if [ ${#PLAYBOOKS_TO_RUN[@]} -gt 0 ]; then
|
||||
for playbook in "${PLAYBOOKS_TO_RUN[@]}"; do
|
||||
echo "Running playbook: $playbook"
|
||||
ansible-playbook "$playbook" -i inventory.ini
|
||||
done
|
||||
else
|
||||
echo "No relevant playbooks modified. Skipping Ansible run."
|
||||
fi
|
||||
shell: bash
|
||||
Reference in New Issue
Block a user