27 lines
754 B
Bash
Executable file
27 lines
754 B
Bash
Executable file
#!/bin/bash
|
|
|
|
script_relative_path="$(dirname "$0")"
|
|
declare -i playbook_number=1
|
|
mapfile -t playbook_list < <(find "$script_relative_path/playbooks" -type f | grep -oP '[^/]+\.yml$')
|
|
|
|
|
|
echo "Playbook list:"
|
|
for playbook in "${playbook_list[@]}"; do
|
|
echo " [$playbook_number] $playbook"
|
|
playbook_number+=1
|
|
done
|
|
|
|
read -rp "Select playbook number to execute: " selected_playbook_number
|
|
|
|
|
|
selected_playbook_name="${playbook_list[((selected_playbook_number - 1))]}"
|
|
|
|
if ! echo "$selected_playbook_number" | grep -qP '^[1-9][0-9]*$' || [[ -z "$selected_playbook_name" ]]; then
|
|
echo "Invalid playbook number entered."
|
|
exit 1
|
|
fi
|
|
|
|
|
|
echo "Selected playbook: $selected_playbook_name"
|
|
|
|
ansible-playbook "$script_relative_path/playbooks/$selected_playbook_name"
|