我有这样一本易懂的剧本:
---
-hosts: amqp
vars:
id: "123"
roles:
-cc
现在,我希望在执行playbook时运行设置ID变量的python脚本
我知道我可以通过以下任务启动脚本:
tasks:
-name: script starter
script: idgenerator.py
args:
executable: python3
虽然python脚本的相关部分如下所示:
identifier = generate_id()
sys.stdout.write(identifier)
所以我的问题是如何用pythonfile的“return”值设置变量id
谢谢
编辑:多亏了@Zeitounator和他的示例代码,这个问题现在已经解决了,这就是解决方案或可能的方法
pre_tasks:
-name: script starter
script: idgenerator.py
args:
executable: python3
register: script_output
-name: factsetter
set_fact:
id: "{{ script_output.stdout }}"
目前没有回答
相关问题 更多 >
编程相关推荐