These are the exact situations where we need to use pass. Using pass, each password is stored inside a gpg encrypted file.
For example:
If you're trying to use passwords stored as servers/foo for server foo using Ansible, you can use it using pass like this:
servers]
foo ansible_sudo=True \
ansible_sudo_pass="{{ lookup('pipe', 'pass servers/foo') }}"