Skip to content

Instantly share code, notes, and snippets.

@Nani-o
Last active September 6, 2017 10:23
Show Gist options
  • Select an option

  • Save Nani-o/09ca2e3a3490f87ba9d4257348641c5f to your computer and use it in GitHub Desktop.

Select an option

Save Nani-o/09ca2e3a3490f87ba9d4257348641c5f to your computer and use it in GitHub Desktop.
bash - List all Ansible variables within a file or folder
#!/bin/bash
TARGET="$1"
if [[ ! -e "${TARGET}" ]]; then
echo "${TARGET}: no such file or directory"
exit 1
fi
grep --color=always -RoP "{{[A-z0-9 _-]*}}" "${TARGET}" | cut -d ':' -f2 | sort | uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment