Hey @Fez,
This is one of the way of doing this:
- local_action: shell
head -1 {{ file }} | grep -v -q \$ANSIBLE_VAULT && ansible-vault encrypt {{ file }}
You'll also need --vault-password-file otherwise Ansible will stop processing and wait on prompt.