【发布时间】:2020-02-11 23:33:10
【问题描述】:
我正在尝试使用 ansible 运行我的 python 主文件。
name: Run project
become: yes
script: "{{repo}}/main.py --arg1 {{repo}}/configfile.py"
args:
chdir: "{{repo}}"
executable: "{{repo}}/venv/bin/python"
这个文件有多个从我的项目导入。我能够获取虚拟环境并使用 ansible 运行主脚本。但是,我收到此错误
但是,我收到此错误:
fatal: [local_machine]: FAILED! => {"changed": true, "msg": "non-zero return code", "rc": 1, "stderr": "Traceback (most recent call last):\n File \"/home/vagrant/.ansible/tmp/ansible-tmp-1571132915.6405714-115359809713305/main.py\", line 1, in <module>\n import utils\nModuleNotFoundError: No module named 'utils'\n", "stderr_lines": ["Traceback (most recent call last):", " File \"/home/vagrant/.ansible/tmp/ansible-tmp-1571132915.6405714-115359809713305/watch_scraper.py\", line 1, in <module>", " import utils", "ModuleNotFoundError: No module named 'utils'"], "stdout": "", "stdout_lines": []}
我如何让 ansible 运行脚本并让它知道它的上下文?
【问题讨论】: