我试图在多行上格式化以下命令任务。
tasks:
...
- name: Run the python file
command: "{{ lookup('env','HOME') }}/bin/pythonfile.py \"{{ cmd_status.stdout }}\" {{ test_number }}"
不需要格式化。pythonfile
被正确地执行。我尝试用>
格式化
tasks:
...
- name: Run the python file
command: >
"{{ lookup('env','HOME') }}/bin/pythonfile.py \"{{ cmd_status.stdout }}\" {{ test_number }}"
它赋予了:
"msg":"Errno 2没有这样的文件或目录“,
Debug:
"invocation": {
"module_args": {
"_raw_params": "\"/home/bin/pythonfile.py
关于在多行上格式化命令行的任何建议。
发布于 2017-10-06 16:49:32
简单地删除周围的引号:
command: >
{{ lookup('env','HOME') }}/bin/pythonfile.py "{{ cmd_status.stdout }}" {{ test_number }}
否则,整个字符串(包括空格和参数)被视为要运行的可执行文件的名称(注意,\"
围绕调试调用字符串中的整行)。
当您将其写成一行时,YAML解析器首先会对其进行解释和删除。
https://stackoverflow.com/questions/46615333
复制