Ansible uses Jinja2 to output templates in whatever format is preferred by the thing being configured. I haven't personally seen Ansible used to output YAML... But people will do anything :-P
Ansible does use YAML as a configuration language though—something for which it's perfectly suited.
Don't tell the Ansible folks!