Ansible provides a feature where you can pass the password file or a script to be used while running the playbook. You can use --vault-password-file flag for this purpose and then add the filename. Something like this:
ansible-playbook site.yml --vault-password-file pswd.py