It is not difficult to integrate this with /etc/ansible/facts.d .
You can store JSON files, INI files or executable scripts in this directory, and the content / output will be available as server facts after the installation module.
I'm not sure that this will take YAML. You might be lucky and this will just add a symlink to your /var/database_credentials.yml file. (YAML is not mentioned in the documents, but it would be strange if YAML is not supported, since almost everything in Ansible is based on YAML). If not, you can create a script in the language you prefer that reads this file and outputs a JSON object.
See Local Facts (Facts.d) in the docs.
source share