【发布时间】:2021-05-13 15:03:18
【问题描述】:
“>”字符在执行 shell 命令的简单 Ansible 任务中起到什么作用?对于我的一生,我找不到文档或提及这一点!这是任务的模板:
- name: <task_name>
shell: >
<command>
谢谢。
【问题讨论】:
“>”字符在执行 shell 命令的简单 Ansible 任务中起到什么作用?对于我的一生,我找不到文档或提及这一点!这是任务的模板:
- name: <task_name>
shell: >
<command>
谢谢。
【问题讨论】:
> 是 yaml 的标记。这意味着以下行将被压缩为单个字符串,前导缩进压缩为单个空格。有一些关于前导缩进的技术细节会修改最终字符串的生成方式,但对于 yaml 解析器来说,以下是等价的:
- name: task_name
shell: >
this is some
arbitrary string which may
be a shell command
- name: task2_name
shell: this is some arbitrary string which may be a shell command
【讨论】: