【发布时间】:2016-05-10 10:42:14
【问题描述】:
我正在尝试从 ansible 脚本运行 python 脚本。我认为这将是一件容易的事情,但我无法弄清楚。我有一个这样的项目结构:
playbook-folder
roles
stagecode
files
mypythonscript.py
tasks
main.yml
release.yml
我正在尝试在 main.yml 中的任务中运行 mypythonscript.py(这是 release.yml 中使用的角色)。任务如下:
- name: run my script!
command: ./roles/stagecode/files/mypythonscript.py
args:
chdir: /dir/to/be/run/in
delegate_to: 127.0.0.1
run_once: true
我也试过 ../files/mypythonscript.py。我认为 ansible 的路径与剧本有关,但我猜不是?
我还尝试调试以确定我在脚本中间的位置,但也没有运气。
- name: figure out where we are
stat: path=.
delegate_to: 127.0.0.1
run_once: true
register: righthere
- name: print where we are
debug: msg="{{righthere.stat.path}}"
delegate_to: 127.0.0.1
run_once: true
这只是打印出“。”。太有帮助了...
【问题讨论】:
标签: ansible ansible-2.x