如何 运行 来自 ansible 剧本的 python 脚本

How to run a python script from a ansible playbook

正在尝试创建一个 yaml,它将 运行 一个 python 脚本连接到其他软件框架。

剧本看起来类似于:

---
- host: all
  tasks:
  - name: Connect to some framework
    script: testscript.py

这是正确的语法还是要添加到 yaml 文件中?

您可能应该添加解释器:

---
- host: all
  tasks:
  - name: Connect to some framework
    script: /path/to/testscript.py
    args:
      executable: /usr/bin/python