我正在使用此代码以编程方式运行 ansible:https ://github.com/jtyr/ansible-run_playbook带有一个简单的剧本,它只是从 Ubuntu 服务器收集事实并将它们打印到屏幕上:
- name: Test play
hosts: all
tasks:
- name: Debug task
debug:
msg: "{{hostvars[inventory_hostname]}}"
tags:
- debug
但我真正需要的是简单地将输出保存到 python 变量中,而不是通过模板运行它或输出到屏幕(我实际上将在 Django 应用程序中使用它)。有没有办法做到这一点?
感谢您的阅读。