I am using this code to run ansible programmatically: https://github.com/jtyr/ansible-run_playbook with a simple playbook that just gathers facts from an Ubuntu server and prints them to the screen:
- name: Test play
hosts: all
tasks:
- name: Debug task
debug:
msg: "{{hostvars[inventory_hostname]}}"
tags:
- debug
But what I really need is to simply save that output into a python variable instead of running it through a template or outputting to the screen (I will actually be using it inside of a Django app). Is there a way to do this?
Thank you for reading.