zoukankan      html  css  js  c++  java
  • YAML语法

    YAML语法是ansible剧本的表达方式。

    • 所有YAML都可以选择以--—开始和...结束
    • 列表的所有成员都是以“-”开头的相同缩进级别的行(一个破折号和一个空格):
    ---
    # A list of tasty fruits
    - Apple
    - Orange
    - Strawberry
    - Mango
    ...
    
    • 字典以简单的形式表示(冒号后面必须有一个空格)
    # An employee record
    martin:
        name: Martin D'vloper
        job: Developer
        skill: Elite
    
    • 更为复杂的数据结构
    # Employee records
    -  martin:
        name: Martin D'vloper
        job: Developer
        skills:
          - python
          - perl
          - pascal
    -  tabitha:
        name: Tabitha Bitumen
        job: Developer
        skills:
          - lisp
          - fortran
          - erlang
    

    也可以用缩写形式:

    ---
    martin: {name: Martin D'vloper, job: Developer, skill: Elite}
    ['Apple', 'Orange', 'Strawberry', 'Mango']
    
    • 值可以使用|或>跨多行。使用“文字块标量”|跨越多行将包括新行和任何尾随空格。使用“折叠块标量”>将新行折叠到空格;它被用来使原本很长的一行更容易阅读和编辑。
    include_newlines: |
                exactly as you see
                will appear these three
                lines of poetry
    
    fold_newlines: >
                this is really a
                single line of text
                despite appearances
    
    • 示例
    ---
    # An employee record
    name: Martin D'vloper
    job: Developer
    skill: Elite
    employed: True
    foods:
        - Apple
        - Orange
        - Strawberry
        - Mango
    languages:
        perl: Elite
        python: Elite
        pascal: Lame
    education: |
        4 GCSEs
        3 A-Levels
        BSc in the Internet of Things
    
  • 相关阅读:
    大数据的起步:初学者
    接触区块链
    学习开始了,博客开始了
    hadoop分布式的搭建过程
    Java笔试题
    JavaSCript全局变量与局部变量
    OSGI
    restful
    jersey
    JSP+Servlet+Mybits小例子
  • 原文地址:https://www.cnblogs.com/os-linux/p/11938309.html
Copyright © 2011-2022 走看看