【问题标题】:What is the purpose of ">" in "shell: >" within an Ansible task?Ansible任务中“shell:>”中“>”的目的是什么?
【发布时间】:2021-05-13 15:03:18
【问题描述】:

“>”字符在执行 shell 命令的简单 Ansible 任务中起到什么作用?对于我的一生,我找不到文档或提及这一点!这是任务的模板:

- name: <task_name>
  shell: >
    <command>

谢谢。

【问题讨论】:

    标签: ansible yaml


    【解决方案1】:

    &gt; 是 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
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-06-14
    • 2011-05-29
    • 1970-01-01
    • 2012-06-30
    • 2012-08-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多