Ensure bash-completion also search for .yaml

Auto-complete ignores playbooks having .yaml
extension, which might be a good chunk of third-party playbooks.

Let's ensure we cover them as well.

Change-Id: If995d702ea58c4251b655ba2c3043dbf4f14e671
Signed-off-by: Dmitriy Rabotyagov <dmitriy.rabotyagov@cleura.com>
This commit is contained in:
Dmitriy Rabotyagov 2025-12-18 19:21:48 +01:00
parent 4f7c175803
commit 5fe6f2987b

View file

@ -42,6 +42,7 @@ _normalize_collection_playbook_paths(){
# Remove ".yml" extension (if present)
path=${path%.yml}
path=${path%.yaml}
# Replace slashes with dots
path=${path//\//.}
@ -83,7 +84,7 @@ _openstack_ansible() {
elif [[ "$prev" == "-l" ]] || [[ "$prev" == "--limit" ]]; then
completions=$(_ansible_hosts_inventory | grep -i "${cur}")
else
playbooks=$(find ${COLLECTION_PATH} -type f -name "*.yml" | grep playbooks)
playbooks=$(find ${COLLECTION_PATH} -type f \( -name "*.yml" -o -name "*.yaml" \) | grep playbooks)
completions=$(_normalize_collection_playbook_paths ${playbooks[@]} | grep -i "${cur}")
fi
COMPREPLY=($(compgen -W '${completions}' -- ${cur}))